You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Rudi Steiner <ru...@googlemail.com> on 2007/05/30 09:32:00 UTC

How to force validation

Hi,

I have the problem, that I can't show the messages generated by the
build in validation mechanism of myFaces because in all languages the
name of an inputfield shown in the message is the id of the
inputfield, and this id is not dynamic. So I can't change it for
different languages.

The idea is to write a validationmethod like validateRequired() and
depending on the component for which this method is called, generate
the message on the fly in the right language. The problem is, that a
validationmethod is just called, if there is a input in the filed, so
I have to use the required-attribute. But this is exactly, what I want
to avoid :)

My question: can I force myFaces to call a validationmethod, also if
the inputfield is empty?

Thanks a lot,
Rudi

Re: How to force validation

Posted by "::SammyRulez::" <sa...@gmail.com>.
cool... bookmarked!

2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> Hi Sammy,
>
> I found a solution here:
> http://forum.java.sun.com/thread.jspa?threadID=5115563&messageID=9419018
>
> The solution is
>
> <t:messages showDetail="true" replaceIdWithLabel="true"/>
>
> Thanks,
> Rudi
>
>
> On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > see
> > http://www.laliluna.de/javaserver-faces-message-resource-bundle-tutorial.html
> >
> > for some info about that..
> >
> > any way it seems to me that your problem is only with the
> > requered=true validation.
> >
> > why not set required=false and add this type of validation in your
> > custom - interationalized validator.
> >
> > I don't know if when required=false and content=null validation phase is skipped
> >
> > I hope it helps
> >
> >
> > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > Hi Sammy,
> > >
> > > I can't show the message near the inputfield, so I have to use
> > > <h:messaes/> which shows a list of all messages for the page. Thats
> > > why the name of the field within the message is important.
> > >
> > > I don't understand what you mean by your second proposal. Which class
> > > should I extend and where do I have to register a new messageloader?
> > >
> > > Thanks a lot,
> > > Rudi
> > >
> > > On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > > > I mean
> > > >
> > > > 1) cut DescrD from bundle so that message will be "value required"
> > > > only in appropriate language (the message is near the field so that
> > > > the field name is not really necessary to me)
> > > >
> > > > 2)extend message loader in order to translate upon a key/language
> > > > dictionary a proper name for the fields (more difficult but better)
> > > >
> > > > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > > > Hi Sammy,
> > > > >
> > > > > by modifying the bundle, I can't change the parameter passed to the
> > > > > message. If I for example have a input field like this:
> > > > >
> > > > > <h:input Text id="DescrD" required="true"
> > > > > value="#{PriorityEditBean.priority.prioDescriptionD}"/>
> > > > >
> > > > > So the generated message is something like
> > > > >
> > > > > Validation error "DescrD": value required.
> > > > >
> > > > > The problem is the "DescrD" is shown in all languages in the message,
> > > > > and this I can't change by modifying the bundle :(
> > > > >
> > > > > Do you have another idea?
> > > > >
> > > > > Thank a lot,
> > > > > Rudi
> > > > >
> > > > >
> > > > > On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > > > > > what about customize the bundle of messages?
> > > > > >
> > > > > > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have the problem, that I can't show the messages generated by the
> > > > > > > build in validation mechanism of my Faces because in all languages the
> > > > > > > name of an input field shown in the message is the id of the
> > > > > > > input field, and this id is not dynamic. So I can't change it for
> > > > > > > different languages.
> > > > > > >
> > > > > > > The idea is to write a validation method like validate Required() and
> > > > > > > depending on the component for which this method is called, generate
> > > > > > > the message on the fly in the right language. The problem is, that a
> > > > > > > validation method is just called, if there is a input in the filed, so
> > > > > > > I have to use the required-attribute. But this is exactly, what I want
> > > > > > > to avoid :)
> > > > > > >
> > > > > > > My question: can I force myFaces to call a validation method, also if
> > > > > > > the input field is empty?
> > > > > > >
> > > > > > > Thanks a lot,
> > > > > > > Rudi
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > ::Samples::
> > > > > > http://www.kyub.com/blog/
> > > > > > -----------------------------------------------------------------
> > > > > > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> > > > > >  E per un terzo giustificazione
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > ::Samples::
> > > > http://www.kyub.com/blog/
> > > > -----------------------------------------------------------------
> > > > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> > > >  E per un terzo giustificazione
> > > >
> > >
> >
> >
> > --
> > ::SammyRulez::
> > http://www.kyub.com/blog/
> > -----------------------------------------------------------------
> > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> >  E per un terzo mistificazione
> >
>


-- 
::SammyRulez::
http://www.kyub.com/blog/
-----------------------------------------------------------------
La programmazione è per un terzo interpretazione e per due terzi ispirazione.
 E per un terzo mistificazione

