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

Gavin King gavin.king at jboss.com
Tue Jun 12 13:30:11 EDT 2007


  User: gavin   
  Date: 07/06/12 13:30:11

  Modified:    src/main/org/jboss/seam/pages  Param.java
  Log:
  Application.getResourceBundle() does not seem to work...
  
  Revision  Changes    Path
  1.4       +31 -8     jboss-seam/src/main/org/jboss/seam/pages/Param.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Param.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/pages/Param.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Param.java	12 Jun 2007 07:09:15 -0000	1.3
  +++ Param.java	12 Jun 2007 17:30:11 -0000	1.4
  @@ -147,27 +147,33 @@
               throws ValidatorException
      {
         String[] parameterValues = requestParameters.get( getName() );
  +
         if (parameterValues==null || parameterValues.length==0)
         {
            if ( isRequired() )
            {
  -            String bundleName = facesContext.getApplication().getMessageBundle();
  -            if (bundleName==null) bundleName = FacesMessage.FACES_MESSAGES;
  -            ResourceBundle resourceBundle = facesContext.getApplication().getResourceBundle(facesContext, bundleName);
  -            throw new ValidatorException( new FacesMessage(
  -                     FacesMessage.SEVERITY_ERROR, 
  -                     resourceBundle.getString("javax.faces.component.UIInput.REQUIRED"), 
  -                     resourceBundle.getString("javax.faces.component.UIInput.REQUIRED_detail")
  -                  ) );
  +            addRequiredMessage(facesContext);
            }
            return null;
         }
  +
         if (parameterValues.length>1)
         {
            throw new IllegalArgumentException("page parameter may not be multi-valued: " + getName());
         }         
  +
         String stringValue = parameterValues[0];
      
  +      //Note: for not-required fields, we behave a
  +      //but different than JSF for empty strings.
  +      //is this a bad thing? (but we are the same
  +      //for required fields)
  +      if ( stringValue.length()==0 && isRequired() )
  +      {
  +         addRequiredMessage(facesContext);
  +         return null;
  +      }
  +   
         Converter converter = null;
         try
         {
  @@ -192,6 +198,23 @@
         return value;
      }
   
  +   private void addRequiredMessage(FacesContext facesContext)
  +   {
  +      String bundleName = facesContext.getApplication().getMessageBundle();
  +      if (bundleName==null) bundleName = FacesMessage.FACES_MESSAGES;
  +      ResourceBundle resourceBundle = facesContext.getApplication().getResourceBundle(facesContext, bundleName);
  +      //TODO: this should not be necessary!
  +      if (resourceBundle==null)
  +      {
  +         resourceBundle = org.jboss.seam.core.ResourceBundle.instance();
  +      }
  +      throw new ValidatorException( new FacesMessage(
  +               FacesMessage.SEVERITY_ERROR, 
  +               resourceBundle.getString("javax.faces.component.UIInput.REQUIRED"), 
  +               resourceBundle.getString("javax.faces.component.UIInput.REQUIRED_detail")
  +            ) );
  +   }
  +
      public String getValidatorId()
      {
         return validatorId;
  
  
  



More information about the jboss-cvs-commits mailing list