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/webapp/WEB-INF/templates/vm/portlets/html customize-update_save_row.vm
Date Wed, 11 Jun 2003 18:45:10 GMT
morciuch    2003/06/11 11:45:10

  Modified:    src/java/org/apache/jetspeed/modules/actions/portlets
                        CustomizeAction.java
               webapp/WEB-INF/templates/vm/portlets/html
                        customize-update_save_row.vm
  Log:
  Portlet customizer now allows to set parameter values to empty string (see Bugzilla bug#
18806)
  
  Revision  Changes    Path
  1.19      +75 -23    jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java
  
  Index: CustomizeAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- CustomizeAction.java	4 Mar 2003 00:04:53 -0000	1.18
  +++ CustomizeAction.java	11 Jun 2003 18:45:10 -0000	1.19
  @@ -102,6 +102,8 @@
   public class CustomizeAction extends VelocityPortletAction
   {
   
  +    public static final String PARAM_NAMESPACE = "_param_";
  +
       /**
        * Subclasses must override this method to provide default behavior
        * for the portlet action
  @@ -197,6 +199,57 @@
           }
       }
   
  +    /**
  +     * Resets the portlet settings to default
  +     * 
  +     * @param rundata
  +     * @param context
  +     */
  +    public void doDefault(RunData rundata, Context context)
  +    {                    
  +        // we should first retrieve the portlet to customize and its parameters
  +        // definition
  +        Portlet p = ((JetspeedRunData) rundata).getCustomized();
  +
  +        // Update paramaters
  +        try
  +        {
  +            PortletInstance instance = PersistenceManager.getInstance(p, rundata);
  +
  +            instance.removeAllAttributes();
  +
  +            try
  +            {
  +                ((JetspeedRunData) rundata).getCustomizedProfile().store();
  +            }
  +            catch (Exception e)
  +            {
  +                Log.error("Unable to save profile ",e);
  +            }
  +
  +            //FIXME: this hack is due to the corrupted lifecycle of the portlet in the
  +            //current API when caching is activated
  +            try
  +            {
  +                org.apache.jetspeed.util.PortletSessionState.setPortletConfigChanged(p,
rundata);
  +                p.init();
  +            }
  +            catch (PortletException e)
  +            {
  +                Log.error("Customizer failed to reinitialize the portlet "+p.getName(),
e);
  +            }
  +
  +            // we're done, make sure clean up the
  +            // session
  +            doCancel(rundata, context);
  +        }
  +        catch (Exception e)
  +        {
  +            Log.error(e);
  +        }
  +    }
  +
  +
       /** Updates the customized portlet entry */
       public void doUpdate(RunData rundata, Context context)
       {
  @@ -363,34 +416,33 @@
                   Parameter param = (Parameter)i.next();
                   String name = param.getName();
                   String newValue = rundata.getParameters().getString(name);
  +                String regValue = param.getValue();
  +                String psmlValue = instance.getAttribute(name);
   
  -                // we treat null and empty string in the same way, we should
  -                // probably find a better system as they may have different semantic
  -                if ((newValue==null)||(newValue.equals("")))
  -                {
  -                    // this will fail if the parameter is currently set in the registry
  -                    // but not in the PSML entry. This is a good thing !
  -                    instance.removeAttribute(name);
  -                }
  -                else
  +                //System.out.println(name + "= [" + psmlValue + "] in psml");
  +                //System.out.println(name + "= [" + regValue + "] in registry");
  +
  +                // New value for this parameter exists
  +                if (newValue != null)
                   {
  -                    // only update if the value changed
  -                    if (!newValue.equals(p.getPortletConfig().getInitParameter(name)))
  +                    System.out.println(name + "= [" + newValue + "] in request");
  +                    // New value differs from registry - record it in psml
  +                    if (!regValue.equals(newValue))
                       {
  -                        instance.setAttribute(name,newValue);
  -                        // Note: setting the portlet's config *IS NOT* a good idea -
  -                        // it might be used as the Portlet for other PSMLDocument Entries
that
  -                        // used to have the same parameters as this one (Portlets *ARE*
cached on
  -                        // their parameters), so changing the parameters like this changes
them for
  -                        // all and make the Portlet *NOT MATCH* the cache handle.
  -                        // It's ok not to do this here, since when this PSML is next rendered,
  -                        // it will look for a portlet with the new set of parameters, and
will
  -                        // find / create a new one if needed - ggolden
  -
  -                        //pc.setInitParameter(name,newValue);
  -                        madePsChange = true;
  +                        instance.setAttribute(name, newValue);
  +                        psmlValue = newValue;
  +                        //System.out.println("setting attribute for [" + name + "]");
                       }
  +                    madePsChange = true;
                   }
  +                // Remove duplicate parameters from psml
  +                if (psmlValue != null && psmlValue.equals(regValue))
  +                {
  +                    //System.out.println("removing attribute for [" + name + "]");
  +                    instance.removeAttribute(name);
  +                    madePsChange = true;
  +                }
  +
               }
   
               // save all the changes
  
  
  
  1.2       +3 -1      jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customize-update_save_row.vm
  
  Index: customize-update_save_row.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customize-update_save_row.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- customize-update_save_row.vm	2 Jul 2002 07:22:38 -0000	1.1
  +++ customize-update_save_row.vm	11 Jun 2003 18:45:10 -0000	1.2
  @@ -3,6 +3,8 @@
         <td align="center" colspan="2">
            <input type="submit" name="eventSubmit_doUpdate" value="$l10n.CUSTOMIZER_UPDATE">
            &nbsp;
  +         <input type="submit" name="eventSubmit_doDefault" value="Default" TITLE="Reset
to default">
  +         &nbsp;
            <input type="submit" name="eventSubmit_doCancel" value="$l10n.CUSTOMIZER_CANCEL">
         </td>
       </tr>
  
  
  

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


Mime
View raw message