• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enabling and Disabling ComboBox/TextBox based on actions

 
Greenhorn
Posts: 14
Android
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....


Regards,
Avinash Bhat
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic