| Author |
valueChangelistener vs Javascript
|
bert brutzel
Greenhorn
Joined: May 28, 2010
Posts: 6
|
|
Hi all,
One of the input fields of my form should be mandatory in dependency of the currently selected item of an item list. The label of this input field should be bold only if the value of the list is (e.g) 2 or 3. This should be done without validating any other field.
So I wrote this valueChangeListener:
But the event obviously occurs only when the whole form is submitted, evan with immediate="true". But then all other fields are validated also
Because I'm new to JSF, I don't understand, which action is fired at which time.
So is it better to write a special validator and handle the style of the label with Javascript? I think this is very dirty! How can I do this with JSF?
Sorry for my english and many thanks for your help!
utzel
|
 |
bert brutzel
Greenhorn
Joined: May 28, 2010
Posts: 6
|
|
|
In the meantime I've found out, I was successful (beside fixing some errors in the listener) with <f:ajax ...
|
 |
suresh dasari
Ranch Hand
Joined: Oct 05, 2009
Posts: 120
|
|
I faced the same issue.
it worked for me, but when you submit the page without selecting any value from dropdown then valueChangeListener is called once and then for the second click page is submitting resulting in double submission of a page when dropdown is not altered
if you change the dropdown once, then for single submission is working fine.
can any one help me out?
|
Sun Certified Java Programmer with 93 percent
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
|
If you use RichFaces, this is fairly simple. Your valuechangelistener only needs to set a "render" flag. Use the ajaxSingle attribute on the AJAX event definition to limit input to just the input control in question and a reRender= that includes the control whose state you want updated. The valuechangelistener ONLY needs to set a flag - no mucking around with the component tree is required, since RichFaces does all the sordid little details automatically, as long as the affected control has its render= attribute set to monitor the flag that the valuechangelistener toggles.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: valueChangelistener vs Javascript
|
|
|