You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Krause, Nico" <ni...@tomtom.com> on 2006/03/15 15:09:26 UTC

(Validation) required="true" should change my css style of inputbox e.g. background:red

Hello, 
 
i was wondering how to change the background of an inputbox by simply
changing the css style to e.g. background:red. when a required="true" -
validation was set.
I was trying several possibilties but no one seems to fit my needs and i
am just right now some kind of frustrated because of this issue. 
 
1. Making use of the Expression Language by just accessing a
method/property in a backing bean. This works fine, as long as i don't
want do access Input-Elements of a dataTable. I don't think i can use
the Expression Lanuage to access a method with a parameter like
getStyle(componentId)
 
2. I was trying to find a possibility access the components-attributes
through "findComponent("inputbox1")  in the jsf-api. Unfortunatly I was
not able to find the component (my input textfield) by its name or any
other function under FacesContext. Result was allways null. :-(
 
3. Implementing an own Validator: I implemented an own Validator which
worked pretty good unless the field was at least 1 letter. The validator
was not fired when i typed nothing into the inputBox. (But this is
exactly the functionality i need)
 
At the end of the day i think i have to rewrite each component and
overwrite the validate method just because of of the requirement to make
the background of an input field red if a user forgot to enter data when
it's required definitly.
 
Is that correct what i am thinking? Did i ignore other facts or
specifications?
 
Thank you in advance for any hint how to change the css style with in a
required="true".
 
Best Regards,
 
Nico
 
 
 
 
 
 
Nico Krause| Software Development| TomTom WORK | nico.krause@tomtom.com
| +49 (0)1749891949 mobile | +49(0)34124495-0 office | +49(0)34124495-25
fax | www.tomtomwork.com <http://www.tomtomwork.com/> 
 

Re: (Validation) required="true" should change my css style of inputbox e.g. background:red

Posted by Christian Bohn <C....@CHILI-Radiology.com>.
ooops, sorry, I think, I read your question too fast and misunderstood it.
...

so long




Re: (Validation) required="true" should change my css style of inputbox e.g. background:red

Posted by Christian Bohn <C....@CHILI-Radiology.com>.
Hi,

why don't you simply define two inputfields and render only one like this:

...
<t:inputText rendered="#{<<the EL-expression you used in your 
required-attribute or simply true or false}"  required="true" 
styleClass="red"  ....  />
<t:inputText rendered="#{! <<the EL-expression you used in your 
required-attribute or simply true or false}"  required="false" 
styleClass="normal"  ....  />
...

greetings

Chrstian