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

Gavin King gavin.king at jboss.com
Sun Dec 17 11:04:09 EST 2006


  User: gavin   
  Date: 06/12/17 11:04:09

  Modified:    src/main/org/jboss/seam/core   Page.java Pages.java
  Log:
  any-outcome
  
  Revision  Changes    Path
  1.11      +15 -5     jboss-seam/src/main/org/jboss/seam/core/Page.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Page.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Page.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- Page.java	17 Dec 2006 15:03:29 -0000	1.10
  +++ Page.java	17 Dec 2006 16:04:09 -0000	1.11
  @@ -99,20 +99,21 @@
      {
         private ValueBinding<Object> outcomeValueBinding;
         private Map<String, Case> cases = new HashMap<String, Case>();
  -      private Case defaultCase;
  +      private Case nullCase;
  +      private Case anyCase;
         
         public Map<String, Case> getCases()
         {
            return cases;
         }
         
  -      void setDefaultCase(Case defaultCase)
  +      void setNullCase(Case defaultCase)
         {
  -         this.defaultCase = defaultCase;
  +         this.nullCase = defaultCase;
         }
  -      public Case getDefaultCase()
  +      public Case getNullCase()
         {
  -         return defaultCase;
  +         return nullCase;
         }
         
         void setOutcomeValueBinding(ValueBinding<Object> outcomeValueBinding)
  @@ -123,6 +124,15 @@
         {
            return outcomeValueBinding;
         }
  +
  +      public Case getAnyCase()
  +      {
  +         return anyCase;
  +      }
  +      void setAnyCase(Case elseCase)
  +      {
  +         this.anyCase = elseCase;
  +      }
      }
      
      public static final class Case
  
  
  
  1.65      +32 -8     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.64
  retrieving revision 1.65
  diff -u -b -r1.64 -r1.65
  --- Pages.java	17 Dec 2006 14:09:18 -0000	1.64
  +++ Pages.java	17 Dec 2006 16:04:09 -0000	1.65
  @@ -142,6 +142,11 @@
   
      private Page parsePage(Element element, String viewId)
      {
  +      if (viewId==null)
  +      {
  +         throw new IllegalStateException("Must specify view-id for <page/> declaration");
  +      }
  +      
         if ( viewId.endsWith("*") )
         {
            wildcardViewIds.add(viewId);
  @@ -221,18 +226,28 @@
         String outcomeExpression = element.attributeValue("outcome");
         if (outcomeExpression!=null)
         {
  -         navigation.setOutcomeValueBinding(Expressions.instance().createValueBinding(outcomeExpression));
  +         navigation.setOutcomeValueBinding( Expressions.instance().createValueBinding(outcomeExpression) );
         }
         List<Element> cases = element.elements("outcome");
         for (Element childElement: cases)
         {
            Page.Case caze = parseCase(childElement);
  -         navigation.getCases().put( childElement.attributeValue("value"), caze );
  +         String value = childElement.attributeValue("value");
  +         if (value==null)
  +         {
  +            throw new IllegalStateException("Must specify value for <outcome/> declaration");
  +         }
  +         navigation.getCases().put(value, caze);
         }
  -      Element childElement = element.element("null-outcome");
  +      Element childElement = element.element("any-outcome");
         if (childElement!=null)
         {
  -         navigation.setDefaultCase(parseCase(childElement));
  +         navigation.setAnyCase( parseCase(childElement) );
  +      }
  +      childElement = element.element("null-outcome");
  +      if (childElement!=null)
  +      {
  +         navigation.setNullCase( parseCase(childElement) );
         }
         
         String expression = element.attributeValue("action");
  @@ -340,10 +355,19 @@
                     outcome = value==null ? null : value.toString();
                  }
                  
  -               Page.Case caze = outcome==null ?
  -                  //JSF navhandler says ignore all rules when null outcome
  -                  navigation.getDefaultCase() :
  -                  navigation.getCases().get(outcome);
  +               Page.Case caze;
  +               if (outcome==null) 
  +               {
  +                  //JSF navhandler says ignore all rules when null outcome.
  +                  //so we have a special case for that
  +                  caze = navigation.getNullCase();
  +               }
  +               else
  +               {
  +                  caze = navigation.getCases().get(outcome);
  +                  if (caze==null) caze = navigation.getAnyCase();
  +               }
  +               
                  if (caze!=null)
                  {
                     //TODO: begin/end conversation, etc!!
  
  
  



More information about the jboss-cvs-commits mailing list