In my application i am enabling and disabling a button according to the value selected by the user from the <h:SelectOneMenu>
. I am using a valueChangeListener
for the same operation.My doubt is whether it is good to use javascript
or the valueChangeListener
for better performance.
views:
31answers:
2
A:
Rule #1: JavaScript can be disabled.
By the way, the valueChangeListener
already won't be fired automatically without a little help of JavaScript. The onchange="submit()"
part is JavaScript.
BalusC
2010-06-22 11:19:32
one more doubt by calling valueChangeListener request is client side or server side
Hari
2010-06-22 11:35:44
The `onchange="submit()"` submits the form to the server side and Java/JSF runs at the server side, so ...
BalusC
2010-06-22 11:52:55
A:
Depends on what you want to do once the value changes. With javascript, the only way to trigger a server side action is to submit()
the form via the onchange
attribute. This simply submits all information to the backing bean. The valueChangeListener
on the other hand gives you more control on the server side (what element changed, what was the old value, what was the new value)
Java Drinker
2010-06-22 14:43:54
Hmmm, one of us is confused I think. Do you only want to do some client side processing when the value changes? What I mean is, when the user selects some new value, what do want that to do? Should it update a database column/other storage? Should it simply modify something on the page shown to the user?The best solution depends on what you're trying to acomplish
Java Drinker
2010-06-23 12:41:01
I just want to enable and disable a button according to the data selected by the user, its not just on onchange enable or disable a button need to validate the data and do the enabling and disabling.
Hari
2010-06-23 15:01:15