I have had (and continue to have) a similar problem.
It seems that the reset() is called prior to populating your form and then
is populated using java reflection and the submit parameters/attributes.
So...it seems that if the arrays are not initialized to correct lengths upon
form construction or reset, they will not get created and/or populated.
I have yet to find a nice solution to this.

-----Original Message-----
From: MarwanSalam <[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 12, 2003 6:34 PM
To: [EMAIL PROTECTED]
Subject: Re: posting an updated collection back to Action


Hi,

I looked at all your the responses to this thread and then looked at 
Ted Husted's "Struts Tip #6 - Use an array to capture multiple 
parameters" to solve my problem.
However, I still have some problems when I submit my changes(even if 
I don't change anything).

My ActionForm looks like this:
    private String[] orderLineNumber = null;
    private String[] quantityShipped = null;
    private String[] quantityCancelled = null;

with setters and getters for these attributes. In the ActionForm 
constructor there is nothing to initialize the arrays.

After submitting the form, I am trying to access these arrays in the 
Action class like this:
String[] lineNumber = (UpdateForm)form.getOrderLineNumber();

and I get a java.lang.NullPointerException on this exact line.

My JSP looks like this:
<%List orderDetailList=(List)session.getAttribute(Constants.ORDERS);%>
<code>
<form action="updateOrder.do" method="post">
 <logic:iterate id="orderDetail" name="orderDetailList">
  <td><bean:write name="orderDetail" property="orderLineNumber"</td>
  <td><html:text name="orderDetail" property="quantityShipped" /></td>
  <td><html:text name="orderDetail"property="quantityCancelled"/></td>
 </logic:iterate>
 <input type="submit" value"Update">
</form>
</code>


This is still not working. The lines in the JSP are objects and not 
Strings. My JSP is retrieving a collection of these objects to 
display in a grid as you see above. Can I have these objects in my 
ActionForm instead of defining arrays for each column in the JSP? All 
I need to do is retrieve the grid of data from the JSP to my Action 
class with one submit button. That's all.

Thanks,
Marwan



--- In [EMAIL PROTECTED], "John Espey" <[EMAIL PROTECTED]> wrote:
> You can create indexed properties (   getOrderDetail(int),
> setOrderDetail(int, string)  )
> You have to back them whatever way you see fit (I've used arrays in 
the past
> but I had to make sure they were sized propertly on each call).  On 
your
> JSP, the resulting names for your input fields will need to be 
indexed:
> <html:text name="orderDetail" property="quantityShipped
[${index}]"/> will
> work if you are using the EL version of the html taglib. (Although 
I'm not
> sure the name property has to be specified if you use the html:form 
tag
> instead of the form tag as you've shown here)
> 
> 
> 
> 
> -----Original Message-----
> From: MarwanSalam <[EMAIL PROTECTED]> [mailto:marwansalam@y...]
> Sent: Monday, February 10, 2003 5:46 PM
> To: [EMAIL PROTECTED]
> Subject: posting an updated collection back to Action
> 
> 
> Hi,
> 
> I have a list of line items displayed in a JSP where some of the
> attributes can be edited. I would like to capture the updated data 
by
> the user to return it to my Action class so I can modify my model
> accordingly.
> 
> Here is my JSP code:
> 
> <form action="updateOrder.do" method="post">
>   <input type="hidden" name="action" value="updateOrder">
>   <logic:iterate id="orderDetail" type="OrderDetailModel"
>                  collection="<%= orderDetailList %>">
>    <td><html:text name="orderDetail" 
property="quantityShipped"/></td>
>   </logic:iterate>
>   <input type="submit" value"Update Order">
> </form>
> 
> I know my ActionForm class has to have a property called
> orderDetailList. But the question is, how will the correct index be
> updated since my list can contain many OrderDetailModel's? Should I
> add a method in my ActionForm class like getOrderDetailList.get
> (index)? Help!!!
> 
> 
> --------------------------------------------------------------------
-
> 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]


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