I am definitely using session scope.

Struts-config snippet:

  <action path="/productSetUpdate"
    type="com.mycompany.ecom.struts.product.ProductAction"
    name="productSetForm"
    scope="session"
    validate="false"
    parameter="productSetUpdate">
      <forward name="success" path="ecom.admin.product.set.update.page"/>
  </action>
  <action path="/productSetUpdateSubmit"
    type="com.mycompany.ecom.struts.product.ProductAction"
    name="productSetForm"
    scope="session"
    validate="false"
    input="ecom.admin.product.set.update.page"
    parameter="productSetUpdateSubmit">
      <forward name="success" path="/productSetsList.do"/>
  </action>

Action snippet:

    private ActionForward doProductSetUpdate(ActionMapping mapping,
ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws
Exception {
        log.debug(":doProductSetUpdate");
        HttpSession session = request.getSession();
        // get productSetID from parameter
        String productSetIDstr = request.getParameter("productSetID");
        int productSetID = ((productSetIDstr == null) ? 0 :
Integer.parseInt(productSetIDstr));
        // get set
        ProductBD productBD = new ProductBD();
        ProductSetWithItems setWithItems =
productBD.findSetByIDWithItems(productSetID);
        // save set in session
        session.setAttribute("productSetWithItems", setWithItems);
        // update form
        ProductSetForm productSetForm = (ProductSetForm) form;
        BeanUtils.copyProperties(productSetForm, setWithItems);
        // Forward control to the success URI specified in struts-config.xml
        return (mapping.findForward("success"));
    }

Does BeanUtils.copyProperties do a shallow or deep copy? Also, it is copying
from an ArrayList to a Collection.

Wiebe

-----Original Message-----
From: Michael Jouravlev [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 09, 2005 11:18 AM
To: Struts Users Mailing List
Subject: Re: Nested error

It was initialized when JSP was prepared, then response was returned
to the browser. If you use formbean with request scope, it is gone.
When you hit the submit button, you initiate new request, it which the
form is recreated, and this field may not be initialized.

So, the fact that you were able to render a page means nothing, if you
use request scope for formbean. Use session scope or reinitialize
formbean each time. Caution: if you use request scope, then reset()
may be not called (not sure on that), so initialize the form in the
consructor.

Michael.

On 9/9/05, Wiebe de Jong <[EMAIL PROTECTED]> wrote:
> Michael,
> 
> The collection was initialized. In fact, it had several items in it and
the
> form had successfully displayed, as I mentioned.
> 
> The error occurs when I hit the submit button, whether I changed any
values
> or not.
>
>>   <nested:iterate property="items"
>>   ...
>>   IndexOutOfBoundsException: Index: 0, Size: 0
>>   ...
>>   private Collection items; <--- null

---------------------------------------------------------------------
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