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

Disabling h:commandButtons in d:dataTables  RSS feed

 
Dimitris Karageorgopoulos
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I use JSF 1.1
I have a dataTable that displays rows of data from a managed bean function of the type

public List<MyObject> getListOfDate()

Each row displayed is actually an h:commandButton. Inside the ActionListener of the commandButton, after some business specific actions, I want to disable the button

public void clickActionEvent(ActionEvent event){
if (event.getComponent() instanceof HtmlCommandButton){

//Business code


HtmlCommandButton rowButton = (HtmlCommandButton)event.getComponent();
rowButton.setDisabled(true);

}
}

However, this code instead of disabling the row button I click, it disables it all the buttons in all rows of the dataTable.

Is this default behaviour?

Is there any JSF way I can overcome it ?
 
Tim Holloway
Bartender
Posts: 18713
71
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you add a boolean column to your datamodel row object you can use that to control enable/disable using the following syntax:


No JSF-specific code is required.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!