Thanks Eddie,
  I probably should have split the form bean into 2 beans:  one for the
array property and one for the "other" properties.  I need to send all
that data to the client because the JSP page includes 2 forms for
editing these two groups of properties.  The backend data is accessed
via a bean that I wrap in my form bean to allow me to use Integer
instead of int and to allow me to implement Serializable, etc.  I guess
I went with my first instinct, which was to represent the data with a
single form bean that looks very similar to the JSR-88 descriptor bean
that represents the data... looking back on it, there was nothing to
stop me from splitting the data up into 2 forms in order to fit the UI.

  Thanks for the response, it got me thinking about my design.  It would
have made sense for me think more about my UI requirements than the
shape of the data on the backend when I created my form bean(s).

-------------------
Ture Hoefner
WebLogic Portal Engineering
BEA Systems, Inc.


-----Original Message-----
From: Eddie O'Neil [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 15, 2006 1:18 AM
To: Beehive Users
Subject: Re: Hidden databinding to array properties

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.persistedEve
ntTypes[0]}" value="AddToCartEvent">
>
>         <input type="hidden"
name="serviceAdminBehaviorTrackingDetailsPortlet{actionForm.persistedEve
ntTypes[1]}" value="BuyEvent">
>
>         ...
>
>         ...
>
>         ...
>
>         <input type="hidden"
name="serviceAdminBehaviorTrackingDetailsPortlet{actionForm.persistedEve
ntTypes[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
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Reply via email to