portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morci...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util PortletSessionState.java
Date Fri, 18 Oct 2002 17:46:37 GMT
morciuch    2002/10/18 10:46:37

  Modified:    src/java/org/apache/jetspeed/util PortletSessionState.java
  Log:
  Added methods to query portlet config changed state. This is useful with custom portlets
and allows to react to user customization.
  
  Revision  Changes    Path
  1.6       +43 -8     jakarta-jetspeed/src/java/org/apache/jetspeed/util/PortletSessionState.java
  
  Index: PortletSessionState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/PortletSessionState.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PortletSessionState.java	3 Oct 2002 21:46:48 -0000	1.5
  +++ PortletSessionState.java	18 Oct 2002 17:46:37 -0000	1.6
  @@ -73,6 +73,11 @@
   {
   
       /**
  +     * Portlet attribute to save config state.
  +     */
  +    public static final String CONFIG_CHANGED = "config_changed";
  +
  +    /**
       Returns the parameter for this name from the Temp - session object
       */
       public static Object getAttribute(RunData rundata, String attrName)
  @@ -118,12 +123,12 @@
       }
   
       /**
  -     * Returns the parameter for this name using the following search path:
  +     * Returns the attribute for this name using the following search path:
        * <ul>
  -     * <li>request</li>
  -     * <li>session</li>
  -     * <li>instance</li>     
  -     * <li>config</li>
  +     * <li>request parameter</li>
  +     * <li>session attribute</li>
  +     * <li>instance attribute</li>     
  +     * <li>config parameter</li>
        * <ul>
        * Uses the portlet parameter to generate a unique key.
        * 
  @@ -154,13 +159,13 @@
               }
           }
   
  -        // Look in the session
  +        // Look in the session attributes
           if (result == null) 
           {
               result = getAttribute(portlet, rundata, attrName);
           }
   
  -        // Look in the instance
  +        // Look in the instance attributes
           if (result == null)
           {
               result = portlet.getAttribute(attrName, null, rundata);
  @@ -285,6 +290,36 @@
       public static void clearAttribute(VelocityPortlet portlet, RunData rundata, String
attrName)
       {
           clearAttribute((Portlet) portlet, rundata, attrName);
  +    }
  +
  +    /**
  +     * The portlet config has changed. Calling getPortletConfigChanged returns the current
state
  +     * and resets it.
  +     * 
  +     * @param portlet
  +     * @param rundata
  +     */
  +    public static void setPortletConfigChanged(Portlet portlet, RunData rundata)
  +    {
  +        setAttribute(portlet, rundata, CONFIG_CHANGED, "true");
  +    }
  +
  +    /**
  +     * Returns current state of portlet config and resets it if set.
  +     * 
  +     * @param portlet
  +     * @param rundata
  +     * @return TRUE if portlet config has changed
  +     */
  +    public static boolean getPortletConfigChanged(Portlet portlet, RunData rundata)
  +    {
  +        String state = (String) getAttribute(portlet, rundata, CONFIG_CHANGED);
  +        if (state != null)
  +        {
  +            clearAttribute(portlet, rundata, CONFIG_CHANGED);
  +        }
  +
  +        return state != null;
       }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message