Hi Hermod,

I took a look on the url you provided and on the wiki I also read that the
'required' validator is a special case. The JSF framework will only call a
Validator if a value was submitted. Usually, you would set required="true"
as an attribute on the input component.  If I set requied=true on the input
component then JSF built in validation kicks in and Shale "required"
validator is never processed.

Is there a way to display JSF required validator?  or Is there a way to pass
an argument to JSF required validator message?

sanjay

On 3/19/07, Hermod Opstvedt <[EMAIL PROTECTED]> wrote:

Hei

Take a look at [1]. Notice the usage of the arg parameter.


[1] http://shale.apache.org/shale-validator/index.html

Hermod

-----Opprinnelig melding-----
Fra: Sanjay Choudhary [mailto:[EMAIL PROTECTED]
Sendt: 19. mars 2007 21:14
Til: [email protected]
Emne: Re: validation required

Hermod and Gary,

             <h:panelGrid columns="3" cellpadding="0" cellspacing="0">
                    <h:outputLabel for="firstName">
                        <h:outputText value="*"
styleClass="required"></h:outputText>
                        <h:outputText value="First name" />
                    </h:outputLabel>
                    <h:inputText styleClass="inputText"
                        value="#{bp.firstName}" id="firstName" size="30"
maxlength="30" required="true">
                        <val:commonsValidator type="required" arg="First
name"
                            server="true" client="true"
message="#{bu['myerror']}"/> ----------------> tried as per Gary's
suggestion, nothing appeared
                    </h:inputText>
                    <h:message for="firstName"
styleClass="message"></h:message>
                </h:panelGrid>


I read Gary's email and tried his thoughts. When I tried this without
required="true" no message appeared and with required="true" it showed the
default message {0} is required.

Sanjay.

On 3/19/07, Gary VanMatre <[EMAIL PROTECTED]> wrote:
>
> >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