myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Korherr <jakob.korh...@gmail.com>
Subject Re: AW: AW: Any way to customize this validate number message?
Date Wed, 02 Dec 2009 19:10:21 GMT
Hi,

You can obtain the label from a managed bean (e.g. #{bean.label}) and check
FacesContext.getCurrentInstance().getRenderResponse().

If true, it is the value for the label.
If false, it is the value for the FacesMessage.

I hope this works in your version. I only did a short (and a bit different)
test in myfaces 1.2, but that worked well.

Regards

Jakob Korherr

2009/12/2 laredotornado <laredotornado@gmail.com>

>
> Ah, I see.  In that case I have one last question.  I want the validation
> error message to contain a slightly different value than what the label
> contains in its "value" field.  As such, is a custom phase listener my only
> option?
>
> Thanks, -
>
>
>
> Rene Guenther wrote:
> >
> > Hi Dave,
> >
> > I just looked it up, it is
> > <h:outputLabel ...>
> >
> > Eg.:
> >
> > <h:outputLabel for="status" value="#{text['entity.gos.status']}"/>
> > <t:inputText forceId="true" value="#{documentData.documentStatus}"
> > id="status"
> >                                    required="true"/>
> >
> >
> > That way the ... is required message included the value of the label for
> > us.
> >
> > Cheers
> > Rene
> >
> >
> > -----Urspr√ľngliche Nachricht-----
> > Von: laredotornado [mailto:laredotornado@gmail.com]
> > Gesendet: Mittwoch, 2. Dezember 2009 19:10
> > An: users@myfaces.apache.org
> > Betreff: Re: AW: Any way to customize this validate number message?
> >
> >
> > Hi Rene,
> >
> > I changed the input ... is this what you meant because I still get the
> > same
> > error ...
> >
> >                 <label id="Dome Tour, Number of Adults"
> > for="domeTourNumber_of_Adults">
> >                   *
> >                   <strong>Number of Adults:</strong>
> >                 </label>
> >                 <t:inputText forceId="true" id="domeTourNumber_of_Adults"
> > value="#{domeTour.numAdults}"
> >                                             required="false"
> >                                             size="60"
> >                                             maxlength="60"
> >                                             styleClass="textFields
> > numAdultsField">
> >                 <f:validator validatorId="TourRequiredIfCheckedValidator"
> > />
> >                       <f:validator validatorId="TourTotalPeopleValidator"
> />
> >                       <f:validator
> validatorId="TourAdultChildRatioValidator" />
> >                </t:inputText>
> >
> > The error that appears is
> >
> > domeTourNumber_of_Adults: 'bbb' must be a number between -2147483648 and
> > 2147483647 Example: 9346
> >
> > Any ideas what I might be doing wrong?  Thanks, - Dave
> >
> >
> >
> > Rene Guenther wrote:
> >>
> >> Hi Dave,
> >>
> >> If I remember correctly, if you use a label and use t:inputText instead
> >> of
> >> h:inputText together with forceId="true" in the message
> >> tourType:domeTourNumber_of_Adults: will be replaced with the name of the
> >> label.
> >>
> >> There is also a key relating to MyFaces applicationResources.properties
> >> file
> >> which contains the message. If you find the key you could use that key
> >> along
> >> with your customized message into your applicationResources file which
> >> takes
> >> precedence over MyFaces one. You might find the message key eg. by
> >> looking
> >> up the file in the MyFaces sources.
> >>
> >> If you need different parameters than the default one you'd probably
> have
> >> to
> >> write your own validator.
> >>
> >> Cheers
> >> Rene
> >>
> >> -----Urspr√ľngliche Nachricht-----
> >> Von: laredotornado [mailto:laredotornado@gmail.com]
> >> Gesendet: Mittwoch, 2. Dezember 2009 18:10
> >> An: users@myfaces.apache.org
> >> Betreff: Any way to customize this validate number message?
> >>
> >>
> >> Hi,
> >>
> >> I'm using MyFaces 1.1.6.  I have this ...
> >>
> >>                 <h:inputText id="domeTourNumber_of_Adults"
> >> value="#{domeTour.numAdults}"
> >>                                             required="false"
> >>                                             size="60"
> >>                                             maxlength="60"
> >>                                             styleClass="textFields
> >> numAdultsField">
> >>                 <f:validator
> validatorId="TourRequiredIfCheckedValidator"
> >> />
> >>
> >>                      <f:validator validatorId="TourTotalPeopleValidator"
> />
> >>                      <f:validator
> validatorId="TourAdultChildRatioValidator"
> >> />
> >>                </h:inputText>
> >>
> >> in which the bean's set and get type is an int.  So if I enter a value
> >> like
> >> "aaa" into the field, I get a message like
> >>
> >> tourType:domeTourNumber_of_Adults: 'aaa' must be a number between
> >> -2147483648 and 2147483647 Example: 9346
> >>
> >> I would like to customize this message.  Anyone know how I can do that?
> >> Thanks, - Dave
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/Any-way-to-customize-this-validate-number-message--tp2
> >> 6612567p26612567.html
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >>
> >
> > --
> > View this message in context:
> >
> http://old.nabble.com/Any-way-to-customize-this-validate-number-message--tp26612567p26613605.html
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Any-way-to-customize-this-validate-number-message--tp26612567p26614138.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message