1 package org.apache.jetspeed.portal.portlets; 2 3 import org.apache.turbine.util.RunData; 5 6 import org.apache.jetspeed.portal.Portlet; 8 import org.apache.jetspeed.portal.PortletException; 9 import org.apache.jetspeed.portal.portlets.AbstractPortlet; 10 import org.apache.jetspeed.portal.service.PersistenceService; 11 import org.apache.jetspeed.portal.service.ServiceFactory; 12 import org.apache.jetspeed.portal.service.ServiceException; 13 14 15 20 public abstract class AbstractVTLPortlet extends AbstractPortlet 21 { 22 23 26 public void init( ) throws PortletException 27 { 28 setCacheable( false ); 29 } 30 31 36 public boolean getAllowMinimize( RunData rundata ) 37 { 38 return rundata.getUser() != null && rundata.getUser().hasLoggedIn(); 39 } 40 41 46 public boolean getAllowClose( RunData rundata ) 47 { 48 return rundata.getUser() != null && rundata.getUser().hasLoggedIn(); 49 } 50 51 59 public String getAttribute( String attrName, String attrDefValue, RunData rundata ) 60 { 61 String attrValue = null ; 62 63 try 64 { 65 Object [] params = { this }; 66 PersistenceService ps = (PersistenceService)ServiceFactory 67 .getService( PersistenceService.class, 68 rundata, params); 69 attrValue = ps.getPage().getAttribute( attrName ); 70 if( attrValue == null ) 71 { 72 attrValue = attrDefValue ; 73 } 74 } 75 catch ( ServiceException e ) 76 { 77 attrValue = attrDefValue ; 78 } 79 80 return attrValue; 81 } 82 83 90 public void setAttribute( String attrName, String attrValue, RunData rundata ) 91 { 92 try 93 { 94 Object [] params = { this }; 95 PersistenceService ps = (PersistenceService)ServiceFactory 96 .getService( PersistenceService.class, 97 rundata, params); 98 ps.getPage().setAttribute( attrName, attrValue ); 99 ps.store(); 100 } 101 catch ( ServiceException e ) {} 102 } 103 104 110 public void setMinimized( boolean minimize, RunData rundata ) 111 { 112 if( this.getAllowMinimize( rundata ) ) 113 { 114 this.setAttribute("minimized", minimize ? "true" : "false", rundata ); 115 } 116 } 117 118 123 public boolean isMinimized( RunData rundata ) 124 { 125 return this.getAttribute("minimized", "false", rundata ).equals("true"); 126 } 127 128 134 public boolean isButtonMaximize( RunData rundata ) 135 { 136 String portlet = rundata.getParameters().getString ( "portlet", "" ); 137 String button = rundata.getParameters().getString ( "button", "" ); 138 139 return portlet.equals( this.getName() ) && button.equals("maximize"); 140 } 141 142 148 public boolean isButtonConfigure( RunData rundata ) 149 { 150 String portlet = rundata.getParameters().getString ( "portlet", "" ); 151 String button = rundata.getParameters().getString ( "button", "" ); 152 153 return portlet.equals( this.getName() ) && button.equals("configure"); 154 } 155 156 157 } 158 | Popular Tags |