tags:

views:

31

answers:

2

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.

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
one more doubt by calling valueChangeListener request is client side or server side
Hari
The `onchange="submit()"` submits the form to the server side and Java/JSF runs at the server side, so ...
BalusC
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
can we do this client side using javascript?
Hari
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
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