portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks Lookup.java GenericFrameworkPortlet.java
Date Fri, 12 Nov 2004 19:35:46 GMT
taylor      2004/11/12 11:35:46

  Modified:    portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks
                        Lookup.java GenericFrameworkPortlet.java
  Log:
  - add bean parameter to actions
  - support for isNew for typical form beans
  
  Revision  Changes    Path
  1.2       +2 -1      jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/Lookup.java
  
  Index: Lookup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/Lookup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Lookup.java	12 Nov 2004 06:28:56 -0000	1.1
  +++ Lookup.java	12 Nov 2004 19:35:46 -0000	1.2
  @@ -25,4 +25,5 @@
   public interface Lookup
   {
       boolean lookup(String key);
  +    boolean isNew();
   }
  
  
  
  1.8       +33 -20    jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/GenericFrameworkPortlet.java
  
  Index: GenericFrameworkPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/GenericFrameworkPortlet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- GenericFrameworkPortlet.java	12 Nov 2004 06:28:56 -0000	1.7
  +++ GenericFrameworkPortlet.java	12 Nov 2004 19:35:46 -0000	1.8
  @@ -56,6 +56,7 @@
    */
   public class GenericFrameworkPortlet extends GenericVelocityPortlet
   {
  +
       /**
        * Init Parameter: default spring configuration property
        */
  @@ -69,11 +70,12 @@
       private static final String PREFS_SUFFIX = ".prefs";
   
       private static final String SESSION_ERROR_MESSAGES = "portals.bridges.framework.errors";
  +
       /**
        * Action signature for calling velocity portlet actions
        */
       private static final Class[] VELOCITY_PORTLET_ACTION_SIGNATURE =
  -    { ActionRequest.class, ActionResponse.class};
  +    { ActionRequest.class, ActionResponse.class, Object.class};
   
       private static PortletApplicationModel model = null;
   
  @@ -87,7 +89,7 @@
       {
           model.setExternalSupport(map);
       }
  -    
  +
       public void init(PortletConfig config) throws PortletException
       {
           super.init(config);
  @@ -141,7 +143,7 @@
           if (errors.isEmpty())
           {
               request.getPortletSession().removeAttribute(SESSION_ERROR_MESSAGES, PortletSession.PORTLET_SCOPE);
  -            
  +
               // (4) execute the velocity action
               String action = request.getParameter(FrameworkConstants.BRIDGES_ACTION);
               if (null == action)
  @@ -157,7 +159,7 @@
               else
               {
                   // call the specified action in the post params
  -                String actionForward = invokeVelocityPortletAction(action, request, response);
  +                String actionForward = invokeVelocityPortletAction(action, request, response,
bean);
                   forward = model.getForward(actionForward);
               }
           }
  @@ -327,7 +329,8 @@
                   if (view == null || view.equals(this.getDefaultViewPage()))
                   {
                       // clear it
  -                    response.setRenderParameter(FrameworkConstants.VIEW_VIEW_MODE, view);
//(String) null);
  +                    response.setRenderParameter(FrameworkConstants.VIEW_VIEW_MODE, view);
//(String)
  +                                                                                      
   // null);
                   }
                   else
                   {
  @@ -339,7 +342,8 @@
                   if (view == null || view.equals(this.getDefaultEditPage()))
                   {
                       // clear it
  -                    response.setRenderParameter(FrameworkConstants.VIEW_EDIT_MODE, view);
//(String) null);
  +                    response.setRenderParameter(FrameworkConstants.VIEW_EDIT_MODE, view);
//(String)
  +                                                                                      
   // null);
                   }
                   else
                   {
  @@ -350,7 +354,8 @@
               {
                   if (view == null || view.equals(this.getDefaultHelpPage()))
                   {
  -                    response.setRenderParameter(FrameworkConstants.VIEW_HELP_MODE, view);
//(String) null);
  +                    response.setRenderParameter(FrameworkConstants.VIEW_HELP_MODE, view);
//(String)
  +                                                                                      
   // null);
                   }
                   else
                   {
  @@ -365,7 +370,8 @@
                   if (view == null || view.equals(this.getDefaultViewPage()))
                   {
                       // clear it
  -                    response.setRenderParameter(FrameworkConstants.VIEW_VIEW_MODE, view);
//(String) null);
  +                    response.setRenderParameter(FrameworkConstants.VIEW_VIEW_MODE, view);
//(String)
  +                                                                                      
   // null);
                   }
                   else
                   {
  @@ -377,7 +383,8 @@
                   if (view == null || view.equals(this.getDefaultEditPage()))
                   {
                       // clear it
  -                    response.setRenderParameter(FrameworkConstants.VIEW_EDIT_MODE, view);
//(String) null);
  +                    response.setRenderParameter(FrameworkConstants.VIEW_EDIT_MODE, view);
//(String)
  +                                                                                      
   // null);
                   }
                   else
                   {
  @@ -388,7 +395,8 @@
               {
                   if (view == null || view.equals(this.getDefaultHelpPage()))
                   {
  -                    response.setRenderParameter(FrameworkConstants.VIEW_HELP_MODE, view);
//(String) null);
  +                    response.setRenderParameter(FrameworkConstants.VIEW_HELP_MODE, view);
//(String)
  +                                                                                      
   // null);
                   }
                   else
                   {
  @@ -402,7 +410,7 @@
       {
   
           // try to get the bean from the session first
  -        Object bean = getBeanFromSession(request, mb); 
  +        Object bean = getBeanFromSession(request, mb);
           if (bean == null)
           {
               bean = model.createBean(mb);
  @@ -472,14 +480,14 @@
        * 
        * @param methodName
        */
  -    protected String invokeVelocityPortletAction(String methodName, ActionRequest request,
ActionResponse response)
  -            throws PortletException
  +    protected String invokeVelocityPortletAction(String methodName, ActionRequest request,
ActionResponse response,
  +            Object bean) throws PortletException
       {
           try
           {
               Method method = this.getClass().getMethod(methodName, VELOCITY_PORTLET_ACTION_SIGNATURE);
               Object[] parameters =
  -            { request, response};
  +            { request, response, bean};
               String result = (String) method.invoke(this, parameters);
               return result;
           }
  @@ -523,9 +531,10 @@
               break;
           }
           putRequestVariable(request, FrameworkConstants.FORWARD_TOOL, new Forwarder(model,
request, response));
  -        Map errors = (Map)request.getPortletSession().getAttribute(SESSION_ERROR_MESSAGES,
PortletSession.PORTLET_SCOPE);
  +        Map errors = (Map) request.getPortletSession().getAttribute(SESSION_ERROR_MESSAGES,
  +                PortletSession.PORTLET_SCOPE);
           if (errors != null)
  -        {            
  +        {
               putRequestVariable(request, "ERRORS", errors);
           }
           request.setAttribute(FrameworkConstants.MODEL_TOOL, model);
  @@ -538,8 +547,13 @@
       private void beanToContext(RenderRequest request, String view, ModelBean mb)
       {
           Object bean;
  +
  +        String key = null;
  +        if (mb.getLookupKey() != null)
  +        {
  +            key = (String) request.getAttribute(mb.getLookupKey());
  +        }
           
  -        String key = (String)request.getAttribute(mb.getLookupKey());
           if (key != null)
           {
               bean = model.lookupBean(mb, key);
  @@ -569,7 +583,6 @@
           putRequestVariable(request, FrameworkConstants.PREFS_VARIABLE, bean);
       }
   
  -    
       private Object getBeanFromSession(PortletRequest request, ModelBean mb)
       {
           return request.getPortletSession().getAttribute(makeModelBeanKey(mb));
  @@ -582,12 +595,12 @@
               request.getPortletSession().setAttribute(makeModelBeanKey(mb), bean);
           }
       }
  -    
  +
       private String makeModelBeanKey(ModelBean mb)
       {
           return "ModelBean:" + mb.getBeanName();
       }
  -    
  +
       /**
        * Specific for Velocity
        * 
  
  
  

---------------------------------------------------------------------
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