Hi Andy,
Here goes with the background. Feel free anyone to shoot me down if there's
a better approach :-)
The high level overview is as follows, then I'll follow with detail -:
[1] Formulating a good non-session-scope based way to handle concept within
an application of SearchObject/DisplayObjects/EditObjects where search
criteria is remembered throughout this chain.
[2] Issue I have current with single form bean approach in terms of how to
reset a request-parameter (eg ACTION) when forwarded in an action to another
action.
Some detail follows, however in summary in order to work around issue [2]
above I'm having I thought that breaking out the current form bean I have
into 2 form beans, would assist. See below
=== DETAILS ===
I want to have a design which caters for through out the application, for
each application object -:
- Search Object X
- Display Object Xs (could come in via other pages too)
- Edit/Add/Delete Object X
Once the edit/add/delete operations are completed then go back to the
"display object Xs" page, BUT remembering the original search criteria.
Without this (or a paging approach) useability becomes an issues when there
are many objects (ie search is used to narrow scope). Of course if you add a
new object with fields which didn't match the search criteria then after you
return to the "display object Xs" page the new item wouldn't be in the list,
but thats expected.
I currently have this working fine by incorporating in the objects FormBean
separate search fields. For example FormBeanX
--------
search_title
search_description
action
...
title
description
-------
This way the FormBean is passed each time through the chain of pages and the
search_xxx fields are automatically picked up from request parameters via
the struts infra-structure. In the "Display Object Xs" and "Edit/Add/Delete
Object X" JSP pages I just include them as hidden elements.
I did however have to use the ACTION field in the formbean to check whether
we were in a "search" OR "add"/"edit"/"delete" action state, and then only
validate as appropriate.
My only setback to this seemingly nice design is that if you (a) hit an
exception on the "display Object X's" page after you clicked on edit/add or
delete, OR (b) if the user hits cancel on this screen, THEN I need to go
back to the "display Object X's" to display the error. As there is setup of
the object list for this page I want to forward back to the action
associated with setting up this page (ie not recode same thing in a
different action class). However what I need to do is reset the ACTION
field from EDIT say to DISPLAY (noting the validation comment above), and
this is the problem.
It seems this may not be possible?
- setting the ACTION field in the formbean from within the action prior to
the forward doesn't work as the pseudo code in a previous post from TedH
indicated that "If a form bean is in play, the ActionServlet resets and
populates it from the HTTP request"
- I still haven't found a way to override a request parameters value from an
action yet??? (it seems possible using a JSP tag, ie the forward tag, so
maybe I just haven't worked it out yet)
=====
Hope that make sense. In summary therefore struts questions I have are -:
[1] How to override a request parameters value in an action &
[2] How to load a 2nd form bean in an action (see email below)
[PS. Another thought I just had is to have a separate action field for the
seach case. ie within the form bean have ACTION and SEARCH_ACTION.]
Regards
Greg
----Original Message Follows----
From: "Andy Noble" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Subject: Re: Help-Loading 2nd FormBean in same action???Is there an easy
way??
Date: Mon, 3 Dec 2001 00:04:28 -0000
As far as I'm aware, 1 JSP form gets mapped to 1 formbean.
Why would you not have the attributes in the first formbean?
If really necessary, you could maybe consider have the 1st formbean have
getters and setters which delegate to a second formbean. But would help if
you could explain reason for 2nd formbean.
Andy
----- Original Message -----
From: Greg Callaghan <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 02, 2001 11:22 PM
Subject: Help-Loading 2nd FormBean in same action???Is there an easy way??
> Hi,
>
> Does anyone know an easy way to load a 2nd form bean in an action?
>
> That is, the main formbean has already been specified in struts.xml for
that
> action and will load automatically per usual. If however I have other
> separate hidden form elements in my JSP form which I would like to
auto-load
> into their associated formbean (ie the 2nd form bean) is there a way to
> easily do this in the action in struts.
>
> Eg. Within Action Class -:
> FormBean2 formbean2 = LOAD (request, <formbean2 class ref>)
> (or something like this)
>
>
> Cheers
> Greg
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>