struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Alfors" <peter.alf...@hksystems.com>
Subject Re: pre-populate and request scope problem in struts.
Date Tue, 21 Aug 2001 18:30:30 GMT

I assume that your select tag is expecting to get data from your form object that you had
previously placed into the request?
When you return to the 'toJsp' page, you will need to place the form object back into the
request, or place the form object in the session in the first place.
When you say that your edit command returns to the previous page, is it going through an
action?  If so, you would want to place the form back into the request there
(if you do not want to use the session).

Pete

However, I would suggest that

BinhMinh Nguyen wrote:

> Hi,
> I have the following problem, can anyone help me to
> spot it.
>
> I am using the following technique for pre-populate:
>
> 1- in the Action object   of 'fromJSP' , I create an
> objetc of the Form objetc of the 'toJSP'
> 2-I then set all the properties  of the Form objetc of
> the 'toJSP' here by calling the setters of this Form
> object. As followed:
>
> Partner partner = new Partner(tradingID,
> fnDataSource);
>                                         //get the product-list from a given partner
>                                         String[] products = partner.getProducts();
>
>                                         //pre=populating
>                                         System.out.println("<RetailerMainAction>-
> Data-Pre-Populating for form processForm");
>                                         ProcessForm processForm = new ProcessForm();
>
>                                         processForm.setProducts(products);
>                                         System.out.println("<RetailerMainAction>-
set
> product-collection");
>
>                                         processForm.setTradingID(tradingID);
>                                         System.out.println("<RetailerMainAction>-
set
> partner-ID");
>
>                                         request.setAttribute("processForm",processForm);
>
> //the_session.setAttribute("processForm",processForm);
>                                         System.out.println("<RetailerMainAction>-
save
> processForm bean");
>
> 3- set the Form object to the request scope.
>                                 request.setAttribute("processForm",processForm);
>
>
> 4- then I give out the 'toJSP'
>
> so far, every works perfectly. All the properies are
> preloaded as expected.
>
> <P>
> <font color="green" size="+2">
>    Trading ID&nbsp;<bean:write  name="processForm"
> property="tradingID" scope="request"
> />(<%=user_name%>)
> </font>
>
> <hr>
> <table border="0" width="100%">
> <tr><td colspan="2">&nbsp;</td></tr>
> <tr>
>
>     <td align="left" width="10%">
>        Product-Line:&nbsp;&nbsp;
>     </td>
>
>     <td align="left">
>        <html:select property="selProduct" size="1" >
>             <html:options property="products" />
>        </html:select>
>
>     </td>
> </tr>
>
> 5- then in the 'toJSP' I issue a command submit to g
> oto the 'lastJSP'. The action forward the request is
> defined in strut-config.xml as below:
>
> <!-- Order -->
>      <action     path="/main/order/order"
>
> type="com.furnishnet.struts.OrderAction"
>                  name="orderForm"
>                  input="/main/order/order_screen.jsp"
>                  scope="request"
>                  validate="false">
>
>                 <forward  name="confirm"
> path="/main/order/order_screen.jsp"/>
>                 <forward  name="process_edit"
> path="/main/operation/process_screen.jsp" />
>
>
>      </action>
>
> In this 'lastJSP'   I have the button "Edit" which
> bring the user back to the previous JSP, 'toJSP'.
> But the serlvet raised an exception. There is
> something wrong with the <select> tag and <option>
> tag,
> if I remove these tag from the JSP, before I
> "come-back"  to this 'toJSP', nothing worng happens,
> therefor, there must be something wrong with this
> property and the Form that I save off the attribute
>
> Can some one spot it out for me please.
>
> really appreciate you help
>
> Binh Nguyen
>
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/


Mime
View raw message