This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Disabling h:commandButtons in d:dataTables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Disabling h:commandButtons in d:dataTables" Watch "Disabling h:commandButtons in d:dataTables" New topic
Author

Disabling h:commandButtons in d:dataTables

Dimitris Karageorgopoulos
Greenhorn

Joined: Oct 11, 2010
Posts: 11
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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14480
    
    7

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Disabling h:commandButtons in d:dataTables
 
Similar Threads
display multiple rich:dataTables
DataTable and Select All Checkboxes
Create row index in dataTable
Delete an empty row from datatable
Multiple Data Tables