Re: How to force validation

Posted by Rudi Steiner <ru...@googlemail.com>.
Hi Sammy,

I found a solution here:
http://forum.java.sun.com/thread.jspa?threadID=5115563&messageID=9419018

The solution is

<t:messages showDetail="true" replaceIdWithLabel="true"/>

Thanks,
Rudi


On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> see
> http://www.laliluna.de/javaserver-faces-message-resource-bundle-tutorial.html
>
> for some info about that..
>
> any way it seems to me that your problem is only with the
> requered=true validation.
>
> why not set required=false and add this type of validation in your
> custom - interationalized validator.
>
> I don't know if when required=false and content=null validation phase is skipped
>
> I hope it helps
>
>
> 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > Hi Sammy,
> >
> > I can't show the message near the inputfield, so I have to use
> > <h:messaes/> which shows a list of all messages for the page. Thats
> > why the name of the field within the message is important.
> >
> > I don't understand what you mean by your second proposal. Which class
> > should I extend and where do I have to register a new messageloader?
> >
> > Thanks a lot,
> > Rudi
> >
> > On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > > I mean
> > >
> > > 1) cut DescrD from bundle so that message will be "value required"
> > > only in appropriate language (the message is near the field so that
> > > the field name is not really necessary to me)
> > >
> > > 2)extend message loader in order to translate upon a key/language
> > > dictionary a proper name for the fields (more difficult but better)
> > >
> > > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > > Hi Sammy,
> > > >
> > > > by modifying the bundle, I can't change the parameter passed to the
> > > > message. If I for example have a input field like this:
> > > >
> > > > <h:input Text id="DescrD" required="true"
> > > > value="#{PriorityEditBean.priority.prioDescriptionD}"/>
> > > >
> > > > So the generated message is something like
> > > >
> > > > Validation error "DescrD": value required.
> > > >
> > > > The problem is the "DescrD" is shown in all languages in the message,
> > > > and this I can't change by modifying the bundle :(
> > > >
> > > > Do you have another idea?
> > > >
> > > > Thank a lot,
> > > > Rudi
> > > >
> > > >
> > > > On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > > > > what about customize the bundle of messages?
> > > > >
> > > > > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > > > > Hi,
> > > > > >
> > > > > > I have the problem, that I can't show the messages generated by the
> > > > > > build in validation mechanism of my Faces because in all languages the
> > > > > > name of an input field shown in the message is the id of the
> > > > > > input field, and this id is not dynamic. So I can't change it for
> > > > > > different languages.
> > > > > >
> > > > > > The idea is to write a validation method like validate Required() and
> > > > > > depending on the component for which this method is called, generate
> > > > > > the message on the fly in the right language. The problem is, that a
> > > > > > validation method is just called, if there is a input in the filed, so
> > > > > > I have to use the required-attribute. But this is exactly, what I want
> > > > > > to avoid :)
> > > > > >
> > > > > > My question: can I force myFaces to call a validation method, also if
> > > > > > the input field is empty?
> > > > > >
> > > > > > Thanks a lot,
> > > > > > Rudi
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > ::Samples::
> > > > > http://www.kyub.com/blog/
> > > > > -----------------------------------------------------------------
> > > > > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> > > > >  E per un terzo giustificazione
> > > > >
> > > >
> > >
> > >
> > > --
> > > ::Samples::
> > > http://www.kyub.com/blog/
> > > -----------------------------------------------------------------
> > > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> > >  E per un terzo giustificazione
> > >
> >
>
>
> --
> ::SammyRulez::
> http://www.kyub.com/blog/
> -----------------------------------------------------------------
> La programmazione è per un terzo interpretazione e per due terzi ispirazione.
>  E per un terzo mistificazione
>

Re: How to force validation

Posted by "::SammyRulez::" <sa...@gmail.com>.
see
http://www.laliluna.de/javaserver-faces-message-resource-bundle-tutorial.html

for some info about that..

any way it seems to me that your problem is only with the
requered=true validation.

why not set required=false and add this type of validation in your
custom - interationalized validator.

I don't know if when required=false and content=null validation phase is skipped

I hope it helps


