>From: "Sanjay Choudhary" <[EMAIL PROTECTED]> 
>
> I am not sure what I am missing here... snippet from my JSP is 
> 
 ><h:inputText styleClass="inputText"
>                        value="#{bp.firstName}" id="firstName"
>                        required="true" size="30">
>                        <val:commonsValidator type="required" arg="First name"
>                            server="true" client="true" 
> message="errors.required"/>
>                        </val:commonsValidator>
>                    </h:inputText>
>
> 
> 
> 
> 
> 
> in my message bundle file I have overridden 
> javax.faces.component.UIInput.REQUIRED={0} is required. (I read on wiki 
> that message = errors.required will be ignored). Funny thing is that JSF is 
> not passing argument for {0}. On my client , I am seeing message {0} is 
> required instead of "First name is required". What am I missing here? 
>


When you use the message attribute to override the validation message, it must 
be 
the expanded message.  It can not be the message key.  This means that you will 
need to load the resource bundle within the JSP to override the validator 
message, 
"#{messages['somekey']}".
 
 
The shale validator will look in three locations for the error message.
 
1) Default messages are defined with the validaion rule [1].  The message keys 
point 
to a packaged resource bundles in 4 locales [2].
  
2) You can override the message by using the same message key and a different 
resource bundle.  This resource bundle needs to be registered in the 
faces-conif.xml using the "message-bundle" [3].  This is a global override for 
all 
uses of the commonsValidator within your application.
 
3) You can override the message for each situation using the "message" 
attribute. 
This expects the message as it might appear in the resource bundle.  
 
 
The "getErrorMessages" method in the commonsValidator resolves these rules [4].
 
 
[1] 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-validator/src/main/resources/org/apache/shale/validator/validator-rules.xml?view=markup
[2] 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-validator/src/main/resources/org/apache/shale/validator/messages.properties?view=markup
[3] 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-usecases/src/main/webapp/WEB-INF/faces-config.xml?view=markup
[4] 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-validator/src/main/java/org/apache/shale/validator/CommonsValidator.java?view=markup

 
> thanks, 
> Sanjay 


Gary

Reply via email to