You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by mo...@apache.org on 2002/08/20 19:38:31 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedTool.java

morciuch    2002/08/20 10:38:31

  Modified:    src/java/org/apache/jetspeed/util/template JetspeedTool.java
  Log:
  Added support for parameter presentation styles (see Bugzilla issue 11697)
  
  Revision  Changes    Path
  1.21      +95 -1     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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JetspeedTool.java	7 Aug 2002 06:02:15 -0000	1.20
  +++ JetspeedTool.java	20 Aug 2002 17:38:31 -0000	1.21
  @@ -72,9 +72,11 @@
   import org.apache.jetspeed.om.profile.Profile;
   import org.apache.jetspeed.om.profile.ProfileException;
   import org.apache.jetspeed.om.profile.Entry;
  +import org.apache.jetspeed.modules.ParameterLoader;
   
   import java.util.Enumeration;
   import java.util.Stack;
  +import java.util.Map;
   
   /**
    * Utility class for accessing Jetspeed in a "pull" mode
  @@ -549,4 +551,96 @@
   
           return result;
       }
  +
  +    /**
  +     * Return the content of a portlet using the portlet's name. This portlet is sought in
  +     * the registry. This is useful when you want to get portlet's content without
  +     * actually having the portlet in user's profile (for example, to preview a portlet
  +     * before adding it to the profile).
  +     * <P>
  +     * If a control name is specified to the portlet description, returns the defined
  +     * portlet and control, otherwise use the default control.
  +     * <P>
  +     * Issues to resolve:
  +     * <UL>
  +     * <LI> is new portlet instance created everytime someone previews the same portlet?
  +     * <LI>should use the same skin as the current pane
  +     * <LI>if TitlePortletControl is used, the action icons (max, min, etc) are not functional.
  +     * Also, customize icon should not be present.
  +     * <LI> interactive portlets (such as DatabaseBrowser) lose functionality (such as sorting
  +     * in DatabaseBrowser).
  +     * 
  +     * @param portletName
  +     *               Name of the portlet as defined in registry
  +     * @param controlName
  +     *               Optional control name to use in displaying the portlet
  +     * @return the rendered content of the portlet
  +     */
  +    public ConcreteElement getPortletFromRegistry(String portletName, String controlName)
  +    {
  +
  +        ConcreteElement result = null;
  +        Portlet p = null;
  +        
  +        try {
  +            // Always set portlet id to "preview" so each preview request gets it from the cache.
  +            // At least, I think that's how it works.
  +            p = PortletFactory.getPortlet(portletName, "preview");
  +            PortletControl control = controlName == null ? PortalToolkit.getControl((String)null) :
  +                                                           PortalToolkit.getControl(controlName);
  +            if (control != null)
  +            {
  +                JetspeedRunData jdata = (JetspeedRunData)rundata;
  +                // Use the profile's skin
  +                p.getPortletConfig().setSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
  +                control.setPortlet(p);
  +                control.init();
  +                result = control.getContent(rundata);
  +            } 
  +            else if (p!=null)
  +            {
  +                result = p.getContent(rundata);
  +            }
  +        } 
  +        catch (Exception e) 
  +        {
  +            Log.error(e);
  +            result = new ConcreteElement();
  +        }
  +                
  +        if (result == null)
  +        {
  +            //the customizer already streamed its content, return a stub
  +            result = new ConcreteElement();
  +        }
  +
  +        return result;
  +    }
  +
  +    /**
  +     * Returns a parameter in its defined parameter style
  +     * 
  +     * @param portlet
  +     * @param parmName
  +     * @return 
  +     */
  +    public static String getPortletParameter(RunData data, Portlet portlet, String parmName)
  +    {
  +        String result = null;
  +        try {
  +            if (portlet != null && parmName != null) {
  +                Map portletParms = portlet.getPortletConfig().getInitParameters();
  +                String parmValue = portlet.getPortletConfig().getInitParameter(parmName);
  +                String parmStyle = portlet.getPortletConfig().getInitParameter(parmName + ".style");
  +                if (parmStyle != null) {
  +                    result = ParameterLoader.getInstance().eval(data, parmStyle, parmName, parmValue, portletParms);                
  +                }
  +            }
  +        } catch (Exception e){
  +            Log.error(e);
  +        }
  +
  +        return result;
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>