Tim,
    I'm not sure this will work for you, but if it does, it may be the 
easiest solution.  I am assuming that you have a "failure" forward in 
the Delete action that sends the user back to the list page.  Instead of 
mapping this forward to the list page, map it to the list action.  That 
way, the action errors (or non-struts error message) that you save in 
the request object will still be there, and it will pick up the vector 
in the list action before it dispatches to the list page.

Bill

Tim Trentham wrote:

> I'm wondering if there is a "best practice" or standard Struts way of
> handling repopulation of request attributes needed for a page after an
> error. 
> 
> For instance, I have a list of contacts with a checkbox next to each one.
> The list is generated by the logic:iterate and multibox tags using a vector
> that is placed in the request by the action that forwards to the page that
> displays the list. The user can select contacts from the list and delete
> them.
> 
> If the user clicks the delete button and there are no users checked, my
> validate method throws them back to the page telling them that they need to
> pick something. Of course, the vector is no longer in the request for
> display, so you see the error message, but no users.
> 
> I did find a two things in past posts, but nothing really promising...
> 
> 1)
> repopulation occurs in the reset method
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05423.html
> 
> but this means that you are re-populating the request with the dropdown list
> even if there aren't any errors, which seems like a waste of resources.
> also, you still have to populate the first time from somewhere else as the
> forms reset() method isn't called until after the first time the page is
> displayed.
> 
> 2)
> repopulation occurs in validate method
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg11305.html
> 
> this is what i'm looking at doing, but once again, i have to do it in two
> places: the original action that generates the list in the jsp page and then
> in the validate method of the form if there is an error.
> 
> I also have the additional problem of keeping track of which vector to
> re-generate. I display the contacts in blocks of 25, so if you are on the
> second block of 25 and you click delete with no contacts checked, I need to
> know that I need to re-generate the second block and not the first.
> 
> I'm wondering if others have come up with a good way of handling this before
> I go off and reinvent the wheel.
> 
> Thanks.
> 
> Tim
> 
> --------------------------------
> Tim Trentham
> Platform Development
> @hand Corporation
> [EMAIL PROTECTED]

Reply via email to