So here is my dilemma, I'm trying to enable/disable a button depending on whether at least one check-box is checked or not in a table. I'm trying to use a valueChangeListener (my first time using this) but I can't seem to get it to work.
Here is my code for the table and button.
This is my bean code.
Can someone please help me out?
Thanks in advance!
PS: I know that document.getElementByID("selectMessage").checked) is not the correct syntax, but I dont know the right way to do it.
Couple of problems here. Don't capitalize object instance or property names (EnableDisable.Checkbox). The convention is to capitalize class names and lowercase the inital letter of instances, methods, and properties, and it's bad practice at best, and a potential fight with JSF at worst if you don't adhere to the convention.
ValueChangeListener is fired as a part of the form submit process, so if you're hoping to dynamically update the page, you're out of luck. You'd need to add AJAX support to your checkboxes for that.
Even with AJAX, however, the entire form will be submitted by default, which means that the valueChangeListener will only fire if ALL controls in the form have valid values, so your best bet is to constrain the submit to just the checkbox itself.
Normally you get the value of a control by querying the control's property (that is "isCheck1()" for checkbox 1, since it's a boolean property). However, the valueChangeListener is part of the updating process, so that's not something to rely on. ValueChangeListeners really should ONLY pay attention to the value being changed. For something that needs to know about the form as a whole, use an action processor instead.
Customer surveys are for companies who didn't pay proper attention to begin with.