Well the lazy beans themselves look easy to work with, but I have to
write code that converts the lazy beans to regular dynabeans (and back).
My normal dynabeans have extra fields in them to do things like specify
the correct table to save a bean to, and also formatting options for
beans going to and from the database (for example to convert Date fields
correctly from a user viewable to database workable form going in and
out automatically).

Nathan

-----Original Message-----
From: Takhar, Sandeep [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 21, 2004 1:53 PM
To: Struts Users Mailing List
Subject: RE: Creating an indexed property of DynaActionForms

I don't think using the lazy beans is a bad approach and if you look at
the code, there is very little of it.

I got half way to implementing the approach, but the piece I was
building was shut down so I don't know how effective it is.

sandeep

-----Original Message-----
From: Nathan Ewing [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 21, 2004 1:48 PM
To: Struts Users Mailing List
Subject: RE: Creating an indexed property of DynaActionForms


I briefly toyed with the idea of trying to fix the flaw myself, but I
looked at the struts source code and the change would not be a trivial
one.

-----Original Message-----
From: Takhar, Sandeep [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 21, 2004 1:33 PM
To: Struts Users Mailing List
Subject: RE: Creating an indexed property of DynaActionForms

I couldn't think of one.

sandeep

-----Original Message-----
From: Nathan Ewing [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 21, 2004 11:00 AM
To: Struts Users Mailing List
Subject: RE: Creating an indexed property of DynaActionForms


I take it then that there is no way to use normal DynaActionForms.  It
would certainly be a lot simpler. :(

   Nathan

-----Original Message-----
From: Takhar, Sandeep [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 21, 2004 7:44 AM
To: Struts Users Mailing List
Subject: RE: Creating an indexed property of DynaActionForms

Use the lazyValidatorActionForm, which allows you to keep things request
scope when using arrays.

http://www.niallp.pwp.blueyonder.co.uk/

        <form-bean name="SampleMain"
type="org.apache.struts.validator.DynaValidatorForm">
            <form-property name="subForm1" type="java.util.ArrayList"/>
            <form-property name="subForm2" type="java.util.ArrayList"/>
        </form-bean>

Unfortunately I haven't tried this, but am pretty sure it works.


sandeep
-----Original Message-----
From: Nathan Ewing [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 20, 2004 5:49 PM
To: [EMAIL PROTECTED]
Subject: Creating an indexed property of DynaActionForms


I'm trying to figure out how to define and use a DynaActionForm which
has an indexed property that is another DynaActionForm.  I'm using
struts 1.1.  Here is something like what I mean:

        First my sample struts-config.xml
        ----------------------------------
        <form-bean name="SubForm"
type="org.apache.struts.validator.DynaValidatorForm">
                <form-property name="property1"
type="java.lang.String"/>
                <form-property name="property2"
type="java.lang.String"/>
        </form-bean>

        <form-bean name="SampleMain"
type="org.apache.struts.validator.DynaValidatorForm">
            <form-property name="subForm1" type="SubForm[]"/>
            <form-property name="subForm2" type="SubForm[]"/>
        </form-bean>
        
        And the JSP:
        ------------------

        <table>
        <c:forEach var="subForm1" items="${SampleMain.map.subForm1}"
varStatus="status">
                <tr>
                    <td><html:text
property="subForm1[${status.index}].property1" size="5" />

                    <td><html:text
property="subForm1[${status.index}].property2" size="5" />
</tr>
        </c:forEach>
        </table>

Unfortunately this doesn't work.  If I try making the subtypes SubForm[]
like above, I get a NullPointer exception when I try to start the
server, when struts tries to create the DynaForm classes.

If I make the property type Object[], I can successfully populate the
form, but when I try to save it, I get an ArrayOutOfBounds error when
struts tries to create the initial DynaForms (Obviously because it has
no idea what type of form to create, I think).

How do I make this work?

Also, once I start implementing validation on this form, is it going to
be possible to use struts validation to validate the subitems?

        Thanks,
        Nathan


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



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