This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Dear Sirs and Madams,
I am very new to JSF and would appreciate any help on the current issue am having. I have data being displayed on a browser via a JSF table, and the table is bound to a userVOArray attribute on the managed bean. All works well and I have a able of users displayed (first name, last name, user type etc). As the array is populated by data pulled from a database, its size changes depending on users being added or deleted. I wish to add a column of checboxes to the table allowing me to delete a user whose corresponding checkbox has been checked. How would I go about this please?
JSF is based on the Model/View/Controller architecture. So the view (datatable) can only display what's in the model.
Your problem is that the original rows of the datatable don't possess a "delete me" attribute.
You get around this by building a model that does. In other works, instead of binding the datamodel directly to the view, construct a façade class that includes the original attributes of a datamodel row plus a boolean item that indicates deletion and build your view model using instances of this class. You can then reference this view model when looking for items to delete.
Customer surveys are for companies who didn't pay proper attention to begin with.
Thanking you both for your prompt responses, I will try your suggestions and get back to you with any further queries.
Joined: Oct 10, 2006
Hello again, am pleased to say the suggestions made came in extremely useful and I have sorted out the dynamic checkbox issue, thanks again! However I now have a similar issue: I would like to have a new column next to the checkbox column, also dynamic with a button so that when that button is clicked on, that row is selected to be edited (However if there is a better way of fulfilling such a use case please let me know). Am using a Table as opposed to a datatable from the palette in netbeans, not sure if that makes a difference but thought I would add the info.
Thanking you profusely in advance for any input,