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 valu开发者_JS百科eChangeListener
for the same operation.My doubt is whether it is good to use javascript
or the valueChangeListener
for better performance.
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.
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)
精彩评论