2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> Hi Sammy,
>
> I can't show the message near the inputfield, so I have to use
> <h:messaes/> which shows a list of all messages for the page. Thats
> why the name of the field within the message is important.
>
> I don't understand what you mean by your second proposal. Which class
> should I extend and where do I have to register a new messageloader?
>
> Thanks a lot,
> Rudi
>
> On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > I mean
> >
> > 1) cut DescrD from bundle so that message will be "value required"
> > only in appropriate language (the message is near the field so that
> > the field name is not really necessary to me)
> >
> > 2)extend message loader in order to translate upon a key/language
> > dictionary a proper name for the fields (more difficult but better)
> >
> > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > Hi Sammy,
> > >
> > > by modifying the bundle, I can't change the parameter passed to the
> > > message. If I for example have a input field like this:
> > >
> > > <h:input Text id="DescrD" required="true"
> > > value="#{PriorityEditBean.priority.prioDescriptionD}"/>
> > >
> > > So the generated message is something like
> > >
> > > Validation error "DescrD": value required.
> > >
> > > The problem is the "DescrD" is shown in all languages in the message,
> > > and this I can't change by modifying the bundle :(
> > >
> > > Do you have another idea?
> > >
> > > Thank a lot,
> > > Rudi
> > >
> > >
> > > On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > > > what about customize the bundle of messages?
> > > >
> > > > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > > > Hi,
> > > > >
> > > > > I have the problem, that I can't show the messages generated by the
> > > > > build in validation mechanism of my Faces because in all languages the
> > > > > name of an input field shown in the message is the id of the
> > > > > input field, and this id is not dynamic. So I can't change it for
> > > > > different languages.
> > > > >
> > > > > The idea is to write a validation method like validate Required() and
> > > > > depending on the component for which this method is called, generate
> > > > > the message on the fly in the right language. The problem is, that a
> > > > > validation method is just called, if there is a input in the filed, so
> > > > > I have to use the required-attribute. But this is exactly, what I want
> > > > > to avoid :)
> > > > >
> > > > > My question: can I force myFaces to call a validation method, also if
> > > > > the input field is empty?
> > > > >
> > > > > Thanks a lot,
> > > > > Rudi
> > > > >
> > > >
> > > >
> > > > --
> > > > ::Samples::
> > > > http://www.kyub.com/blog/
> > > > -----------------------------------------------------------------
> > > > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> > > >  E per un terzo giustificazione
> > > >
> > >
> >
> >
> > --
> > ::Samples::
> > http://www.kyub.com/blog/
> > -----------------------------------------------------------------
> > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> >  E per un terzo giustificazione
> >
>


-- 
::SammyRulez::
http://www.kyub.com/blog/
-----------------------------------------------------------------
La programmazione è per un terzo interpretazione e per due terzi ispirazione.
 E per un terzo mistificazione

Re: How to force validation

Posted by Rudi Steiner <ru...@googlemail.com>.
Hi Sammy,

I can't show the message near the inputfield, so I have to use
<h:messaes/> which shows a list of all messages for the page. Thats
why the name of the field within the message is important.

I don't understand what you mean by your second proposal. Which class
should I extend and where do I have to register a new messageloader?

Thanks a lot,
Rudi

On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> I mean
>
> 1) cut DescrD from bundle so that message will be "value required"
> only in appropriate language (the message is near the field so that
> the field name is not really necessary to me)
>
> 2)extend message loader in order to translate upon a key/language
> dictionary a proper name for the fields (more difficult but better)
>
> 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > Hi Sammy,
> >
> > by modifying the bundle, I can't change the parameter passed to the
> > message. If I for example have a input field like this:
> >
> > <h:input Text id="DescrD" required="true"
> > value="#{PriorityEditBean.priority.prioDescriptionD}"/>
> >
> > So the generated message is something like
> >
> > Validation error "DescrD": value required.
> >
> > The problem is the "DescrD" is shown in all languages in the message,
> > and this I can't change by modifying the bundle :(
> >
> > Do you have another idea?
> >
> > Thank a lot,
> > Rudi
> >
> >
> > On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > > what about customize the bundle of messages?
> > >
> > > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > > Hi,
> > > >
> > > > I have the problem, that I can't show the messages generated by the
> > > > build in validation mechanism of my Faces because in all languages the
> > > > name of an input field shown in the message is the id of the
> > > > input field, and this id is not dynamic. So I can't change it for
> > > > different languages.
> > > >
> > > > The idea is to write a validation method like validate Required() and
> > > > depending on the component for which this method is called, generate
> > > > the message on the fly in the right language. The problem is, that a
> > > > validation method is just called, if there is a input in the filed, so
> > > > I have to use the required-attribute. But this is exactly, what I want
> > > > to avoid :)
> > > >
> > > > My question: can I force myFaces to call a validation method, also if
> > > > the input field is empty?
> > > >
> > > > Thanks a lot,
> > > > Rudi
> > > >
> > >
> > >
> > > --
> > > ::Samples::
> > > http://www.kyub.com/blog/
> > > -----------------------------------------------------------------
> > > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> > >  E per un terzo giustificazione
> > >
> >
>
>
> --
> ::Samples::
> http://www.kyub.com/blog/
> -----------------------------------------------------------------
> La programmazione è per un terzo interpretazione e per due terzi ispirazione.
>  E per un terzo giustificazione
>

Re: How to force validation

