[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...

Gavin King gavin.king at jboss.com
Tue Oct 31 15:09:21 EST 2006


  User: gavin   
  Date: 06/10/31 15:09:21

  Modified:    src/main/org/jboss/seam/core       Conversation.java
                        ConversationEntry.java Manager.java Pages.java
                        ResourceBundle.java Switcher.java
  Log:
  introduced <page switch=disabled/>
  breaking changes to how conversation switching works
  fix a bug where destroy methods caused an exception in ManagedEntityIdentityInterceptor
  
  Revision  Changes    Path
  1.24      +28 -14    jboss-seam/src/main/org/jboss/seam/core/Conversation.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Conversation.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Conversation.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -b -r1.23 -r1.24
  --- Conversation.java	13 Oct 2006 05:30:26 -0000	1.23
  +++ Conversation.java	31 Oct 2006 20:09:21 -0000	1.24
  @@ -109,12 +109,18 @@
            {
               throw new IllegalStateException("only long-running conversation outcomes are switchable");
            }
  -         if (description!=null)
  -            manager.getCurrentConversationEntry().setDescription(description);
            if (viewId!=null)
  +         {
               manager.getCurrentConversationEntry().setViewId(viewId);
  +         }
  +         if (description!=null)
  +         {
  +            manager.getCurrentConversationEntry().setDescription(description);
  +         }
            if (timeout!=null)
  +         {
               manager.getCurrentConversationEntry().setTimeout(timeout);
  +         }
            description = null;
            viewId = null;
         }
  @@ -123,32 +129,36 @@
      /**
       * Switch back to the last defined view-id for the
       * current conversation.
  +    * 
  +    * @return true if a redirect occurred
       */
  -   public String redirect()
  +   public boolean redirect()
      {
         Manager manager = Manager.instance();
         String viewId = manager.getCurrentConversationViewId();
         return redirect(manager, viewId);
      }
   
  -   private String redirect(Manager manager, String viewId)
  +   private boolean redirect(Manager manager, String viewId)
      {
  -      if (viewId!=null)
  +      if (viewId==null)
         {
  -         manager.redirect( viewId );
  -         return "org.jboss.seam.switch";
  +         return false;
         }
         else
         {
  -         return null;
  +         manager.redirect(viewId);
  +         return true;
         }
      }
      
      /**
       * End a child conversation and redirect to the last defined
       * view-id for the parent conversation.
  +    * 
  +    * @return true if a redirect occurred
       */
  -   public String endAndRedirect()
  +   public boolean endAndRedirect()
      {
         end();
         Manager manager = Manager.instance();
  @@ -250,15 +260,17 @@
         String parentId = getParentId();
         if (parentId!=null)
         {
  -         Manager.instance().swapConversation(parentId);
  +         Manager.instance().switchConversation(parentId);
         }
      }
      
      /**
       * Pop the conversation stack and redirect to the last defined
       * view-id for the parent conversation.
  +    * 
  +    * @return true if a redirect occurred
       */
  -   public String redirectToParent()
  +   public boolean redirectToParent()
      {
         pop();
         return redirect();
  @@ -272,15 +284,17 @@
         String rootId = getRootId();
         if (rootId!=null)
         {
  -         Manager.instance().swapConversation(rootId);
  +         Manager.instance().switchConversation(rootId);
         }
      }
   
      /**
       * Switch to the root conversation and redirect to the 
       * last defined view-id for the root conversation.
  +    * 
  +    * @return true if a redirect occurred
       */
  -   public String redirectToRoot()
  +   public boolean redirectToRoot()
      {
         root();
         return redirect();
  
  
  
  1.25      +19 -6     jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConversationEntry.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- ConversationEntry.java	25 Oct 2006 15:14:35 -0000	1.24
  +++ ConversationEntry.java	31 Oct 2006 20:09:21 -0000	1.25
  @@ -77,21 +77,34 @@
      }
   
      public String destroy() {
  -      boolean success = Manager.instance().swapConversation( getId() );
  +      boolean success = Manager.instance().switchConversation( getId() );
         if (success) Manager.instance().endConversation(false);
         return null;
      }
   
  -   public String select() {
  -      boolean success = Manager.instance().swapConversation( getId() );
  +   public void select() {
  +      switchConversation();
  +   }
  +   
  +   public boolean switchConversation()
  +   {
  +      boolean success = Manager.instance().switchConversation( getId() );
         if (success)
         {
  -         Manager.instance().redirect( getViewId() );
  -         return "org.jboss.seam.switch";
  +         String viewId = getViewId();
  +         if (viewId!=null)
  +         {
  +            Manager.instance().redirect(viewId);
  +            return true;
         }
         else
         {
  -         return null;
  +            return false;
  +         }
  +      }
  +      else
  +      {
  +         return false;
         }
      }
   
  
  
  
  1.106     +20 -13    jboss-seam/src/main/org/jboss/seam/core/Manager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Manager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -b -r1.105 -r1.106
  --- Manager.java	27 Oct 2006 12:58:09 -0000	1.105
  +++ Manager.java	31 Oct 2006 20:09:21 -0000	1.106
  @@ -35,7 +35,6 @@
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.contexts.ServerConversationContext;
  -import org.jboss.seam.pageflow.Page;
   import org.jboss.seam.util.Id;
   
   /**
  @@ -43,7 +42,7 @@
    *
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.105 $
  + * @version $Revision: 1.106 $
    */
   @Scope(ScopeType.EVENT)
   @Name("org.jboss.seam.core.manager")
  @@ -689,7 +688,7 @@
       * @param id the id of the conversation to switch to
       * @return true if the conversation exists
       */
  -   public boolean swapConversation(String id)
  +   public boolean switchConversation(String id)
      {
         ConversationEntry ce = ConversationEntries.instance().getConversationEntry(id);
         if (ce!=null)
  @@ -889,6 +888,7 @@
      /**
       * If a page description is defined, remember the description and
       * view id for the current page, to support conversation switching.
  +    * Called just before the render phase.
       */
      public void prepareBackswitch(PhaseEvent event) {
         if ( isLongRunningConversation() )
  @@ -900,32 +900,39 @@
            Conversation conversation = Conversation.instance();
   
            //stuff from jPDL takes precedence
  -         Page page = Init.instance().isJbpmInstalled() && Pageflow.instance().isInProcess() ?
  +         org.jboss.seam.pageflow.Page pageflowPage = Init.instance().isJbpmInstalled() && Pageflow.instance().isInProcess() ?
                  Pageflow.instance().getPage() : null;
  -         if (page==null)
  +         if (pageflowPage==null)
            {
               //handle stuff defined in pages.xml
               String viewId = event.getFacesContext().getViewRoot().getViewId();
               Pages pages = Pages.instance();
               if (pages!=null) //for tests
               {
  -               if ( pages.hasDescription(viewId) )
  +               org.jboss.seam.core.Page pageEntry = pages.getPage(viewId);
  +               if ( pageEntry.isSwitchEnabled() )
                  {
  -                  conversation.setDescription( pages.getDescription(viewId) );
                     conversation.setViewId(viewId);
                  }
  -               conversation.setTimeout( pages.getTimeout(viewId) );
  +               if ( pageEntry.hasDescription() )
  +               {
  +                  conversation.setDescription( pageEntry.renderDescription() );
  +               }
  +               conversation.setTimeout( pageEntry.getTimeout() );
               }
            }
            else
            {
               //use stuff from the pageflow definition
  -            if ( page.hasDescription() )
  +            if ( pageflowPage.isSwitchEnabled() )
  +            {
  +               conversation.setViewId( pageflowPage.getViewId() );
  +            }
  +            if ( pageflowPage.hasDescription() )
               {
  -               conversation.setDescription( page.getDescription() );
  -               conversation.setViewId( page.getViewId() );
  +               conversation.setDescription( pageflowPage.getDescription() );
               }
  -            conversation.setTimeout( page.getTimeout() );
  +            conversation.setTimeout( pageflowPage.getTimeout() );
            }
   
         }
  @@ -967,7 +974,7 @@
            Pages pages = Pages.instance();
            if (pages!=null) //for tests
            {
  -            noConversationViewId = pages.getNoConversationViewId(viewId);
  +            noConversationViewId = pages.getPage(viewId).getNoConversationViewId();
            }
         }
         else
  
  
  
  1.41      +18 -128   jboss-seam/src/main/org/jboss/seam/core/Pages.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Pages.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pages.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -b -r1.40 -r1.41
  --- Pages.java	31 Oct 2006 06:40:24 -0000	1.40
  +++ Pages.java	31 Oct 2006 20:09:21 -0000	1.41
  @@ -3,13 +3,11 @@
   import static org.jboss.seam.InterceptionType.NEVER;
   
   import java.io.InputStream;
  -import java.util.ArrayList;
   import java.util.Collections;
   import java.util.Comparator;
   import java.util.HashMap;
   import java.util.List;
   import java.util.Map;
  -import java.util.MissingResourceException;
   import java.util.Set;
   import java.util.SortedSet;
   import java.util.TreeSet;
  @@ -32,7 +30,6 @@
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.core.Expressions.MethodBinding;
  -import org.jboss.seam.core.Expressions.ValueBinding;
   import org.jboss.seam.util.Parameters;
   import org.jboss.seam.util.Resources;
   
  @@ -55,89 +52,6 @@
      private Map<String, Page> pagesByViewId = new HashMap<String, Page>();   
      private String noConversationViewId;
      
  -   static final class Page
  -   {
  -      Page(String viewId)
  -      {
  -         this.viewId = viewId;
  -         if (viewId!=null)
  -         {
  -            int loc = viewId.lastIndexOf('.');
  -            if ( loc>0 && viewId.startsWith("/") )
  -            {
  -               this.resourceBundleName = viewId.substring(1, loc);
  -            }
  -         }
  -      }
  -      
  -      final String viewId;
  -      String description;
  -      Integer timeout;
  -      MethodBinding action;
  -      String outcome;
  -      String noConversationViewId;
  -      String resourceBundleName;
  -      List<PageParameter> pageParameters = new ArrayList<PageParameter>();
  -      
  -      java.util.ResourceBundle getResourceBundle()
  -      {
  -         try
  -         {
  -            return java.util.ResourceBundle.getBundle(
  -                  resourceBundleName, 
  -                  Locale.instance(), 
  -                  Thread.currentThread().getContextClassLoader()
  -               );
  -         }
  -         catch (MissingResourceException mre)
  -         {
  -            return null;
  -         }
  -      }
  -      
  -      @Override
  -      public String toString()
  -      {
  -         return "Page(" + viewId + ")";
  -      }
  -   }
  -   
  -   static final class PageParameter
  -   {
  -      PageParameter(String name)
  -      {
  -         this.name = name;
  -      }
  -      
  -      final String name;
  -      ValueBinding valueBinding;
  -      ValueBinding converterValueBinding;
  -      String converterId;
  -      
  -      Converter getConverter()
  -      {
  -         if (converterId!=null)
  -         {
  -            return FacesContext.getCurrentInstance().getApplication().createConverter(converterId);
  -         }
  -         else if (converterValueBinding!=null)
  -         {
  -            return (Converter) converterValueBinding.getValue();
  -         }
  -         else
  -         {
  -            Class<?> type = valueBinding.getType();
  -            return FacesContext.getCurrentInstance().getApplication().createConverter(type);           
  -         }
  -      }
  -
  -      @Override
  -      public String toString()
  -      {
  -         return "PageParameter(" + name + ")";
  -      }
  -   }
  -   
      private SortedSet<String> wildcardViewIds = new TreeSet<String>( 
            new Comparator<String>() {
               public int compare(String x, String y)
  @@ -180,20 +94,22 @@
               Page entry = new Page(viewId);
               pagesByViewId.put(viewId, entry);
               
  +            entry.setSwitchEnabled(!"disabled".equals( page.attributeValue("switch") ));
  +            
               String description = page.getTextTrim();
               if (description!=null && description.length()>0)
               {
  -               entry.description = description;
  +               entry.setDescription(description);
               }
               
               String timeoutString = page.attributeValue("timeout");
               if (timeoutString!=null)
               {
  -               entry.timeout = Integer.parseInt(timeoutString);
  +               entry.setTimeout(Integer.parseInt(timeoutString));
               }
               
               String noConversationViewId = page.attributeValue("no-conversation-view-id");
  -            entry.noConversationViewId = noConversationViewId;
  +            entry.setNoConversationViewId(noConversationViewId);
               
               String action = page.attributeValue("action");
               if (action!=null)
  @@ -201,18 +117,18 @@
                  if ( action.startsWith("#{") )
                  {
                     MethodBinding methodBinding = Expressions.instance().createMethodBinding(action);
  -                  entry.action = methodBinding;
  +                  entry.setAction(methodBinding);
                  }
                  else
                  {
  -                  entry.outcome = action;
  +                  entry.setOutcome(action);
                  }
               }
               
               String bundle = page.attributeValue("bundle");
               if (bundle!=null)
               {
  -               entry.resourceBundleName = bundle;
  +               entry.setResourceBundleName(bundle);
               }
               
               List<Element> children = page.elements("param");
  @@ -228,21 +144,21 @@
                  {
                     name = valueExpression.substring(2, valueExpression.length()-1);
                  }
  -               PageParameter pageParameter = new PageParameter( name );
  -               pageParameter.valueBinding = Expressions.instance().createValueBinding( valueExpression );
  +               Page.PageParameter pageParameter = new Page.PageParameter(name);
  +               pageParameter.valueBinding = Expressions.instance().createValueBinding(valueExpression);
                  pageParameter.converterId = param.attributeValue("converterId");
                  String converterExpression = param.attributeValue("converter");
                  if (converterExpression!=null)
                  {
  -                  pageParameter.converterValueBinding = Expressions.instance().createValueBinding( converterExpression );
  +                  pageParameter.converterValueBinding = Expressions.instance().createValueBinding(converterExpression);
                  }
  -               entry.pageParameters.add(pageParameter);
  +               entry.getPageParameters().add(pageParameter);
               }
            }
         }
      }
      
  -   private Page getPage(String viewId)
  +   public Page getPage(String viewId)
      {
         Page result = null;
         if (viewId!=null)
  @@ -263,21 +179,6 @@
         return loc<0 ? null : viewId.substring(0, loc) + getSuffix();
      }
      
  -   public boolean hasDescription(String viewId)
  -   {
  -      return getPage(viewId).description!=null;
  -   }
  -   
  -   public String getDescription(String viewId)
  -   {
  -      return Interpolator.instance().interpolate( getPage(viewId).description );
  -   }
  -
  -   public Integer getTimeout(String viewId)
  -   {
  -      return getPage(viewId).timeout;
  -   }
  -   
      public boolean callAction()
      {
         boolean result = false;
  @@ -301,12 +202,12 @@
      {
         boolean result = false;
         
  -      String outcome = getPage(viewId).outcome;
  +      String outcome = getPage(viewId).getOutcome();
         String fromAction = outcome;
         
         if (outcome==null)
         {
  -         MethodBinding methodBinding = getPage(viewId).action;
  +         MethodBinding methodBinding = getPage(viewId).getAction();
            if (methodBinding!=null) 
            {
               fromAction = methodBinding.getExpressionString();
  @@ -335,11 +236,6 @@
         }
      }
      
  -   public java.util.ResourceBundle getResourceBundle(String viewId)
  -   {
  -      return getPage(viewId).getResourceBundle();
  -   }
  -   
      public static Pages instance()
      {
         if ( !Contexts.isApplicationContextActive() )
  @@ -381,12 +277,6 @@
         return result;
      }
      
  -   public String getNoConversationViewId(String viewId)
  -   {
  -      String result = getPage(viewId).noConversationViewId;
  -      return result==null ? noConversationViewId : result;
  -   }
  -   
      public Map<String, Object> getParameters(String viewId)
      {
         return getParameters(viewId, Collections.EMPTY_SET);
  @@ -395,7 +285,7 @@
      public Map<String, Object> getParameters(String viewId, Set<String> overridden)
      {
         Map<String, Object> parameters = new HashMap<String, Object>();
  -      for ( PageParameter pageParameter: getPage(viewId).pageParameters )
  +      for ( Page.PageParameter pageParameter: getPage(viewId).getPageParameters() )
         {
            if ( !overridden.contains(pageParameter.name) )
            {
  @@ -413,7 +303,7 @@
      {
         String viewId = facesContext.getViewRoot().getViewId();
         Map<String, String[]> requestParameters = Parameters.getRequestParameters();
  -      for ( PageParameter pageParameter: getPage(viewId).pageParameters )
  +      for ( Page.PageParameter pageParameter: getPage(viewId).getPageParameters() )
         {         
            String[] parameterValues = requestParameters.get(pageParameter.name);
            if (parameterValues==null || parameterValues.length==0)
  @@ -448,7 +338,7 @@
      {
         String viewId = facesContext.getViewRoot().getViewId();
         
  -      for (PageParameter pageParameter: getPage(viewId).pageParameters)
  +      for (Page.PageParameter pageParameter: getPage(viewId).getPageParameters())
         {         
            Object object = Contexts.getPageContext().get(pageParameter.name);
            if (object!=null)
  
  
  
  1.18      +1 -1      jboss-seam/src/main/org/jboss/seam/core/ResourceBundle.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ResourceBundle.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ResourceBundle.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- ResourceBundle.java	31 Oct 2006 04:38:37 -0000	1.17
  +++ ResourceBundle.java	31 Oct 2006 20:09:21 -0000	1.18
  @@ -161,7 +161,7 @@
                     String viewId = viewRoot.getViewId();
                     if (viewId!=null)
                     {
  -                     return Pages.instance().getResourceBundle(viewId);
  +                     return Pages.instance().getPage(viewId).getResourceBundle();
                     }
                  }
               }
  
  
  
  1.12      +9 -8      jboss-seam/src/main/org/jboss/seam/core/Switcher.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Switcher.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Switcher.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- Switcher.java	25 Oct 2006 15:14:35 -0000	1.11
  +++ Switcher.java	31 Oct 2006 20:09:21 -0000	1.12
  @@ -23,7 +23,7 @@
    * Support for the conversation switcher drop-down menu.
    * 
    * @author Gavin King
  - * @version $Revision: 1.11 $
  + * @version $Revision: 1.12 $
    */
   @Scope(ScopeType.PAGE)
   @Name("switcher")
  @@ -92,17 +92,18 @@
         }
         else
         {
  -         boolean success = manager.swapConversation(conversationIdOrOutcome);
  +         boolean success = manager.switchConversation(conversationIdOrOutcome);
            if (success)
            {
               resultingConversationIdOrOutcome = manager.getCurrentConversationId();
  -            Manager.instance().redirect( manager.getCurrentConversationViewId() );
  -            actualOutcome = "org.jboss.seam.switch";
  -         }
  -         else
  +            
  +            String viewId = manager.getCurrentConversationViewId();
  +            if (viewId!=null)
            {
  -            actualOutcome = null;
  +               Manager.instance().redirect(viewId);
  +            }
            }
  +         actualOutcome = null;
         }
         Lifecycle.resumeConversation( FacesContext.getCurrentInstance().getExternalContext() ); //TODO: remove, unnecessary
         return actualOutcome;
  
  
  



More information about the jboss-cvs-commits mailing list