m4rkuz schrieb:
Hi Everyone,
I have a little big problem, I got a CRUD like app, in the main form
I have a data table that shows the result of a query and every row has
a link to jump to the edit page, everything works fine, until I try to
go to the next page /*h:commandLink action="#{backingBean.edit}"
*/with the selected row so I can edit it, the problems kicks in when I
remove a line of code that I have in the getObjectList method
/* objectList = manager.findAll();
*/
I remove it because I need that the main page doesn't show anything
until the search button is clicked, after this modification the links
stop working, I cannot get to the nex page, in Debug mode I see I
don't even get to the edit() methond in the backing bean, is like the
bean is recreated before the action of the h:commandLink kicks and
then the table data and the row are null so they don't fire any event :S
The BackingBean scope is Request (it work with session scope but I
don't think is necesary to hold on that bean for a whole session )
When you have input fields or commandlinks within a table, then on
postback the backing bean needs to have the table's datamodel available,
ie the value attribute of the datatable has to return the same list of
objects.
Reloading the table from the database does work in some cases (your
getObjectList method), as long as it always returns the same objects
that were present when the table was rendered, ie the data in the table
is *static*. But in most cases this is not true, ie the number of
matching "rows" in the database might change. In this case you just
cannot use request-scoped backing beans with tables that have input
fields or commandlinks in them.
Your options are to use session scope, or use one of the "conversation
scope" implementations available, or to not have tables with command or
input components. Or *if* your manager.findAll method always returns the
same results, then put it back in.
Regards,
Simon