Posted by "::SammyRulez::" <sa...@gmail.com>.
I mean

1) cut DescrD from bundle so that message will be "value required"
only in appropriate language (the message is near the field so that
the field name is not really necessary to me)

2)extend message loader in order to translate upon a key/language
dictionary a proper name for the fields (more difficult but better)

2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> Hi Sammy,
>
> by modifying the bundle, I can't change the parameter passed to the
> message. If I for example have a input field like this:
>
> <h:input Text id="DescrD" required="true"
> value="#{PriorityEditBean.priority.prioDescriptionD}"/>
>
> So the generated message is something like
>
> Validation error "DescrD": value required.
>
> The problem is the "DescrD" is shown in all languages in the message,
> and this I can't change by modifying the bundle :(
>
> Do you have another idea?
>
> Thank a lot,
> Rudi
>
>
> On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> > what about customize the bundle of messages?
> >
> > 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > > Hi,
> > >
> > > I have the problem, that I can't show the messages generated by the
> > > build in validation mechanism of my Faces because in all languages the
> > > name of an input field shown in the message is the id of the
> > > input field, and this id is not dynamic. So I can't change it for
> > > different languages.
> > >
> > > The idea is to write a validation method like validate Required() and
> > > depending on the component for which this method is called, generate
> > > the message on the fly in the right language. The problem is, that a
> > > validation method is just called, if there is a input in the filed, so
> > > I have to use the required-attribute. But this is exactly, what I want
> > > to avoid :)
> > >
> > > My question: can I force myFaces to call a validation method, also if
> > > the input field is empty?
> > >
> > > Thanks a lot,
> > > Rudi
> > >
> >
> >
> > --
> > ::Samples::
> > http://www.kyub.com/blog/
> > -----------------------------------------------------------------
> > La programmazione è per un terzo interpretazione e per due terzi ispirazione.
> >  E per un terzo giustificazione
> >
>


-- 
::Samples::
http://www.kyub.com/blog/
-----------------------------------------------------------------
La programmazione è per un terzo interpretazione e per due terzi ispirazione.
 E per un terzo giustificazione

Re: How to force validation

Posted by Rudi Steiner <ru...@googlemail.com>.
Hi Sammy,

by modifying the bundle, I can't change the parameter passed to the
message. If I for example have a inputfield like this:

<h:inputText id="DescrD" required="true"
value="#{PriorityEditBean.priority.prioDescriptionD}"/>

So the generated message is something like

Validationerror "DescrD": value required.

The problem is the "DescrD" is shown in all languages in the message,
and this I can't change by modifying the bundle :(

Do you have another idea?

Thank a lot,
Rudi


On 5/30/07, ::SammyRulez:: <sa...@gmail.com> wrote:
> what about customize the bundle of messages?
>
> 2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> > Hi,
> >
> > I have the problem, that I can't show the messages generated by the
> > build in validation mechanism of myFaces because in all languages the
> > name of an inputfield shown in the message is the id of the
> > inputfield, and this id is not dynamic. So I can't change it for
> > different languages.
> >
> > The idea is to write a validationmethod like validateRequired() and
> > depending on the component for which this method is called, generate
> > the message on the fly in the right language. The problem is, that a
> > validationmethod is just called, if there is a input in the filed, so
> > I have to use the required-attribute. But this is exactly, what I want
> > to avoid :)
> >
> > My question: can I force myFaces to call a validationmethod, also if
> > the inputfield is empty?
> >
> > Thanks a lot,
> > Rudi
> >
>
>
> --
> ::SammyRulez::
> http://www.kyub.com/blog/
> -----------------------------------------------------------------
> La programmazione è per un terzo interpretazione e per due terzi ispirazione.
>  E per un terzo mistificazione
>

Re: How to force validation

Posted by "::SammyRulez::" <sa...@gmail.com>.
what about customize the bundle of messages?

2007/5/30, Rudi Steiner <ru...@googlemail.com>:
> Hi,
>
> I have the problem, that I can't show the messages generated by the
> build in validation mechanism of myFaces because in all languages the
> name of an inputfield shown in the message is the id of the
> inputfield, and this id is not dynamic. So I can't change it for
> different languages.
>
> The idea is to write a validationmethod like validateRequired() and
> depending on the component for which this method is called, generate
> the message on the fly in the right language. The problem is, that a
> validationmethod is just called, if there is a input in the filed, so
> I have to use the required-attribute. But this is exactly, what I want
> to avoid :)
>
> My question: can I force myFaces to call a validationmethod, also if
> the inputfield is empty?
>
> Thanks a lot,
> Rudi
>


-- 
::SammyRulez::
http://www.kyub.com/blog/
-----------------------------------------------------------------
La programmazione è per un terzo interpretazione e per due terzi ispirazione.
 E per un terzo mistificazione