You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Lindholm, Greg" <gl...@neom.com> on 2006/03/09 20:45:00 UTC

Looking for equivalent to Struts errorStyleClass with an input field

I'm writing my first JSF application and looking for the equivalent to 
"errorStyleClass" feature I used in Struts.

In Struts you can specify an "errorStyleClass" attribute on an
<html:text>  input field tag. If a validation error occurs on that field
it will 
redisplay the field with the supplied errorStyleClass. 

	<html:text errorStyleClass="errorStyle" ....>

The JSF <h:inputText > tag doesn't support this so how do you do this 
in JSF?

I see something similar in the <h:message errorClass="errorStyle"...>
tag 
but it seems to apply to the message not the input field.

Is there another component I can use? Or can I embed the field in in 
another tag?

---
Greg Lindholm





Re: Looking for equivalent to Struts errorStyleClass with an input field

Posted by Mike Kienenberger <mk...@gmail.com>.
I haven't done this, but here's a couple of approaches I'd use if I
were going to.

1 ) http://issues.apache.org/jira/browse/TOMAHAWK-165
ifMessage tag that renders children only if there is a message for the
specified component(s)

2) Alternately, create a styleClass="#{backingBean.errorStyleClass}"
attribute with a method that returns either the error style or the
normal style depending on if it finds an applicable message tag.

You can also set up an h:message or t:message tag that is active only
for specific component, but I don't know if that would really help you
in your case.

On 3/9/06, Lindholm, Greg <gl...@neom.com> wrote:
> I'm writing my first JSF application and looking for the equivalent to
> "errorStyleClass" feature I used in Struts.
>
> In Struts you can specify an "errorStyleClass" attribute on an
> <html:text>  input field tag. If a validation error occurs on that field
> it will
> redisplay the field with the supplied errorStyleClass.
>
>         <html:text errorStyleClass="errorStyle" ....>
>
> The JSF <h:inputText > tag doesn't support this so how do you do this
> in JSF?
>
> I see something similar in the <h:message errorClass="errorStyle"...>
> tag
> but it seems to apply to the message not the input field.
>
> Is there another component I can use? Or can I embed the field in in
> another tag?