raphael     01/06/25 03:47:26

  Modified:    src/java/org/apache/jetspeed/portal PortalState.java
  Log:
  add support for portlet set customization
  
  Revision  Changes    Path
  1.4       +47 -4     
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortalState.java
  
  Index: PortalState.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortalState.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PortalState.java  2001/06/04 17:40:18     1.3
  +++ PortalState.java  2001/06/25 10:47:18     1.4
  @@ -54,6 +54,8 @@
   
   package org.apache.jetspeed.portal;
   
  +import org.apache.jetspeed.services.PortletFactory;
  +import org.apache.jetspeed.services.resources.JetspeedResources;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.Log;
   import org.apache.ecs.ConcreteElement;
  @@ -204,12 +206,12 @@
       public static ConcreteElement getCustomizeContent( PortletSet set, RunData data 
)
       {        
           String name = getCustomized( data );
  -        
  -        
  +                
           if (set.getName().equals(name))
           {
  -            // FIXME: we can't call getContent() because that would create
  -            // a loop, call the default customizer for this PortletSet
  +            // we can't call getContent() directly because that would create
  +            // a loop
  +            return getCustomizer(set,data).getContent(data);
           }
           else
           {
  @@ -258,4 +260,45 @@
           clearMaximized( rundata );
       }
   
  +    /** This method retrieves the appropriate customizer portlet for the 
  +     *  current portlet
  +     *
  +     *  @param p the portlet to customize
  +     *  @param data the RunData for this request
  +     *  @return the portlet object of the appropriate customizer
  +     */
  +    public static Portlet getCustomizer(Portlet p, RunData data)
  +    {
  +        Portlet customizer = p;
  +
  +        // if the portlet cannot customize itself...
  +        if (! (p instanceof PortletCustomizer) )
  +        {
  +
  +            //look for the customizer name in the portlet
  +            //config (from Registry definition)
  +        
  +            String name = p.getPortletConfig().getInitParameter("_customizer");
  +            
  +            if (name == null)
  +            {
  +                String key = (p instanceof PortletSet)?"PortletSet":"Portlet";      
      
  +
  +                name = 
JetspeedResources.getString("customizer."+key,key+"Customizer");
  +            }
  +        
  +            try
  +            {
  +                customizer = PortletFactory.getPortlet(name);
  +                data.getSession().setAttribute("customize", p);
  +            }
  +            catch (Exception e)
  +            {
  +                Log.error(e);
  +            }
  +        }
  +            
  +        return customizer;
  +    }
  +    
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to