aspose file tools*
The moose likes JSF and the fly likes Enabling and Disabling ComboBox/TextBox based on actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Enabling and Disabling ComboBox/TextBox based on actions " Watch "Enabling and Disabling ComboBox/TextBox based on actions " New topic
Author

Enabling and Disabling ComboBox/TextBox based on actions

Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

Hello All,

I wanted one help in the JSF modalPanel.

this is my modalPanel code:





As shown in the above code:

I have following components in ModalPanel:

1) ComboBox
2) Instance
3) Save and Cancel



I wanted some validation here :

For example:

- The Instance Text box and SAVE button should be disabled. When the pop up appears.
- The Instance Text BOX gets enabled only when any selection happenes in COMBO Box
- The SAVE button gets enabled only when COMBO BOX and INSTANCE TEXT BOX is filled.
- Let the CANCEL button be enabled always.


Please some one help me in this....


Regards,
Avinash Bhat
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

I was little puzzled as to why you were putting in brute-force boldface and color elements on your sample. Then I realized that you were attempting to highlight things and our formatting control doesn't do that. Oops.

As usual, I have to nit-pick before addressing the real problem: "CMBrowserBean" is a class instance, not a class. So according to the JavaBean conventions, its name should start with a lower-case character.

JSF does not enforce this, but some tools and other resources may have trouble when you don't follow the conventions. At least you didn't call it a "Controller" .

The easiest way to get your controls enabled and disabled is by using their "disabled" attributes to track a boolean property in a backing bean. The valueChangeListener can do an AJAX event that causes the bean to be (selectively) updated and the disabling booleans to be set/cleared as needed. Then the reRender can cause the target controls to be re-rendered using the current (updated) disable property values.

Attempting to do this stuff locally via javaScript instead is a path to insanity.

The only thing that's especially tricky about this is that you do have to sometimes consider context when re-rendering. One thing I keep running into is when local javascript alters controls (for example, attaching jQuery listeners) and the control is reRendered, it doesn't update the existing control, it deletes it and creates a new one that lacks the locally-set characteristics.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enabling and Disabling ComboBox/TextBox based on actions