Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Enabling and Disabling ComboBox/TextBox based on actions  RSS feed

Avinash Bhat
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....

Avinash Bhat
Tim Holloway
Posts: 18709
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!