I am using a data table in jsf and I want to access the rows selected by the user.However I want my logic to that all in my managed bean rather than in th pagecode(backing beans).How can I do it?.Aim is to separate the messy page code and my logic.How can I iterate through the rows selected by user.Help needed.
I know I can get rowdata using that function but how can I get that UIComponent,Datatable.
Supposing I am clicking on a check box to select a particular row.Then if Im calling an action listner its registered as an event generated by checkbox and then I cant get the reference to Datatable.I need to get that reference and use the function ,rowdata.
As I suppose my managed bean to be free from codes that access these components.Can you please suggest a better way to organise the entire thing for clarity.
Offhand, I'd say you're trying to do things inside out and it's making things excessively complex.
JSF is based on Inversion of Control. In IoC, you normally don't have your beans go out and get things or do things. Instead, they wait for things to be injected into them and for requests to be made of them.
Another way of stating it is that the controlling logic is provided by the framework - the bean only provides the action logic and data storage. <hr/> You should separate business logic from the backing bean. It's good practice. But the way this is normally done is to implement the logic bean as a separate POJO which is injected into the backing bean either by JSF or an equivalent framework such as Spring. The backing bean's action processors then invoke the business bean's methods as needed,
I have no idea what "selected rows" means. JSF is not a client/server architecture nor is any other web application regardless of platform or programming language. A JSF backing bean can only receive events in a batch as an HTTP GET or POST request dispatches them - there's no back-and-forth like in client/server (and this is why I always stress that JSF is not a true MVC architecture). More to the point, I don't know what you mean by saying a row is "selected". There is a "current row" as a bean receives updates from the client, but this is enumerated by the framework, but that's an enumeration of all rows. There's no selection involved, just fields that updated or not.
Customer surveys are for companies who didn't pay proper attention to begin with.
Sorry ressurecting the topic but I have the same problem. I have an IceFaces <ice:dataTable> that iterates from a List (here called "dataList") and generates a table.
dataList has the attributes: id, name, category, scenario and scope.
The table must show 2 columns:
- The "name" of the current data from the list;
- A commandButton that redirects to a page to see it's details (the other attributes);
The question is: how set the "id" attribute in the Managed Bean with the data's "id" from the row wich button was clicked.
Button3 is clicked, the id "3" is passed to the managed bean, the form redirects to the detailed view of the data and retrieves the "id" of the row 3... Hope I made myself understood.
Tim, as you seem to be the guru around here... where can I get detailed information on the use of JSF managed beans, using FacesContext and PhaseListener kind of stuff? I only find simple examples with them but without information on -what- is really getting done.