Ture--
Good question -- this isn't something that's covered very well in
the documentation. Unless you're using a Page Flow scoped form bean,
the data from a POST is being applied to a new form bean instance. As
such, any array / list data structures are empty; to create them, you
can extend the Struts form bean and allocate them in the "reset()"
method.
To date, this behavior is intentional -- the expression language
prevents doing something "unexpected" which means adding an item past
the capacity of either the array or past the size of the list.
One question is why the data needs to be sent to the client at all?
Why not just keep it locally or store it in the session and pick it up
when the form POSTs?
Hope that helps.
Eddie
On 2/6/06, Ture Hoefner <[EMAIL PROTECTED]> wrote:
>
>
>
> Hello,
>
> I have a problem in which I have a pageflow with a form bean that has
> several properties, one of which is an array: String[]. In a form on my JSP
> I use databinding to allow the user to edit every property EXCEPT that array
> property. It is edited on a separate form. I tried to use hidden inputs to
> databind to the String[] property so it won't be null in the form bean passed
> to the edit action in my pageflow:
>
>
>
> <netui-data:repeater dataSource="actionForm.persistedEventTypes">
>
> <netui-data:repeaterItem>
>
> <netui:hidden dataSource="container.item" />
>
> </netui-data:repeaterItem>
>
> </netui-data:repeater>
>
>
>
> It looks good in the generated HTML source:
>
> <input type="hidden"
> name="serviceAdminBehaviorTrackingDetailsPortlet{actionForm.persistedEventTypes[0]}"
> value="AddToCartEvent">
>
> <input type="hidden"
> name="serviceAdminBehaviorTrackingDetailsPortlet{actionForm.persistedEventTypes[1]}"
> value="BuyEvent">
>
> …
>
> …
>
> …
>
> <input type="hidden"
> name="serviceAdminBehaviorTrackingDetailsPortlet{actionForm.persistedEventTypes[15]}"
> value="UserRegistrationEvent">
>
>
>
>
>
>
>
> During databinding, I get an ArrayIndexOutOfBoundsException because it thinks
> the array is empty. I tried a few experiments: I changed the String[] to a
> List<String> in my get/set methods in my bean and see basically the same
> problem:
>
>
>
> [exec] [ERROR] ProcessPopulate - NetUI Warning: Unable to update
> expression
>
> "{actionForm.persistedEventTypes[15]}". The typical cause is that the
> object represented by the expression is not available or is the wrong type
> for updating.
>
> Cause: org.apache.beehive.netui.script.ExpressionUpdateException: Exception
> when attempting to update the expression
> "{actionForm.persistedEventTypes[15]}" with available binding contexts
> [actionForm, pageFlow, globalApp]. Root cause: java.lang.RuntimeException: An
> error occurred setting a value at index "15" because the list is of size 0.
> Be sure to allocate enough items in the List to accomodate any updates which
> may occur against the list.
>
>
>
> For now, I am going to work around it by not using databinding for this
> property. Am I doing something wrong, or is this a bug?
>
>
>
> Thanks.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Ture Hoefner
> WebLogic Portal Engineering
>
>
>
>
> BEA Systems, Inc.
> 4001 Discovery Drive
>
>
> Suite 340
> Boulder, CO 80303
> www.bea.com
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>