It's a database, values always change and not only during an action.
That's why i am using request scope bean for those values, which brings
me troubles when it comes to needing a permanent state for datatable to
work properly...
Mike Kienenberger a écrit :
> You only need to reset the bean values if the bean values change in
> some way beyond the normal flow of the program. Ie, if you click on
> a button, and suddenly a row is gone, then you need to reset your
> cached/saveState'd backing list.
>
> If you have a specific example, I can offer you some specific advice.
>
> On 9/18/06, David Delbecq <[EMAIL PROTECTED]> wrote:
>> Ok, In this case that can be applied because this action is the only one
>> involved in that specific form. But what about more complex form, where
>> there is such a table but lots of possible actions, if i need to always
>> reset the bean value between the decode and the encode operations?
>> Mike Kienenberger a écrit :
>> > Yes to both of you. All you need to do is update your backing data
>> > model in the action -- pretty convenient :-)
>> >
>> > Ie, if you have something like
>> >
>> > <h:dataTable value="#{sharkEngine.acceptedAssignments}"
>> > <h:commandLink action="#{sharkEngine.action.showActivity}"
>> >
>> > then in #{sharkEngine.action.showActivity} you change the value of
>> > sharkEngine.acceptedAssignments to be the updated list.
>> >
>> >
>> > On 9/16/06, delbd <[EMAIL PROTECTED]> wrote:
>> >> So then my problem is how to have the datatable contains old datas
>> >> before action and new datas after action...
>> >
>> > On 9/16/06, Mr Arvind Pandey <[EMAIL PROTECTED]> wrote:
>> >> u r right. u can use preserveDataModel="true" in
>> >> datatable. if it is true then action method surely be
>> >> invoked. But the problem is if u want to delete the
>> >> row from table and afetr deletion you want to display
>> >> the same page then row will be deleted from DB but
>> >> page will contain that row. I am looking for the soln.
>> >
>> >> Mike Kienenberger a écrit :
>> >> > h:dataTable value="#{sharkEngine.acceptedAssignments}" must remain
>> >> > constant from renderResponse of the first request through
>> >> > invokeAction of the second request.
>> >> >
>> >> > I handle this by using <t:saveState
>> >> > value="#{sharkEngine.acceptedAssignments}">
>> >> >
>> >> >
>> >> >
>> >> > On 9/15/06, David Delbecq <[EMAIL PROTECTED]> wrote:
>> >> >> Hello,
>> >> >>
>> >> >> I have a datatable that iterate over some database values. Those
>> >> values
>> >> >> are subject to change, especially in quantity. The datatable is
>> >> rendered
>> >> >> like this:
>> >> >> <h:dataTable value="#{sharkEngine.acceptedAssignments}"
>> >> >> var="theAssignment">
>> >> >> <h:column>
>> >> >> <h:commandLink immediate="true"
>> >> >> value="#{theAssignment.activity.name}"
>> >> >> action="#{sharkEngine.action.showActivity}"
>> >> >> actionListener="#{sharkEngine.action.commandListener}">
>> >> >> <f:param name="activityToShow"
>> >> >> value="#{theAssignment.activity.key}" />
>> >> >> </h:commandLink>
>> >> >> </h:column>
>> >> >> </h:dataTable>
>> >> >>
>> >> >> This basically renders a list of links that need to contain one
>> >> >> information: "activityToShow". Technically,
>> >> >> #{sharkEngine.action.showActivity} will need nothing more to setup
>> >> >> session and show the edition form. However, between display of
>> >> table and
>> >> >> click by user, the database list referenced by datatable is
>> >> subject to
>> >> >> change (because whatever happens, we must reflect db changes to
>> >> user).
>> >> >>
>> >> >> Here is the problem:
>> >> >> If 3 items are showned to user (let's say a,b,c), the user clicks
>> >> on the
>> >> >> last one (c) but by that time the entry a has been removed from
>> >> >> database, the action does not take place?!?
>> >> >> I suspect this is because the 3rd line of datatable has been
>> >> removed,
>> >> >> but how do i handle this. The user won't accept that nothing
>> happens
>> >> >> while he clicks on an entry, obviously. JSF is silent on why it
>> >> did not
>> >> >> execute the action and <h:messages/> shows nothing too.
>> >> >>
>> >> >> What is the good way to create such list of links?
>> >> >>
>> >>
>> >>
>>
>>