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

2006-03-16 Thread Krause, Nico
Hello All,

I just wanted to thank you all for your help. I thought posting the solution 
back to the list will help other people in  the future.

Oki - I did the following:


I created a map for the clientId's which will hold required validation messages.

Map styleMap = new HashMap();

An additional 'getRequired" method is executed by all the components which 
should get the style:

 

The following method finds out if there are any components with messages, adds 
it to the styleMap and returns true if so.

public boolean getRequired(){
styleMap.clear();
FacesContext context = FacesContext.getCurrentInstance();
Iterator itr = context.getClientIdsWithMessages();
boolean ret_val = false;
try{
while (itr.hasNext()) {
String clientId = (String) itr.next();  
 
UIComponent uic = 
context.getCurrentInstance().getViewRoot().findComponent(clientId);
styleMap.put(uic.getId(),"background: red");
ret_val = true;
}
}catch(Exception ex){}
return ret_val;
}


That also works pretty good for components in a dataTable.

Thanks again  - have a good one,

Nico


Nico Krause| Software Development| TomTom WORK | [EMAIL PROTECTED] | +49 
(0)1749891949 mobile | +49(0)34124495-0 office | +49(0)34124495-25 fax | 
www.tomtomwork.com

-Ursprüngliche Nachricht-
Von: news [mailto:[EMAIL PROTECTED] Im Auftrag von Laurie Harper
Gesendet: Donnerstag, 16. März 2006 06:11
An: users@myfaces.apache.org
Betreff: Re: (Validation) required="true" should change my css style of 
inputbox e.g. background:red

Yep, that's the simplest solution. If you don't want to emit the 
style/styleClass value from a backing bean you can also use a variant such as

   

Regarding your concern about doing this in a data table, you shouldn't have any 
problem provided you have the isRequired() method on each row item in your 
table model.

L.

CONNER, BRENDAN (SBCSI) wrote:
> if you can compute the style you want from the information you have in 
> one of your managed beans, I believe you can also do one of the
> following:
> 
> 
> 
> or
> 
> 
> 
> - Brendan
> 
> -Original Message-
> From: Christian Bohn [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 15, 2006 8:46 AM
> To: MyFaces Discussion
> Subject: Re: (Validation) required="true" should change my css style 
> of inputbox e.g. background:red
> 
> 
> Hi,
> 
> why don't you simply define two inputfields and render only one like
> this:
> 
> 
>  styleClass="red"    />
>  styleClass="normal"    />
> 
> 
> greetings
> 
> Chrstian
> 
> 
> 
> 
> 



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

2006-03-15 Thread Laurie Harper
Yep, that's the simplest solution. If you don't want to emit the 
style/styleClass value from a backing bean you can also use a variant 
such as


  

Regarding your concern about doing this in a data table, you shouldn't 
have any problem provided you have the isRequired() method on each row 
item in your table model.


L.

CONNER, BRENDAN (SBCSI) wrote:

if you can compute the style you want from the information you have in
one of your managed beans, I believe you can also do one of the
following:



or



- Brendan

-Original Message-
From: Christian Bohn [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 15, 2006 8:46 AM

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


Hi,

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


styleClass="red"    />
styleClass="normal"    />



greetings

Chrstian









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

2006-03-15 Thread CONNER, BRENDAN \(SBCSI\)
Oops, the second choice was meant to be



- Brendan

-Original Message-
From: CONNER, BRENDAN (SBCSI) 
Sent: Wednesday, March 15, 2006 9:07 AM
To: MyFaces Discussion
Subject: RE: (Validation) required="true" should change my css style of
inputbox e.g. background:red


if you can compute the style you want from the information you have in
one of your managed beans, I believe you can also do one of the
following:



or



- Brendan

-Original Message-
From: Christian Bohn [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 15, 2006 8:46 AM
To: MyFaces Discussion
Subject: Re: (Validation) required="true" should change my css style of
inputbox e.g. background:red


Hi,

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

...


...

greetings

Chrstian






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

2006-03-15 Thread Gerald Müllan
Hi,

have you tried it with a component binding of the inputbox in the model?

Just a quick idea, but with some coding in the model it may work.

regards,

Gerald

On 3/15/06, Krause, Nico <[EMAIL PROTECTED]> wrote:
> Christan,
>
> Thank you, i think it's a good idea, if nothing else helps. I think it should 
> work.
>
> Ciao
>
> Nico
>
>
> Nico Krause| Software Development| TomTom WORK | [EMAIL PROTECTED] | +49 
> (0)1749891949 mobile | +49(0)34124495-0 office | +49(0)34124495-25 fax | 
> www.tomtomwork.com
>
> -Ursprüngliche Nachricht-
> Von: Christian Bohn [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 15. März 2006 15:50
> An: MyFaces Discussion
> Betreff: Re: (Validation) required="true" should change my css style of 
> inputbox e.g. background:red
>
> ooops, sorry, I think, I read your question too fast and misunderstood it.
> ...
>
> so long
>
>
>
>


--
Gerald Muellan
Schelleingasse 2/11
1040 Vienna, Austria
0043 699 11772506
[EMAIL PROTECTED]


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

2006-03-15 Thread CONNER, BRENDAN \(SBCSI\)
if you can compute the style you want from the information you have in
one of your managed beans, I believe you can also do one of the
following:



or



- Brendan

-Original Message-
From: Christian Bohn [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 15, 2006 8:46 AM
To: MyFaces Discussion
Subject: Re: (Validation) required="true" should change my css style of
inputbox e.g. background:red


Hi,

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

...


...

greetings

Chrstian






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

2006-03-15 Thread Krause, Nico
Christan,

Thank you, i think it's a good idea, if nothing else helps. I think it should 
work.

Ciao

Nico


Nico Krause| Software Development| TomTom WORK | [EMAIL PROTECTED] | +49 
(0)1749891949 mobile | +49(0)34124495-0 office | +49(0)34124495-25 fax | 
www.tomtomwork.com

-Ursprüngliche Nachricht-
Von: Christian Bohn [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 15. März 2006 15:50
An: MyFaces Discussion
Betreff: Re: (Validation) required="true" should change my css style of 
inputbox e.g. background:red

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

2006-03-15 Thread Christian Bohn

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

2006-03-15 Thread Christian Bohn

Hi,

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

...
styleClass="red"    />
styleClass="normal"    />

...

greetings

Chrstian






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

2006-03-15 Thread Krause, Nico



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 | [EMAIL PROTECTED] | +49 
(0)1749891949 mobile | +49(0)34124495-0 office | +49(0)34124495-25 fax | 
www.tomtomwork.com