taylor 02/03/08 22:29:17 Modified: src/java/org/apache/jetspeed/modules/actions/controllers PanedControllerAction.java src/java/org/apache/jetspeed/portal BasePortletSet.java PanedPortletController.java src/java/org/apache/jetspeed/portal/controllers CardPortletController.java VelocityPanedPortletController.java src/java/org/apache/jetspeed/portal/controls AbstractPortletControl.java VelocityPortletControl.java VelocityPortletSetControl.java src/java/org/apache/jetspeed/services/portaltoolkit JetspeedPortalToolkitService.java src/java/org/apache/jetspeed/util/template JetspeedTool.java Log: Converted over Velocity Paned Controllers and controls to use portlet ids for pane ids instead of names/position. WARNING: this breaks the Administrator Security portlets. Hope to have it fixed real soon. Revision Changes Path 1.5 +11 -62 jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/PanedControllerAction.java Index: PanedControllerAction.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/PanedControllerAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PanedControllerAction.java 23 Jul 2001 21:48:07 -0000 1.4 +++ PanedControllerAction.java 9 Mar 2002 06:29:16 -0000 1.5 @@ -83,6 +83,9 @@ * to work correctly * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> + * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> + * + * @version $Id: PanedControllerAction.java,v 1.5 2002/03/09 06:29:16 taylor Exp $ */ public class PanedControllerAction extends RowColumnControllerAction { @@ -94,75 +97,21 @@ Context context, RunData rundata ) { - PanedPortletController cont = (PanedPortletController)controller; PortletSet myPortlets = cont.getPortlets(); PortletControllerConfig conf = cont.getConfig(); - String pane = cont.retrievePaneName(rundata); - - Log.debug("PanedController: pane requested "+pane); - boolean searchTitle = false; - int paneNum = 0; - - try - { - paneNum = Integer.parseInt( pane ); - } - catch (Exception e) + String pane = cont.retrievePaneID(rundata, true); + Portlet pp = myPortlets.getPortletByID(pane); + if (null == pp) { - paneNum = 0; - searchTitle = true; + pane = cont.retrievePaneID(rundata, false); + pp = myPortlets.getPortletByID(pane); } + context.put("pane", pp); - if ( ( paneNum >= myPortlets.size() ) || ( paneNum <0 ) ) - { - paneNum = 0; - } - - boolean found = false; - - // first search in the child titles - if ( searchTitle == true ) - { - Enumeration en = myPortlets.getPortlets(); - while ( en.hasMoreElements() && ( ! found ) ) - { - Portlet p = (Portlet)en.nextElement(); - if ( p.getTitle().equals(pane) ) - { - context.put("pane", p ); - pane = p.getTitle(); - found=true; - } - } - } - - // then in the explicit position field - if (!found) - { - Enumeration en = myPortlets.getPortlets(); - while ( en.hasMoreElements() && ( ! found ) ) - { - Portlet p = (Portlet)en.nextElement(); - if ( p.getPortletConfig().getPosition() == paneNum ) - { - context.put("pane", p ); - pane = String.valueOf( paneNum ); - found=true; - } - } - } + cont.savePaneID(rundata,pane); + } - // then in the implicit position - if (!found) - { - context.put("pane",myPortlets.getPortletAt(paneNum)); - pane = String.valueOf( paneNum ); - } - - Log.debug("PanedController: pane found "+pane+" context object "+context.get("pane")); - cont.savePaneName(rundata,pane); - } } 1.16 +3 -2 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java Index: BasePortletSet.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- BasePortletSet.java 6 Mar 2002 17:03:33 -0000 1.15 +++ BasePortletSet.java 9 Mar 2002 06:29:16 -0000 1.16 @@ -83,7 +83,8 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> * @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a> - * @version $Id: BasePortletSet.java,v 1.15 2002/03/06 17:03:33 taylor Exp $ + * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> + * @version $Id: BasePortletSet.java,v 1.16 2002/03/09 06:29:16 taylor Exp $ */ public class BasePortletSet implements PortletSet, Portlet, PortletState { @@ -208,7 +209,7 @@ if (portlet.getID().equals(id)) return portlet; } - return portlet; + return null; } /** 1.8 +44 -8 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PanedPortletController.java Index: PanedPortletController.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PanedPortletController.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- PanedPortletController.java 27 Aug 2001 15:50:27 -0000 1.7 +++ PanedPortletController.java 9 Mar 2002 06:29:16 -0000 1.8 @@ -64,10 +64,18 @@ * to build the correct links for referencing the hidden portlets * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> - * @version $Id: PanedPortletController.java,v 1.7 2001/08/27 15:50:27 raphael Exp $ + * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> + * + * @version $Id: PanedPortletController.java,v 1.8 2002/03/09 06:29:16 taylor Exp $ */ public interface PanedPortletController extends PortletController, PortletSetController { + /* + * @return the pane parameter name + * + */ + public String getPaneParameter(); + /** * Test whether the selected portlet is considered selected for the current * request. @@ -89,26 +97,54 @@ public DynamicURI getPortletURI( Portlet p, RunData rundata ); /** + * Returns the pane id of the parameter used for pane selection + * + * @param rundata The request data. + * @param byParameter Set to true to look by query parameter first. + * @return String The pane id for the selected pane. + */ + public String retrievePaneID(RunData rundata, boolean byParameter); + + /** + * Saves the pane id to the session to remember selection state of menu or tab. + * + * @param rundata The request data. + * @param id The tab id to save for this controller + */ + public void savePaneID( RunData rundata, String id ); + + /** + * Sets the name of the pane that should + * be displayed + * + * @deprecated + * + * @param name the selection parameter name + */ + public void savePaneName( RunData data, String name ); + + /** * Returns the name of the pane selector parameter for this controller + * + * @deprecated */ public String getParameterName(); /** * Sets the name of the pane selector parameter for this controller * @param name the new parameter name + * + * @deprecated */ public void setParameterName(String name); /** * Returns the name of the pane that should be displayed + * + * @deprecated + * + * @param byParameter Set to true to look by query parameter first. */ public String retrievePaneName(RunData rundata); - /** - * Sets the name of the pane that should - * be displayed - * - * @param name the selection parameter name - */ - public void savePaneName( RunData data, String name ); } 1.21 +36 -13 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controllers/CardPortletController.java Index: CardPortletController.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controllers/CardPortletController.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- CardPortletController.java 6 Mar 2002 17:03:34 -0000 1.20 +++ CardPortletController.java 9 Mar 2002 06:29:17 -0000 1.21 @@ -81,7 +81,7 @@ or with an invalid value, use the first portlet (position 0)</li> </p> @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> -@version $Id: CardPortletController.java,v 1.20 2002/03/06 17:03:34 taylor Exp $ +@version $Id: CardPortletController.java,v 1.21 2002/03/09 06:29:17 taylor Exp $ */ public class CardPortletController extends AbstractPortletController implements PanedPortletController @@ -99,18 +99,6 @@ PortletSet myPortlets = this.getPortlets(); PortletControllerConfig conf = getConfig(); - /* - String id = rundata.getParameters().getString( "peid" ); - System.out.println("id = " + id); - - if (id != null) - { - Portlet p = myPortlets.getPortletByID(id); - System.out.println("p = " + p.getID()); - base.addElement( p.getContent( rundata ) ); - return base; - } - */ String pane = rundata.getParameters().getString( getParameterName() ); if (pane == null) @@ -348,4 +336,39 @@ { return getConfig().getInitParameter( "defaultcard", "0" ); } + + /** + * Returns the pane id of the parameter used for pane selection + * + * @param rundata The request data. + * @param byParameter Set to true to look by query parameter first. + * @return String The pane id for the selected pane. + * + */ + public String retrievePaneID(RunData rundata, boolean byParameter) + { + return ""; + } + + /** + * Saves the pane id to the session to remember selection state of menu or tab. + * + * @param rundata The request data. + * @param id The tab id to save for this controller + */ + public void savePaneID( RunData data, String id ) + { + } + + public static final String PANE_PARAMETER = "js_pane"; + + /* + * @return the pane parameter name + * + */ + public String getPaneParameter() + { + return PANE_PARAMETER; + } + } 1.4 +120 -43 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controllers/VelocityPanedPortletController.java Index: VelocityPanedPortletController.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controllers/VelocityPanedPortletController.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- VelocityPanedPortletController.java 4 Dec 2001 18:35:51 -0000 1.3 +++ VelocityPanedPortletController.java 9 Mar 2002 06:29:17 -0000 1.4 @@ -69,11 +69,25 @@ * is visible at any given time) * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> + * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> + * + * @version $Id: VelocityPanedPortletController.java,v 1.4 2002/03/09 06:29:17 taylor Exp $ */ + public class VelocityPanedPortletController extends VelocityPortletController implements PanedPortletController { public static final String DEFAULT_PARAMETER = "pane"; + public static final String PANE_PARAMETER = "js_pane"; + + /* + * @return the pane parameter name + * + */ + public String getPaneParameter() + { + return PANE_PARAMETER; + } /** * Test whether the selected portlet is considered selected for the current @@ -85,73 +99,129 @@ */ public boolean isSelected( Portlet p, RunData rundata ) { - String pane = retrievePaneName(rundata); - boolean searchTitle = false; - int paneNum = 0; - - //should we test based on name/title or position - try - { - paneNum = Integer.parseInt( pane ); - } catch (Exception e) { - paneNum = 0; - searchTitle = true; - } - - // first search in the child titles... - if ( searchTitle == true ) + String peid = rundata.getParameters().getString( getPaneParameter() ); + String myid = getPortlets().getID(); + String last = (String)rundata.getUser().getTemp( PANE_PARAMETER + myid ); + if (peid == null) { - return ( p.getName().equals(pane) || p.getTitle().equals(pane) ); + if (last == null) + { + return (getPortlets().getPortletAt( 0 ) == p); + } + else + { + return (p.getID().equals(last)); + } } - else - { - // ...then explicit position parameters... - if ( p.getPortletConfig().getPosition() == paneNum ) + else + { + if (p.getID().equals(peid)) + return true; + // is the peid for this tab set? + if (getPortlets().getPortletByID(peid) != null) + { + // its for another tab in this set + return false; + } + else { - return true; + if (last == null) + return (getPortlets().getPortletAt( 0 ) == p); + else + return (p.getID().equals(last)); } } + } - // ...finally test implicit position - - // sanity check: the position sought should be positive and lower than set size - if ( ( paneNum >= getPortlets().size() ) || ( paneNum <0 ) ) - { - return false; - } + /** + * Builds the link to access to a given pane. + * + * @param rundata The request data. + * @param portlet The portlet to build the link for by id. + * @return DynamicURI A new Dynamic URI with the query parameter + */ + public DynamicURI getPortletURI( Portlet portlet, RunData rundata ) + { + DynamicURI uri = new DynamicURI( rundata ); - return ( getPortlets().getPortletAt( paneNum ) == p ); + // is this necessary? + uri.removeQueryData( getPaneParameter() ); + + uri.addQueryData( getPaneParameter(), portlet.getID() ); + return uri; } /** - Builds the link to access to a given pane. - */ - public DynamicURI getPortletURI( Portlet p, RunData rundata ) + * Returns the pane id of the parameter used for pane selection + * + * @param rundata The request data. + * @param byParameter Set to true to look by query parameter first. + * @return String The pane id for the selected pane. + * + */ + public String retrievePaneID(RunData rundata, boolean byParameter) { + if (false == byParameter) + return retrievePaneIDFromSession(rundata); - String title = p.getTitle(); + String pane = rundata.getParameters().getString( getPaneParameter() ); - DynamicURI uri = new DynamicURI( rundata ); + if (pane == null) + { + // the parameter is undefined, search for sticky value in session + String id = getPortlets().getID(); + pane = (String)rundata.getUser().getTemp( PANE_PARAMETER + id ); + if (pane == null) + { + // use default + pane = getPortlets().getPortletAt(0).getID(); - uri.removePathInfo( getParameterName() ); - uri.removeQueryData( getParameterName() ); + } + } + + return pane; + } - if ( MetaData.DEFAULT_TITLE.equals( title ) ) - { - uri.addPathInfo( getParameterName(), p.getPortletConfig().getPosition() ); - } - else + /** + * Returns the pane id from the session for pane selection + * + * @param rundata The request data. + * @return String The pane id for the selected pane. + * + */ + protected String retrievePaneIDFromSession(RunData rundata) + { + // the parameter is undefined, search for sticky value in session + String id = getPortlets().getID(); + String pane = (String)rundata.getUser().getTemp( PANE_PARAMETER + id ); + + if (pane == null) { - uri.addPathInfo( getParameterName(), title ); + // use default + pane = getPortlets().getPortletAt(0).getID(); + } + + return pane; + } - return uri; + /** + * Saves the pane id to the session to remember selection state of menu or tab. + * + * @param rundata The request data. + * @param id The tab id to save for this controller + */ + public void savePaneID( RunData data, String id ) + { + data.getUser().setTemp( PANE_PARAMETER + getPortlets().getID(), id ); } /** * Sets the name of the parameter that will define which pane should * be displayed * + * @deprecated + * * @param name the selection parameter name */ public void setParameterName( String name ) @@ -161,6 +231,8 @@ /** * Returns the name of the parameter used for pane selection + * + * @deprecated */ public String getParameterName() { @@ -170,6 +242,9 @@ /** * Returns the name of the parameter used for pane selection + * + * @deprecated + * */ public String retrievePaneName(RunData rundata) { @@ -193,6 +268,8 @@ /** * Sets the name of the parameter that will define which pane should * be displayed + * + * @deprecated * * @param name the selection parameter name */ 1.14 +3 -8 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/AbstractPortletControl.java Index: AbstractPortletControl.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/AbstractPortletControl.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- AbstractPortletControl.java 6 Mar 2002 18:32:34 -0000 1.13 +++ AbstractPortletControl.java 9 Mar 2002 06:29:17 -0000 1.14 @@ -91,7 +91,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> * @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a> - * @version $Id: AbstractPortletControl.java,v 1.13 2002/03/06 18:32:34 taylor Exp $ + * @version $Id: AbstractPortletControl.java,v 1.14 2002/03/09 06:29:17 taylor Exp $ */ public abstract class AbstractPortletControl extends AbstractPortlet implements PortletControl @@ -105,11 +105,6 @@ private Portlet portlet = null; private PortletControlConfig conf = null; - /** - Provide a Unique Portlet ID - */ - private String id = null; - // PortletControl specifc interface /** @@ -756,12 +751,12 @@ public String getID() { - return id; + return this.portlet.getID(); } public void setID(String id) { - this.id = id; + this.portlet.setID(id); } /** 1.12 +3 -0 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java Index: VelocityPortletControl.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- VelocityPortletControl.java 18 Jan 2002 12:39:43 -0000 1.11 +++ VelocityPortletControl.java 9 Mar 2002 06:29:17 -0000 1.12 @@ -105,6 +105,9 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Roberto Carrasco</a> * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> + * + * @version $Id: VelocityPortletControl.java,v 1.12 2002/03/09 06:29:17 taylor Exp $ + * */ public class VelocityPortletControl extends AbstractPortletControl { 1.6 +2 -17 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java Index: VelocityPortletSetControl.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- VelocityPortletSetControl.java 6 Mar 2002 17:03:34 -0000 1.5 +++ VelocityPortletSetControl.java 9 Mar 2002 06:29:17 -0000 1.6 @@ -77,6 +77,8 @@ * child * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> + * + * @version $Id: VelocityPortletSetControl.java,v 1.6 2002/03/09 06:29:17 taylor Exp $ */ public class VelocityPortletSetControl extends VelocityPortletControl { @@ -138,24 +140,7 @@ if ( controller != null ) { tab.setSelected(controller.isSelected(p, rundata)); - /* - String pane = rundata.getParameters().getString( "peid" ); - if (null != pane) - { - tab.setSelected(pane.equals(p.getID())); - context.put("portlet", portlets.getPortletByID(pane)); - } - else - { - tab.setSelected(count == 0); - } - */ tab.setLink(controller.getPortletURI( p, rundata ).toString()); -/* - DynamicURI duri = new DynamicURI( rundata ); - duri.addPathInfo("peid", p.getID()); - tab.setLink(duri.toString()); -*/ } tab.setActions(buildActionList(rundata, p)); 1.14 +4 -2 jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit/JetspeedPortalToolkitService.java Index: JetspeedPortalToolkitService.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit/JetspeedPortalToolkitService.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- JetspeedPortalToolkitService.java 7 Mar 2002 01:26:24 -0000 1.13 +++ JetspeedPortalToolkitService.java 9 Mar 2002 06:29:17 -0000 1.14 @@ -82,7 +82,9 @@ * Simple implementation of the PortalFactoryService. * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> - * @version $Id: JetspeedPortalToolkitService.java,v 1.13 2002/03/07 01:26:24 taylor Exp $ + * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> + * + * @version $Id: JetspeedPortalToolkitService.java,v 1.14 2002/03/09 06:29:17 taylor Exp $ */ public class JetspeedPortalToolkitService extends TurbineBaseService implements PortalToolkitService @@ -359,8 +361,8 @@ int nextID = lastID.getValue() + 1; while (!unidentified.empty()) { - //System.out.println("nextid = " + nextID); Portlet p = (Portlet)unidentified.pop(); + p.setID(String.valueOf(nextID)); nextID++; } 1.14 +5 -5 jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTool.java Index: JetspeedTool.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTool.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- JetspeedTool.java 8 Mar 2002 01:21:00 -0000 1.13 +++ JetspeedTool.java 9 Mar 2002 06:29:17 -0000 1.14 @@ -87,7 +87,9 @@ * shared between threads and/or requests</strong> * * @author <a href="mailto:[EMAIL PROTECTED]">Raphaël Luta</a> - * @version $Id: JetspeedTool.java,v 1.13 2002/03/08 01:21:00 taylor Exp $ + * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> + * + * @version $Id: JetspeedTool.java,v 1.14 2002/03/09 06:29:17 taylor Exp $ */ public class JetspeedTool implements ApplicationTool { @@ -330,7 +332,7 @@ { // FIXME: need to write this function // Portlets ps = doc.getPortletsById(id); - result = new StringElement("not implemented"); + result = new StringElement("not implemented - PortletElement"); } else { @@ -338,11 +340,9 @@ if (p != null) { result = p.getContent(rundata); - System.out.println("id = " + p.getID()); - System.out.println("name = " + p.getName()); } else - result = new StringElement("error retrieving"); + result = new StringElement("Error retrieving PortletElement"); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>