Ok, I have figured out why I was having a problem. Why I'm getting the
output that I am I still have to investigate.

I first noticed that all the examples that I've seen forward directly to a
jsp page, I forward to an action that then forwards to a jsp page. I've done
this since it then hides the fact I'm using jsp pages since all my actions
are actually mapped to using the *.html extention instead of the *.do. So my
results, going through an action look like it's just an html page ...

Anyhow, I then looked at how I was doing my forward and removed the
'redirect = "true"' and changed it to false. Now when I add an attribute to
the request scope the jsp page finds it.

Like I said, I'm not really sure why the redirect = "true" would give me
problems, but as soon as I changed it to false everything worked.

Thanks for all of your patience reading all this.
 

> -----Original Message-----
> From: Hubert Rabago [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, March 17, 2005 10:14 AM
> To: Struts Users Mailing List
> Subject: Re: Correct Prepopulate Method
> 
> Hi Joel,
> 
> From the message you include below:
> 
> =====================
> If you want to use request scope, change /submitForm to:
> <action path="/submitForm" name="myForm" 
> scope="request"...>....</action>
> 
> then in showPage:
>     request.setAttribute("myForm", myForm);
> 
> =====================
> 
> The key here is that the mapping to which a form gets 
> submitted to dictates which scope that form will reside.  It 
> doesn't matter where a setup action puts it, because setup is 
> optional.  In fact, it can place it in all three scopes (app, 
> session, request), and the <html:form> tag will still use the 
> scope specified in the mapping which it will be submitted to.
> 
> I think what's causing your confusion is that you're using an 
> ActionForm for data being sent to the JSP, as opposed to 
> something that holds data from an html <form>.  (It probably 
> didn't help that my message started with a typo - I meant to 
> say "setup action" and instead wrote "setup form".)  Sure, 
> you can use it for that purpose, but it's important to 
> understand what it was initially designed for in order to 
> understand how it behaves, before attempting to use it for 
> other purposes.
> 
> http://marc.theaimsgroup.com/?l=struts-user&m=111077992831529&w=2
> 
> In your case, you seem to be just listing down a set of 
> values, as opposed to showing a form that's been 
> prepopulated.  I personally won't bother creating a form just 
> to pass these down and list them in a static way, though I 
> understand that some people do.
> 
> Hubert
> 
> 
> 
> 
> On Thu, 17 Mar 2005 09:48:04 -0700, Schuster Joel M Contr 
> ESC/NDC <[EMAIL PROTECTED]> wrote:
> > I'm still trying to understand this. Please be patient.
> > 
> > Here's my setup. I'm trying to create a test page that will do 
> > regression tests against all the different parts of my 
> internal systems.
> > 
> > I have one simple form (ActionForm) defined.
> > 
> > <form-bean name="CollectionForm"
> > type="org.apache.struts.action.DynaActionForm" >
> >   <form-property name="collection" type="java.util.Collection" /> 
> > </form-bean>
> > 
> > I have two actions that deal with this ...
> > 
> > <action path="/outputpage/testresults"
> > forward="/WEB-INF/jsp/testresults.jsp" /> <action 
> > path="/actions/runtests" type="org.loom.fe.actions.RunTestAction"
> >         name="CollectionForm" scope="request" >
> >         <forward name="results" path="/outputpage/testresults.do"
> > redirect="true" />
> >         <forward name="errror" ... />
> > </action>
> > 
> > So then in my execute of RunTestAction:
> > 
> > {
> > ...
> > DynaActionForm dform = (DynaActionForm) form;
> > 
> > // create my test results and put them in the collection Collection 
> > testResult = ...
> > 
> > // put the collection into the outgoing form dform.set( 
> "collection", 
> > testResults);
> > 
> > // put the form into the right scope
> > 
> > request.getSession().setAttribute( "CollectionForm", dform);
> > 
> > // go to the results page
> > return (mapping.findForward( "results")); }
> > 
> > To kick things off I have this in my admin screen:
> > 
> > <html:link action="/actions/runtests.do">Run Tests</html:link>
> > 
> > Then in my testresults.jsp:
> > 
> > <logic:present name="CollectionForm">
> >   <table>
> >    <logic:iterate id="result" name="CollectionForm" 
> property="collection">
> >      <tr>
> >        <td><bean:write name="result" property= ... Test 
> result ... /><td>
> >      <tr>
> >    </logic:iterate>
> >   </table>
> > </logic:present>
> > 
> > OK... Just to make sure we all understand, the above works! 
> It works 
> > just fine!
> > REPEAT: IT WORKS
> > 
> > However, I really don't like putting the CollectionForm 
> that's going 
> > to my results page being in the session scope. I'd much 
> rather have it 
> > only in the request scope of the results page. That way this 
> > CollectionForm doesn't travel all around with the session. 
> Of course I 
> > could manually remove it from within the jsp page, but that 
> would kill the whole point of MVC...
> > Right?
> > 
> > I've tried making two changes:
> > 1. change the action for the results page <action 
> > path="/outputpage/testresults"
> > forward="/WEB-INF/jsp/testresults.jsp" scope="request" /> 2. change 
> > the scope of the variable for the CollectionForm in RunTestAction 
> > request.setAttribute( "CollectionForm", dform);
> > 
> > That doesn't work. The CollectionForm is not available at 
> all to the jsp.
> > 
> > Then I tried this:
> > 1. change the action for the results page <action 
> > path="/outputpage/testresults"
> > forward="/WEB-INF/jsp/testresults.jsp" 
> name="CollectionForm" scope="request"
> > />
> > 
> > This then make a CollectionForm available to the jsp but it was 
> > empty.. Not the same one that I had linked to the request above.
> > 
> > It seems to me that really it shouldn't be able to work since the 
> > request form my RunTestsAction is a totally different 
> object than the 
> > request for the jsp page. Thus the example from Hubert 
> below wouldn't work in my mind.
> > 
> > So, bottom line... I can make what I'm trying to do work. 
> But it just 
> > doesn't feel right putting it into session scope. I can't 
> believe that 
> > no-one has had to deal with this before.
> > 
> > > -----Original Message-----
> > > From: Hubert Rabago [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, March 11, 2005 9:36 AM
> > > To: Struts Users Mailing List
> > > Subject: Re: Correct Prepopulate Method
> > >
> > > You would usually do prepopulation in a setup ACTION.  
> Which scope 
> > > you place the form in depends on how you configure the 
> action that 
> > > the form will be submitted to.  For example, if you have 
> > > "/showPage.do"
> > > and "/submitForm.do", where submitForm is configured as:
> > >
> > > <action path="/submitForm" name="myForm" ...>....</action>
> > >
> > > Then in the action for showPage, you'd:
> > >
> > >     ModuleConfig moduleConfig =
> > > ModuleUtils.getInstance().getModuleConfig(request);
> > >     FormBeanConfig formBeanConfig =
> > > moduleConfig.findFormBeanConfig("myForm");
> > >     DynaActionForm myForm = (DynaActionForm) 
> > > formBeanConfig.createActionForm(getServlet());
> > >
> > >     myForm.set("propName",propValue);
> > >     request.getSession().setAttribute("myForm", myForm);
> > >
> > >
> > > If you want to use request scope, change /submitForm to:
> > > <action path="/submitForm" name="myForm"
> > > scope="request"...>....</action>
> > >
> > > then in showPage:
> > >     request.setAttribute("myForm", myForm);
> > >
> > >
> > > Hubert
> > >
> > >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to