Re: Anybody? .. Re: Help with a design issue that I'm stumped by....

Vic Cekvenich <[email protected]> Sat, 10 May 2003 17:22:41 -0400
Newsgroups gmane.comp.java.mvc.devel
Organization baseBeans Engineering
Message-ID <[email protected]>
<!- - since bean is mapped, Struts does the new for you so any new by 
you is just GC - - >
<action path  ="/srchPg"  type="com.r.SrchAct"
name="srcBean"    scope="session" validate="false">
    <forward name="Success"      path="srch.jsp" />
    <forward name="Submit"         path="/do/empPg?Dispatch=List" />
</action>

<! - - in action you have to do if/then to see if you have enough data 
to execute the srch, action is the controller, eh - - >

<action path  ="/ empPg"  type="com.r.EmpAct"
name="empBean"    scope="session" validate="false">
    <forward name="Success"      path="empLst.jsp" />
    <forward name="Edit"         path="empEdit.jsp" />
</action>

<! - - since bean in session, you have to clear it, and in dispatch tell 
to go to list -->


Rick Reumann wrote:

>On Fri, May 09,'03 (01:58 PM GMT-0400), Vic wrote: 
>
>  
>
>>I have never needed action chaining. You are just over anyalizing
>>maybe. Struts is MVC so there are 3 parts to everything.
>>    
>>
>
>I don't think I'm over-analyzing this, but if I am please someone show
>me an alternative to the way I would have to return a list based on
>some criteria using the BaseBean approach.
>
>To sum up I'm following this logic:
>
>search.jsp - has some form properties like employeeDepartment
>
>search.jsp is mapped with a SearchFormBean and submits to EmployeeAction
>
>EmployeeAction then needs to do:
>
>	EmployeeBean employee = new EmployeeBean();
>	employee.populate( (SearchFormBean)form.getDepartment() );
>
>Now the reason this question came up was because you mentioned
>that you could have the action mapping create the EmployeeFormBean for
>you so you don't need to do it the action. I understand the mapping does
>that as it's doing here in the case of SearchFormBean. You mentioned
>that instead you could have: 
> 
>  
>
>>Page 1 is search.jsp so you call serachAct that forwards to it. (it
>>also has a serachBena)
>>
>>Page 2 is employeList.jsp so you call employListAct to get to it. (it 
>>also has a employListBean)
>>    
>>
>
>Here's where I don't see how this solves the problem....  
>
>For one you are saying the searchAction forwards to the search.jsp and
>has with it a SearchBean. In this scenario all you are doing is using
>the searchAction here to 'set up' the search.jsp form. That's fine since
>that's probably needed as well to possibly set up some parameters for
>the form, etc. BUT, remember the reason for this form is to present the
>criteria on the page so that when the user submits the form he is
>brought to the list of employees (based on some search criteria).
>
>The search.jsp page is backed by your SearchForm object - NOW the
>question is where does this form on the search.jsp submit??? According
>to your above Page 2 explanation you would say have this form submit to
>"employeeListAct" so that we can get the list back but the problem is
>the search.jsp page needs to be backed by the SearchFormBean. You can't
>map the action of the search.jsp to employeeListAction since you want
>employeeListAction to  be backed by the EmployeeFormBean.
>
>The problem is search.jsp needs to submit to an action like
>employeeListAction but backed by the SearchFormBean so it can use the
>FormBean parameters to figure out how to get back your List of
>Employees. (Which is fine, but then you end up having to manually create
>EmployeeBean in your EmployeeListAction like I showed in the initial
>example). 
>
>Vic, could you (or anyone?) please show the actual mappings in the
>struts config file you would set up for Page 1 and Page 2 scenarios
>above to avoid having to create the instance of EmployeeBean like I have
>done? I don't think it's a big deal but I don't see a way around it and
>would love to see the proposal to avoid this.
>
>Thanks again,
>
>  
>

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East. 
Open Source <a href ="baseBeans.com">Content Management</a>  basic
Portal sofware
Best practice<a href ="baseBeans.com">Supported Struts v.1.1</a>
framework ScafflodingXPress