You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2006/09/22 18:28:01 UTC

Nested form beans

I'm facing a situation where ideally I'd like to have a single ActionForm
like so:

public class MyActionForm extends ActionForm {
  AnotherActionForm1 af1;
  AnotherActionForm2 af2;
}

When in my JSP I do:

<html:text property="af1.field1" />

...I do indeed see the value as I expect.  The way I did this is to have
an Action mapping that references MyActionForm, then within the Action I
instantiate AnotherActionForm1, set the value of field1 on it, and then
set af1 to that new AnotherActionForm1 instance.  That all works nicely.

Here's where I run into a problem...

On the page I basically have 2 separate HTML forms, one for
AnotherActionForm1 and another for AnotherActionForm2.  However, I have a
SINGLE submit button at the end (just plain button that makes an AJAX
request).  onClick of that button, I create a query string from the values
of both forms, and make a request to the server with the query string
attached.  The parameter names of the query string arguments are
af1.field1 and af2.field2, mimicing what's in MyActionForm.  The mapping
that the request goes to again references MyActionForm.

What I've been told should happen is that Struts should be able to
instantiate those two nested beans and set the properties, since the
parameter names give it the information it needs.  This does not however
seem to be happening.

So, two questions... first, is that in fact the expected behavoir?  And
two, if so, any ideas what I'm doing wrong?  I can post all the pertinent
config and code, but thought it might be something more generic that
wouldn't require all that.  This is the first time I've ever had a need to
nest forms like this, so it's a new question for me.

Thanks all!

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Yeah, I'm sure that previous post was confusing :)  tab1Form and tab2Form
are the names of the action forms... I forgot I changed them at one point.
 The code itself all references the proper names.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 2:49 pm, Frank W. Zammetti wrote:
> As a follow-up, I threw some logging in the field1 and field2 setters in
> the subbeans... they don't appear to ever get called.  I don't have to do
> anything special to tell Struts I'm using nested beans, do I?  I didn't
> think so...
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
>> Hi Chris.. thanks for the suggestion, I gave that a shot at one point
>> actually... what I get is now the fields in the subforms (I guess that's
>> as good a term as any!) don't get set...
>>
>> masterForm = app.test.formbeans.MasterForm@141fab6
>> tab1Form = app.test.formbeans.Tab1Form@b301f2
>> tab2Form = app.test.formbeans.Tab2Form@44cbbe
>> field1 = null
>> field2 = null
>>
>> That's what I see in my final JSP output.
>>
>> Frank
>>
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>>  (2006, Apress, ISBN 1-59059-695-1)
>> Java Web Parts - http://javawebparts.sourceforge.net
>>  Supplying the wheel, so you don't have to reinvent it!
>>
>> On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
>>> In your no-arg constructor of your outer ActionForm (the container),
>>> make
>>> sure it instantiates each of the nested ActionForms using their no-arg
>>> constructors.
>>>   (*Chris*)
>>>
>>> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>>
>>>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my
>>>> mistake
>>>> wasn't quite *THAT* obvious! ;) LOL
>>>>
>>>> Frank
>>>>
>>>>
>>>> --
>>>> Frank W. Zammetti
>>>> Founder and Chief Software Architect
>>>> Omnytex Technologies
>>>> http://www.omnytex.com
>>>> AIM/Yahoo: fzammetti
>>>> MSN: fzammetti@hotmail.com
>>>> Author of "Practical Ajax Projects With Java Technology"
>>>> (2006, Apress, ISBN 1-59059-695-1)
>>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>> Supplying the wheel, so you don't have to reinvent it!
>>>>
>>>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>>>> > Hi Hubert,
>>>> >
>>>> > Yes, I get nulls for af1 and af2... I do have getters and setters
>>>> for
>>>> > them.
>>>> >
>>>> > Lemme throw some data your way... I was hoping to avoid posting all
>>>> this,
>>>> > but I suspect there to be something my eyes just aren't catching,
>>>> so...
>>>> >
>>>> >
>>>> > Here's ActionForm1:
>>>> >
>>>> >
>>>> > package app.test.formbeans;
>>>> > import org.apache.struts.action.ActionForm;
>>>> > public class Action1Form extends ActionForm {
>>>> >   private String field1;
>>>> >   public void setField1(String inField1) {
>>>> >     this.field1 = inField1;
>>>> >   }
>>>> >   public String getField1() {
>>>> >     return this.field1;
>>>> >   }
>>>> > }
>>>> >
>>>> >
>>>> > ActionForm2 is identical, just replacing the number 1 with 2
>>>> everywhere.
>>>> > Here's MasterForm:
>>>> >
>>>> >
>>>> > package app.test.formbeans;
>>>> > import org.apache.struts.action.ActionForm;
>>>> > public class MasterForm extends ActionForm {
>>>> >   public Action1Form action1Form;
>>>> >   public Action2Form action2Form;
>>>> >   public void setAction1Form(Action1Form inAction1Form) {
>>>> >     this.action1Form = inAction1Form;
>>>> >   }
>>>> >   public Action1Form getAction1Form() {
>>>> >     return this.action1Form;
>>>> >   }
>>>> >   public void setAction2Form(Action2Form inAction2Form) {
>>>> >     this.action2Form = inAction2Form;
>>>> >   }
>>>> >   public Action2Form getAction2Form() {
>>>> >     return this.action2Form;
>>>> >   }
>>>> > }
>>>> >
>>>> >
>>>> > The Action everything gets submitted to is just a ForwardAction,
>>>> which
>>>> > forwards to:
>>>> >
>>>> >
>>>> > <%@ page language="java" import="app.test.formbeans.*" %>
>>>> > <%
>>>> >   MasterForm masterForm =
>>>> (MasterForm)request.getAttribute("masterForm");
>>>> > %>
>>>> > <%="masterForm = " + masterForm + "<br>"%>
>>>> > <%
>>>> >   Tab1Form tab1Form = null;
>>>> >   Tab2Form tab2Form = null;
>>>> >   if (masterForm != null) {
>>>> >     tab1Form = masterForm.getTab1Form();
>>>> >     tab2Form = masterForm.getTab2Form();
>>>> >   }
>>>> > %>
>>>> > <%="tab1Form = " + tab1Form + "<br>"%>
>>>> > <%="tab2Form = " + tab2Form + "<br>"%>
>>>> > <% if (tab1Form != null) { %>
>>>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>>>> > <% } %>
>>>> > <% if (tab2Form != null) { %>
>>>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>>>> > <% } %>
>>>> >
>>>> >
>>>> > The result I see from this is:
>>>> >
>>>> >
>>>> > masterForm = app.test.formbeans.MasterForm@e3849c
>>>> > tab1Form = null
>>>> > tab2Form = null
>>>> >
>>>> >
>>>> > The page that does that submit, in its final rendered form on the
>>>> client
>>>> > is:
>>>> >
>>>> >
>>>> > <html>
>>>> > <head>
>>>> >   <script>
>>>> >     var finalSubmit = null;
>>>> >     function getXHR() {
>>>> >       if (window.XMLHttpRequest) {
>>>> >         return new XMLHttpRequest();
>>>> >       } else if (window.ActiveXObject) {
>>>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>>>> >       }
>>>> >     }
>>>> >     function submitAll() {
>>>> >       var tab1Form = dojo.io.encodeForm(
>>>> >         document.getElementById("tab1Form"));
>>>> >       var tab2Form = dojo.io.encodeForm(
>>>> >         document.getElementById("tab2Form"));
>>>> >       finalSubmit = getXHR();
>>>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>>>> >       finalSubmit.open("POST", "final.do", true);
>>>> >       finalSubmit.send(tab1Form + tab2Form);
>>>> >     }
>>>> >     function finalSubmitCallback() {
>>>> >       if (finalSubmit.readyState == 4) {
>>>> >         document.getElementById("divResult").innerHTML =
>>>> > finalSubmit.responseText;
>>>> >       }
>>>> >     }
>>>> >   </script>
>>>> > </head>
>>>> > <body onload="init();">
>>>> >   <form name="masterForm" id="tab1Form" method="post"
>>>> > action="/test/tab1.do">
>>>> >     Field1: <input name="tab1Form.field1" value="val1"
>>>> type="text"><br>
>>>> >   </form>
>>>> >   <br>
>>>> >   <form name="masterForm" id="tab2Form" method="post"
>>>> > action="/test/tab2.do">
>>>> >     Field2: <input name="tab2Form.field2" value="val2"
>>>> type="text"><br>
>>>> >   </form>
>>>> >   <br>
>>>> >   <input value="Submit All" onclick="submitAll();" type="button">
>>>> >   <br><br>
>>>> >   <div id="divResult"></div>
>>>> > </body>
>>>> > </html>
>>>> >
>>>> >
>>>> > Note that I removed all the Dojo-related stuff, and some stuff that
>>>> isn't
>>>> > related to this submissino, just to try and keep it small, but, the
>>>> > important thing to note is that when the submission is made, the
>>>> request
>>>> > that goes across is a POST to http://localhost:8080/test/final.do,
>>>> as
>>>> > expected, and the POST body is:
>>>> >
>>>> > tab1Form.field1=val1&tab2Form.field2=val2&
>>>> >
>>>> > ...also as expected, verified in Firebug.  Lastly, here's
>>>> struts-config:
>>>> >
>>>> >
>>>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>>>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
>>>> Struts
>>>> > Configuration 1.2//EN"
>>>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>>>> > <struts-config>
>>>> >   <form-beans>
>>>> >     <form-bean name="masterForm"
>>>> type="app.test.formbeans.MasterForm"
>>>> />
>>>> >   </form-beans>
>>>> >   <action-mappings>
>>>> >     <action path="/final" type="app.test.actions.FinalAction"
>>>> > name="masterForm" scope="request" validate="false">
>>>> >       <forward name="defaultForward" path="/final.jsp" />
>>>> >     </action>
>>>> >   </action-mappings>
>>>> > </struts-config>
>>>> >
>>>> >
>>>> > Note here that I removed the stuff that generated the markup from
>>>> above
>>>> > too, since that seems to be working just fine, I'm pretty sure this
>>>> is
>>>> all
>>>> > that would be relevant.
>>>> >
>>>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>>>> >
>>>> > Frank
>>>> >
>>>> >
>>>> > --
>>>> > Frank W. Zammetti
>>>> > Founder and Chief Software Architect
>>>> > Omnytex Technologies
>>>> > http://www.omnytex.com
>>>> > AIM/Yahoo: fzammetti
>>>> > MSN: fzammetti@hotmail.com
>>>> > Author of "Practical Ajax Projects With Java Technology"
>>>> >  (2006, Apress, ISBN 1-59059-695-1)
>>>> > Java Web Parts - http://javawebparts.sourceforge.net
>>>> >  Supplying the wheel, so you don't have to reinvent it!
>>>> >
>>>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>>>> >> So what does happen when you submit the form?  Are you getting
>>>> NPEs?
>>>> >>
>>>> >> By the time Struts attempts to populate the form bean, the nested
>>>> >> forms should already be instantiated.  You should have getters and
>>>> >> setters for af1 and af2, and getAf1() and getAf2() should not
>>>> return
>>>> a
>>>> >> null.  This could be an issue if the form bean is new, either
>>>> because
>>>> >> it's in request scope, or in session scope but was not previously
>>>> >> instantiated.
>>>> >>
>>>> >> Hubert
>>>> >>
>>>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>> >>> I'm facing a situation where ideally I'd like to have a single
>>>> >>> ActionForm
>>>> >>> like so:
>>>> >>>
>>>> >>> public class MyActionForm extends ActionForm {
>>>> >>>   AnotherActionForm1 af1;
>>>> >>>   AnotherActionForm2 af2;
>>>> >>> }
>>>> >>>
>>>> >>> When in my JSP I do:
>>>> >>>
>>>> >>> <html:text property="af1.field1" />
>>>> >>>
>>>> >>> ...I do indeed see the value as I expect.  The way I did this is
>>>> to
>>>> >>> have
>>>> >>> an Action mapping that references MyActionForm, then within the
>>>> Action
>>>> >>> I
>>>> >>> instantiate AnotherActionForm1, set the value of field1 on it, and
>>>> then
>>>> >>> set af1 to that new AnotherActionForm1 instance.  That all works
>>>> >>> nicely.
>>>> >>>
>>>> >>> Here's where I run into a problem...
>>>> >>>
>>>> >>> On the page I basically have 2 separate HTML forms, one for
>>>> >>> AnotherActionForm1 and another for AnotherActionForm2.  However, I
>>>> have
>>>> >>> a
>>>> >>> SINGLE submit button at the end (just plain button that makes an
>>>> AJAX
>>>> >>> request).  onClick of that button, I create a query string from
>>>> the
>>>> >>> values
>>>> >>> of both forms, and make a request to the server with the query
>>>> string
>>>> >>> attached.  The parameter names of the query string arguments are
>>>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
>>>> >>> mapping
>>>> >>> that the request goes to again references MyActionForm.
>>>> >>>
>>>> >>> What I've been told should happen is that Struts should be able to
>>>> >>> instantiate those two nested beans and set the properties, since
>>>> the
>>>> >>> parameter names give it the information it needs.  This does not
>>>> >>> however
>>>> >>> seem to be happening.
>>>> >>>
>>>> >>> So, two questions... first, is that in fact the expected
>>>> behavoir?  And
>>>> >>> two, if so, any ideas what I'm doing wrong?  I can post all the
>>>> >>> pertinent
>>>> >>> config and code, but thought it might be something more generic
>>>> that
>>>> >>> wouldn't require all that.  This is the first time I've ever had a
>>>> need
>>>> >>> to
>>>> >>> nest forms like this, so it's a new question for me.
>>>> >>>
>>>> >>> Thanks all!
>>>> >>>
>>>> >>> Frank
>>>> >>>
>>>> >>>
>>>> >>> --
>>>> >>> Frank W. Zammetti
>>>> >>> Founder and Chief Software Architect
>>>> >>> Omnytex Technologies
>>>> >>> http://www.omnytex.com
>>>> >>> AIM/Yahoo: fzammetti
>>>> >>> MSN: fzammetti@hotmail.com
>>>> >>> Author of "Practical Ajax Projects With Java Technology"
>>>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>>>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>>>> >>>  Supplying the wheel, so you don't have to reinvent it!
>>>> >>>
>>>> >>> ---------------------------------------------------------------------
>>>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >>> For additional commands, e-mail: user-help@struts.apache.org
>>>> >>>
>>>> >>>
>>>> >>
>>>> >> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >> For additional commands, e-mail: user-help@struts.apache.org
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> > ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> > For additional commands, e-mail: user-help@struts.apache.org
>>>> >
>>>> >
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Got it... had to explicitly set the Content-Type of the request to
application/x-www-form-urlencoded on the XMLHttpRequest object.  Didn't
even occur to me because I set the method to POST, didn't even consider
that might not be sufficient.  Weird thing is, I know I have code where I
POST but don't set the header and it works, not sure why these nested
names would be different.

Well, should it come up for anyone else, there you go :)

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 4:48 pm, Frank W. Zammetti wrote:
> Quick update: it has something to do with the fact that its an AJAX
> request at the end... or because its a POST, one or the other... I built a
> URL with the parameters as a query string, and it worked fine... I don't
> know what it is yet yet, exploring now... the request looks identical
> aside from method, which shouldn't matter, AFAIKT, but something is
> obviously bad with it... will let you know when I figure it out...
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> On Fri, September 22, 2006 4:35 pm, Jiang, Peiyun wrote:
>> Can you just use simple objects in the form?
>>
>> public class MyActionForm extends ActionForm {
>>     AnotherActionForm1 af1;
>>     AnotherActionForm2 af2;
>>
>>   MyActionForm() {
>>     af1 = new SimpleObject1AsAnotherActionForm1();
>>     af2 = new SimpleObject2AsAnotherActionForm2();
>>   }
>> }
>>
>> Access:
>> <%= masterForm.af1.field1 %>
>>
>> Peiyun
>>
>> -----Original Message-----
>> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
>> Sent: September 22, 2006 4:23 PM
>> To: Struts Users Mailing List
>> Cc: Struts Users Mailing List
>> Subject: Re: Nested form beans
>>
>>
>> On Fri, September 22, 2006 3:59 pm, Hubert Rabago wrote:
>>> I can't see anything that would cause your problem.
>>> I guess if it were me, I'd fire up my debugger and start stepping
>>> through some code.
>>> Sorry.
>>
>> Yeah, that's the next step.  Was hoping to avoid it with an easy answer,
>> but that's the way it goes sometimes :)
>>
>>> All I can say at this point is that I know what you're doing is
>>> possible cause that's how FormDef does nested beans.
>>
>> Actually, that's a pretty big help in and of itself... I wasn't frankly
>> aware the subbeans would get populated, so knowing it *should* work at
>> least means I'm not on a wild goose chase.  Thanks for the effort, I
>> definitely appreciate it!
>>
>>> Hubert
>>
>> Frank
>>
>>> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>> Hehe, way ahead of you :)  I put logging in every method...
>>>> constructors,
>>>> getters setter, all three forms.  Here's the output:
>>>>
>>>> MasterForm constructor
>>>> Tab1Form constructor
>>>> Tab2Form constructor
>>>> --NOW IN JSP--
>>>> MasterForm getTab1Form() = app.test.formbeans.Tab1Form@8ab08f
>>>> MasterForm getTab2Form() = app.test.formbeans.Tab2Form@14d921a
>>>> getting field1 = null
>>>> getting field2 = null
>>>>
>>>> Notice the fields don't get set, nor do the subbeans get set on the
>>>> containing bean.  The MasterForm constructor instantiates Tab1Form and
>>>> Tab2Form, as the output indicates.
>>>>
>>>> Frank
>>>>
>>>>
>>>> --
>>>> Frank W. Zammetti
>>>> Founder and Chief Software Architect
>>>> Omnytex Technologies
>>>> http://www.omnytex.com
>>>> AIM/Yahoo: fzammetti
>>>> MSN: fzammetti@hotmail.com
>>>> Author of "Practical Ajax Projects With Java Technology"
>>>>  (2006, Apress, ISBN 1-59059-695-1)
>>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>>  Supplying the wheel, so you don't have to reinvent it!
>>>>
>>>> On Fri, September 22, 2006 2:53 pm, Hubert Rabago wrote:
>>>> > It still sounds like Struts is getting nulls for the subbeans when
>>>> it
>>>> > tries to populate subbean.fieldX.  Put some more logging, this time
>>>> in
>>>> > the getters for the subbean in MasterForm, and log what it's
>>>> > returning.
>>>> >
>>>> > Hubert
>>>> >
>>>> > On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>> >> As a follow-up, I threw some logging in the field1 and field2
>>>> setters
>>>> in
>>>> >> the subbeans... they don't appear to ever get called.  I don't have
>>>> to
>>>> >> do
>>>> >> anything special to tell Struts I'm using nested beans, do I?  I
>>>> didn't
>>>> >> think so...
>>>> >>
>>>> >> Frank
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Frank W. Zammetti
>>>> >> Founder and Chief Software Architect
>>>> >> Omnytex Technologies
>>>> >> http://www.omnytex.com
>>>> >> AIM/Yahoo: fzammetti
>>>> >> MSN: fzammetti@hotmail.com
>>>> >> Author of "Practical Ajax Projects With Java Technology"
>>>> >>  (2006, Apress, ISBN 1-59059-695-1)
>>>> >> Java Web Parts - http://javawebparts.sourceforge.net
>>>> >>  Supplying the wheel, so you don't have to reinvent it!
>>>> >>
>>>> >> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
>>>> >> > Hi Chris.. thanks for the suggestion, I gave that a shot at one
>>>> point
>>>> >> > actually... what I get is now the fields in the subforms (I guess
>>>> >> that's
>>>> >> > as good a term as any!) don't get set...
>>>> >> >
>>>> >> > masterForm = app.test.formbeans.MasterForm@141fab6
>>>> >> > tab1Form = app.test.formbeans.Tab1Form@b301f2
>>>> >> > tab2Form = app.test.formbeans.Tab2Form@44cbbe
>>>> >> > field1 = null
>>>> >> > field2 = null
>>>> >> >
>>>> >> > That's what I see in my final JSP output.
>>>> >> >
>>>> >> > Frank
>>>> >> >
>>>> >> >
>>>> >> > --
>>>> >> > Frank W. Zammetti
>>>> >> > Founder and Chief Software Architect
>>>> >> > Omnytex Technologies
>>>> >> > http://www.omnytex.com
>>>> >> > AIM/Yahoo: fzammetti
>>>> >> > MSN: fzammetti@hotmail.com
>>>> >> > Author of "Practical Ajax Projects With Java Technology"
>>>> >> >  (2006, Apress, ISBN 1-59059-695-1)
>>>> >> > Java Web Parts - http://javawebparts.sourceforge.net
>>>> >> >  Supplying the wheel, so you don't have to reinvent it!
>>>> >> >
>>>> >> > On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
>>>> >> >> In your no-arg constructor of your outer ActionForm (the
>>>> container),
>>>> >> >> make
>>>> >> >> sure it instantiates each of the nested ActionForms using their
>>>> >> no-arg
>>>> >> >> constructors.
>>>> >> >>   (*Chris*)
>>>> >> >>
>>>> >> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>> >> >>>
>>>> >> >>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2...
>>>> my
>>>> >> >>> mistake
>>>> >> >>> wasn't quite *THAT* obvious! ;) LOL
>>>> >> >>>
>>>> >> >>> Frank
>>>> >> >>>
>>>> >> >>>
>>>> >> >>> --
>>>> >> >>> Frank W. Zammetti
>>>> >> >>> Founder and Chief Software Architect
>>>> >> >>> Omnytex Technologies
>>>> >> >>> http://www.omnytex.com
>>>> >> >>> AIM/Yahoo: fzammetti
>>>> >> >>> MSN: fzammetti@hotmail.com
>>>> >> >>> Author of "Practical Ajax Projects With Java Technology"
>>>> >> >>> (2006, Apress, ISBN 1-59059-695-1)
>>>> >> >>> Java Web Parts - http://javawebparts.sourceforge.net
>>>> >> >>> Supplying the wheel, so you don't have to reinvent it!
>>>> >> >>>
>>>> >> >>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>>>> >> >>> > Hi Hubert,
>>>> >> >>> >
>>>> >> >>> > Yes, I get nulls for af1 and af2... I do have getters and
>>>> setters
>>>> >> for
>>>> >> >>> > them.
>>>> >> >>> >
>>>> >> >>> > Lemme throw some data your way... I was hoping to avoid
>>>> posting
>>>> >> all
>>>> >> >>> this,
>>>> >> >>> > but I suspect there to be something my eyes just aren't
>>>> catching,
>>>> >> >>> so...
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > Here's ActionForm1:
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > package app.test.formbeans;
>>>> >> >>> > import org.apache.struts.action.ActionForm;
>>>> >> >>> > public class Action1Form extends ActionForm {
>>>> >> >>> >   private String field1;
>>>> >> >>> >   public void setField1(String inField1) {
>>>> >> >>> >     this.field1 = inField1;
>>>> >> >>> >   }
>>>> >> >>> >   public String getField1() {
>>>> >> >>> >     return this.field1;
>>>> >> >>> >   }
>>>> >> >>> > }
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > ActionForm2 is identical, just replacing the number 1 with 2
>>>> >> >>> everywhere.
>>>> >> >>> > Here's MasterForm:
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > package app.test.formbeans;
>>>> >> >>> > import org.apache.struts.action.ActionForm;
>>>> >> >>> > public class MasterForm extends ActionForm {
>>>> >> >>> >   public Action1Form action1Form;
>>>> >> >>> >   public Action2Form action2Form;
>>>> >> >>> >   public void setAction1Form(Action1Form inAction1Form) {
>>>> >> >>> >     this.action1Form = inAction1Form;
>>>> >> >>> >   }
>>>> >> >>> >   public Action1Form getAction1Form() {
>>>> >> >>> >     return this.action1Form;
>>>> >> >>> >   }
>>>> >> >>> >   public void setAction2Form(Action2Form inAction2Form) {
>>>> >> >>> >     this.action2Form = inAction2Form;
>>>> >> >>> >   }
>>>> >> >>> >   public Action2Form getAction2Form() {
>>>> >> >>> >     return this.action2Form;
>>>> >> >>> >   }
>>>> >> >>> > }
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > The Action everything gets submitted to is just a
>>>> ForwardAction,
>>>> >> >>> which
>>>> >> >>> > forwards to:
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > <%@ page language="java" import="app.test.formbeans.*" %>
>>>> >> >>> > <%
>>>> >> >>> >   MasterForm masterForm =
>>>> >> >>> (MasterForm)request.getAttribute("masterForm");
>>>> >> >>> > %>
>>>> >> >>> > <%="masterForm = " + masterForm + "<br>"%>
>>>> >> >>> > <%
>>>> >> >>> >   Tab1Form tab1Form = null;
>>>> >> >>> >   Tab2Form tab2Form = null;
>>>> >> >>> >   if (masterForm != null) {
>>>> >> >>> >     tab1Form = masterForm.getTab1Form();
>>>> >> >>> >     tab2Form = masterForm.getTab2Form();
>>>> >> >>> >   }
>>>> >> >>> > %>
>>>> >> >>> > <%="tab1Form = " + tab1Form + "<br>"%>
>>>> >> >>> > <%="tab2Form = " + tab2Form + "<br>"%>
>>>> >> >>> > <% if (tab1Form != null) { %>
>>>> >> >>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>>>> >> >>> > <% } %>
>>>> >> >>> > <% if (tab2Form != null) { %>
>>>> >> >>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>>>> >> >>> > <% } %>
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > The result I see from this is:
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > masterForm = app.test.formbeans.MasterForm@e3849c
>>>> >> >>> > tab1Form = null
>>>> >> >>> > tab2Form = null
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > The page that does that submit, in its final rendered form on
>>>> the
>>>> >> >>> client
>>>> >> >>> > is:
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > <html>
>>>> >> >>> > <head>
>>>> >> >>> >   <script>
>>>> >> >>> >     var finalSubmit = null;
>>>> >> >>> >     function getXHR() {
>>>> >> >>> >       if (window.XMLHttpRequest) {
>>>> >> >>> >         return new XMLHttpRequest();
>>>> >> >>> >       } else if (window.ActiveXObject) {
>>>> >> >>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>>>> >> >>> >       }
>>>> >> >>> >     }
>>>> >> >>> >     function submitAll() {
>>>> >> >>> >       var tab1Form = dojo.io.encodeForm(
>>>> >> >>> >         document.getElementById("tab1Form"));
>>>> >> >>> >       var tab2Form = dojo.io.encodeForm(
>>>> >> >>> >         document.getElementById("tab2Form"));
>>>> >> >>> >       finalSubmit = getXHR();
>>>> >> >>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>>>> >> >>> >       finalSubmit.open("POST", "final.do", true);
>>>> >> >>> >       finalSubmit.send(tab1Form + tab2Form);
>>>> >> >>> >     }
>>>> >> >>> >     function finalSubmitCallback() {
>>>> >> >>> >       if (finalSubmit.readyState == 4) {
>>>> >> >>> >         document.getElementById("divResult").innerHTML =
>>>> >> >>> > finalSubmit.responseText;
>>>> >> >>> >       }
>>>> >> >>> >     }
>>>> >> >>> >   </script>
>>>> >> >>> > </head>
>>>> >> >>> > <body onload="init();">
>>>> >> >>> >   <form name="masterForm" id="tab1Form" method="post"
>>>> >> >>> > action="/test/tab1.do">
>>>> >> >>> >     Field1: <input name="tab1Form.field1" value="val1"
>>>> >> >>> type="text"><br>
>>>> >> >>> >   </form>
>>>> >> >>> >   <br>
>>>> >> >>> >   <form name="masterForm" id="tab2Form" method="post"
>>>> >> >>> > action="/test/tab2.do">
>>>> >> >>> >     Field2: <input name="tab2Form.field2" value="val2"
>>>> >> >>> type="text"><br>
>>>> >> >>> >   </form>
>>>> >> >>> >   <br>
>>>> >> >>> >   <input value="Submit All" onclick="submitAll();"
>>>> type="button">
>>>> >> >>> >   <br><br>
>>>> >> >>> >   <div id="divResult"></div>
>>>> >> >>> > </body>
>>>> >> >>> > </html>
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > Note that I removed all the Dojo-related stuff, and some
>>>> stuff
>>>> >> that
>>>> >> >>> isn't
>>>> >> >>> > related to this submissino, just to try and keep it small,
>>>> but,
>>>> >> the
>>>> >> >>> > important thing to note is that when the submission is made,
>>>> the
>>>> >> >>> request
>>>> >> >>> > that goes across is a POST to
>>>> http://localhost:8080/test/final.do,
>>>> >> as
>>>> >> >>> > expected, and the POST body is:
>>>> >> >>> >
>>>> >> >>> > tab1Form.field1=val1&tab2Form.field2=val2&
>>>> >> >>> >
>>>> >> >>> > ...also as expected, verified in Firebug.  Lastly, here's
>>>> >> >>> struts-config:
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>>>> >> >>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software
>>>> Foundation//DTD
>>>> >> >>> Struts
>>>> >> >>> > Configuration 1.2//EN"
>>>> >> >>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>>>> >> >>> > <struts-config>
>>>> >> >>> >   <form-beans>
>>>> >> >>> >     <form-bean name="masterForm"
>>>> >> type="app.test.formbeans.MasterForm"
>>>> >> >>> />
>>>> >> >>> >   </form-beans>
>>>> >> >>> >   <action-mappings>
>>>> >> >>> >     <action path="/final" type="app.test.actions.FinalAction"
>>>> >> >>> > name="masterForm" scope="request" validate="false">
>>>> >> >>> >       <forward name="defaultForward" path="/final.jsp" />
>>>> >> >>> >     </action>
>>>> >> >>> >   </action-mappings>
>>>> >> >>> > </struts-config>
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > Note here that I removed the stuff that generated the markup
>>>> from
>>>> >> >>> above
>>>> >> >>> > too, since that seems to be working just fine, I'm pretty
>>>> sure
>>>> >> this
>>>> >> >>> is
>>>> >> >>> all
>>>> >> >>> > that would be relevant.
>>>> >> >>> >
>>>> >> >>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>>>> >> >>> >
>>>> >> >>> > Frank
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > --
>>>> >> >>> > Frank W. Zammetti
>>>> >> >>> > Founder and Chief Software Architect
>>>> >> >>> > Omnytex Technologies
>>>> >> >>> > http://www.omnytex.com
>>>> >> >>> > AIM/Yahoo: fzammetti
>>>> >> >>> > MSN: fzammetti@hotmail.com
>>>> >> >>> > Author of "Practical Ajax Projects With Java Technology"
>>>> >> >>> >  (2006, Apress, ISBN 1-59059-695-1)
>>>> >> >>> > Java Web Parts - http://javawebparts.sourceforge.net
>>>> >> >>> >  Supplying the wheel, so you don't have to reinvent it!
>>>> >> >>> >
>>>> >> >>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>>>> >> >>> >> So what does happen when you submit the form?  Are you
>>>> getting
>>>> >> NPEs?
>>>> >> >>> >>
>>>> >> >>> >> By the time Struts attempts to populate the form bean, the
>>>> nested
>>>> >> >>> >> forms should already be instantiated.  You should have
>>>> getters
>>>> >> and
>>>> >> >>> >> setters for af1 and af2, and getAf1() and getAf2() should
>>>> not
>>>> >> return
>>>> >> >>> a
>>>> >> >>> >> null.  This could be an issue if the form bean is new,
>>>> either
>>>> >> >>> because
>>>> >> >>> >> it's in request scope, or in session scope but was not
>>>> previously
>>>> >> >>> >> instantiated.
>>>> >> >>> >>
>>>> >> >>> >> Hubert
>>>> >> >>> >>
>>>> >> >>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>> >> >>> >>> I'm facing a situation where ideally I'd like to have a
>>>> single
>>>> >> >>> >>> ActionForm
>>>> >> >>> >>> like so:
>>>> >> >>> >>>
>>>> >> >>> >>> public class MyActionForm extends ActionForm {
>>>> >> >>> >>>   AnotherActionForm1 af1;
>>>> >> >>> >>>   AnotherActionForm2 af2;
>>>> >> >>> >>> }
>>>> >> >>> >>>
>>>> >> >>> >>> When in my JSP I do:
>>>> >> >>> >>>
>>>> >> >>> >>> <html:text property="af1.field1" />
>>>> >> >>> >>>
>>>> >> >>> >>> ...I do indeed see the value as I expect.  The way I did
>>>> this
>>>> is
>>>> >> to
>>>> >> >>> >>> have
>>>> >> >>> >>> an Action mapping that references MyActionForm, then within
>>>> the
>>>> >> >>> Action
>>>> >> >>> >>> I
>>>> >> >>> >>> instantiate AnotherActionForm1, set the value of field1 on
>>>> it,
>>>> >> and
>>>> >> >>> then
>>>> >> >>> >>> set af1 to that new AnotherActionForm1 instance.  That all
>>>> works
>>>> >> >>> >>> nicely.
>>>> >> >>> >>>
>>>> >> >>> >>> Here's where I run into a problem...
>>>> >> >>> >>>
>>>> >> >>> >>> On the page I basically have 2 separate HTML forms, one for
>>>> >> >>> >>> AnotherActionForm1 and another for AnotherActionForm2.
>>>> However,
>>>> >> I
>>>> >> >>> have
>>>> >> >>> >>> a
>>>> >> >>> >>> SINGLE submit button at the end (just plain button that
>>>> makes
>>>> an
>>>> >> >>> AJAX
>>>> >> >>> >>> request).  onClick of that button, I create a query string
>>>> from
>>>> >> the
>>>> >> >>> >>> values
>>>> >> >>> >>> of both forms, and make a request to the server with the
>>>> query
>>>> >> >>> string
>>>> >> >>> >>> attached.  The parameter names of the query string
>>>> arguments
>>>> are
>>>> >> >>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.
>>>> The
>>>> >> >>> >>> mapping
>>>> >> >>> >>> that the request goes to again references MyActionForm.
>>>> >> >>> >>>
>>>> >> >>> >>> What I've been told should happen is that Struts should be
>>>> able
>>>> >> to
>>>> >> >>> >>> instantiate those two nested beans and set the properties,
>>>> since
>>>> >> >>> the
>>>> >> >>> >>> parameter names give it the information it needs.  This
>>>> does
>>>> not
>>>> >> >>> >>> however
>>>> >> >>> >>> seem to be happening.
>>>> >> >>> >>>
>>>> >> >>> >>> So, two questions... first, is that in fact the expected
>>>> >> >>> behavoir?  And
>>>> >> >>> >>> two, if so, any ideas what I'm doing wrong?  I can post all
>>>> the
>>>> >> >>> >>> pertinent
>>>> >> >>> >>> config and code, but thought it might be something more
>>>> generic
>>>> >> >>> that
>>>> >> >>> >>> wouldn't require all that.  This is the first time I've
>>>> ever
>>>> had
>>>> >> a
>>>> >> >>> need
>>>> >> >>> >>> to
>>>> >> >>> >>> nest forms like this, so it's a new question for me.
>>>> >> >>> >>>
>>>> >> >>> >>> Thanks all!
>>>> >> >>> >>>
>>>> >> >>> >>> Frank
>>>> >> >>> >>>
>>>> >> >>> >>>
>>>> >> >>> >>> --
>>>> >> >>> >>> Frank W. Zammetti
>>>> >> >>> >>> Founder and Chief Software Architect
>>>> >> >>> >>> Omnytex Technologies
>>>> >> >>> >>> http://www.omnytex.com
>>>> >> >>> >>> AIM/Yahoo: fzammetti
>>>> >> >>> >>> MSN: fzammetti@hotmail.com
>>>> >> >>> >>> Author of "Practical Ajax Projects With Java Technology"
>>>> >> >>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>>>> >> >>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>>>> >> >>> >>>  Supplying the wheel, so you don't have to reinvent it!
>>>> >> >>> >>>
>>>> >> >>> >>> ---------------------------------------------------------------------
>>>> >> >>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >> >>> >>> For additional commands, e-mail:
>>>> user-help@struts.apache.org
>>>> >> >>> >>>
>>>> >> >>> >>>
>>>> >> >>> >>
>>>> >> >>> >> ---------------------------------------------------------------------
>>>> >> >>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >> >>> >> For additional commands, e-mail: user-help@struts.apache.org
>>>> >> >>> >>
>>>> >> >>> >>
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>> > ---------------------------------------------------------------------
>>>> >> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >> >>> > For additional commands, e-mail: user-help@struts.apache.org
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>>
>>>> >> >>>
>>>> >> >>> ---------------------------------------------------------------------
>>>> >> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >> >>> For additional commands, e-mail: user-help@struts.apache.org
>>>> >> >>>
>>>> >> >>>
>>>> >> >>
>>>> >> >
>>>> >> >
>>>> >> > ---------------------------------------------------------------------
>>>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >> > For additional commands, e-mail: user-help@struts.apache.org
>>>> >> >
>>>> >> >
>>>> >>
>>>> >>
>>>> >> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> >> For additional commands, e-mail: user-help@struts.apache.org
>>>> >>
>>>> >>
>>>> >
>>>> > ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> > For additional commands, e-mail: user-help@struts.apache.org
>>>> >
>>>> >
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Quick update: it has something to do with the fact that its an AJAX
request at the end... or because its a POST, one or the other... I built a
URL with the parameters as a query string, and it worked fine... I don't
know what it is yet yet, exploring now... the request looks identical
aside from method, which shouldn't matter, AFAIKT, but something is
obviously bad with it... will let you know when I figure it out...

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 4:35 pm, Jiang, Peiyun wrote:
> Can you just use simple objects in the form?
>
> public class MyActionForm extends ActionForm {
>     AnotherActionForm1 af1;
>     AnotherActionForm2 af2;
>
>   MyActionForm() {
>     af1 = new SimpleObject1AsAnotherActionForm1();
>     af2 = new SimpleObject2AsAnotherActionForm2();
>   }
> }
>
> Access:
> <%= masterForm.af1.field1 %>
>
> Peiyun
>
> -----Original Message-----
> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
> Sent: September 22, 2006 4:23 PM
> To: Struts Users Mailing List
> Cc: Struts Users Mailing List
> Subject: Re: Nested form beans
>
>
> On Fri, September 22, 2006 3:59 pm, Hubert Rabago wrote:
>> I can't see anything that would cause your problem.
>> I guess if it were me, I'd fire up my debugger and start stepping
>> through some code.
>> Sorry.
>
> Yeah, that's the next step.  Was hoping to avoid it with an easy answer,
> but that's the way it goes sometimes :)
>
>> All I can say at this point is that I know what you're doing is
>> possible cause that's how FormDef does nested beans.
>
> Actually, that's a pretty big help in and of itself... I wasn't frankly
> aware the subbeans would get populated, so knowing it *should* work at
> least means I'm not on a wild goose chase.  Thanks for the effort, I
> definitely appreciate it!
>
>> Hubert
>
> Frank
>
>> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>> Hehe, way ahead of you :)  I put logging in every method...
>>> constructors,
>>> getters setter, all three forms.  Here's the output:
>>>
>>> MasterForm constructor
>>> Tab1Form constructor
>>> Tab2Form constructor
>>> --NOW IN JSP--
>>> MasterForm getTab1Form() = app.test.formbeans.Tab1Form@8ab08f
>>> MasterForm getTab2Form() = app.test.formbeans.Tab2Form@14d921a
>>> getting field1 = null
>>> getting field2 = null
>>>
>>> Notice the fields don't get set, nor do the subbeans get set on the
>>> containing bean.  The MasterForm constructor instantiates Tab1Form and
>>> Tab2Form, as the output indicates.
>>>
>>> Frank
>>>
>>>
>>> --
>>> Frank W. Zammetti
>>> Founder and Chief Software Architect
>>> Omnytex Technologies
>>> http://www.omnytex.com
>>> AIM/Yahoo: fzammetti
>>> MSN: fzammetti@hotmail.com
>>> Author of "Practical Ajax Projects With Java Technology"
>>>  (2006, Apress, ISBN 1-59059-695-1)
>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>  Supplying the wheel, so you don't have to reinvent it!
>>>
>>> On Fri, September 22, 2006 2:53 pm, Hubert Rabago wrote:
>>> > It still sounds like Struts is getting nulls for the subbeans when it
>>> > tries to populate subbean.fieldX.  Put some more logging, this time
>>> in
>>> > the getters for the subbean in MasterForm, and log what it's
>>> > returning.
>>> >
>>> > Hubert
>>> >
>>> > On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>> >> As a follow-up, I threw some logging in the field1 and field2
>>> setters
>>> in
>>> >> the subbeans... they don't appear to ever get called.  I don't have
>>> to
>>> >> do
>>> >> anything special to tell Struts I'm using nested beans, do I?  I
>>> didn't
>>> >> think so...
>>> >>
>>> >> Frank
>>> >>
>>> >>
>>> >> --
>>> >> Frank W. Zammetti
>>> >> Founder and Chief Software Architect
>>> >> Omnytex Technologies
>>> >> http://www.omnytex.com
>>> >> AIM/Yahoo: fzammetti
>>> >> MSN: fzammetti@hotmail.com
>>> >> Author of "Practical Ajax Projects With Java Technology"
>>> >>  (2006, Apress, ISBN 1-59059-695-1)
>>> >> Java Web Parts - http://javawebparts.sourceforge.net
>>> >>  Supplying the wheel, so you don't have to reinvent it!
>>> >>
>>> >> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
>>> >> > Hi Chris.. thanks for the suggestion, I gave that a shot at one
>>> point
>>> >> > actually... what I get is now the fields in the subforms (I guess
>>> >> that's
>>> >> > as good a term as any!) don't get set...
>>> >> >
>>> >> > masterForm = app.test.formbeans.MasterForm@141fab6
>>> >> > tab1Form = app.test.formbeans.Tab1Form@b301f2
>>> >> > tab2Form = app.test.formbeans.Tab2Form@44cbbe
>>> >> > field1 = null
>>> >> > field2 = null
>>> >> >
>>> >> > That's what I see in my final JSP output.
>>> >> >
>>> >> > Frank
>>> >> >
>>> >> >
>>> >> > --
>>> >> > Frank W. Zammetti
>>> >> > Founder and Chief Software Architect
>>> >> > Omnytex Technologies
>>> >> > http://www.omnytex.com
>>> >> > AIM/Yahoo: fzammetti
>>> >> > MSN: fzammetti@hotmail.com
>>> >> > Author of "Practical Ajax Projects With Java Technology"
>>> >> >  (2006, Apress, ISBN 1-59059-695-1)
>>> >> > Java Web Parts - http://javawebparts.sourceforge.net
>>> >> >  Supplying the wheel, so you don't have to reinvent it!
>>> >> >
>>> >> > On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
>>> >> >> In your no-arg constructor of your outer ActionForm (the
>>> container),
>>> >> >> make
>>> >> >> sure it instantiates each of the nested ActionForms using their
>>> >> no-arg
>>> >> >> constructors.
>>> >> >>   (*Chris*)
>>> >> >>
>>> >> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>> >> >>>
>>> >> >>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2...
>>> my
>>> >> >>> mistake
>>> >> >>> wasn't quite *THAT* obvious! ;) LOL
>>> >> >>>
>>> >> >>> Frank
>>> >> >>>
>>> >> >>>
>>> >> >>> --
>>> >> >>> Frank W. Zammetti
>>> >> >>> Founder and Chief Software Architect
>>> >> >>> Omnytex Technologies
>>> >> >>> http://www.omnytex.com
>>> >> >>> AIM/Yahoo: fzammetti
>>> >> >>> MSN: fzammetti@hotmail.com
>>> >> >>> Author of "Practical Ajax Projects With Java Technology"
>>> >> >>> (2006, Apress, ISBN 1-59059-695-1)
>>> >> >>> Java Web Parts - http://javawebparts.sourceforge.net
>>> >> >>> Supplying the wheel, so you don't have to reinvent it!
>>> >> >>>
>>> >> >>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>>> >> >>> > Hi Hubert,
>>> >> >>> >
>>> >> >>> > Yes, I get nulls for af1 and af2... I do have getters and
>>> setters
>>> >> for
>>> >> >>> > them.
>>> >> >>> >
>>> >> >>> > Lemme throw some data your way... I was hoping to avoid
>>> posting
>>> >> all
>>> >> >>> this,
>>> >> >>> > but I suspect there to be something my eyes just aren't
>>> catching,
>>> >> >>> so...
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > Here's ActionForm1:
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > package app.test.formbeans;
>>> >> >>> > import org.apache.struts.action.ActionForm;
>>> >> >>> > public class Action1Form extends ActionForm {
>>> >> >>> >   private String field1;
>>> >> >>> >   public void setField1(String inField1) {
>>> >> >>> >     this.field1 = inField1;
>>> >> >>> >   }
>>> >> >>> >   public String getField1() {
>>> >> >>> >     return this.field1;
>>> >> >>> >   }
>>> >> >>> > }
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > ActionForm2 is identical, just replacing the number 1 with 2
>>> >> >>> everywhere.
>>> >> >>> > Here's MasterForm:
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > package app.test.formbeans;
>>> >> >>> > import org.apache.struts.action.ActionForm;
>>> >> >>> > public class MasterForm extends ActionForm {
>>> >> >>> >   public Action1Form action1Form;
>>> >> >>> >   public Action2Form action2Form;
>>> >> >>> >   public void setAction1Form(Action1Form inAction1Form) {
>>> >> >>> >     this.action1Form = inAction1Form;
>>> >> >>> >   }
>>> >> >>> >   public Action1Form getAction1Form() {
>>> >> >>> >     return this.action1Form;
>>> >> >>> >   }
>>> >> >>> >   public void setAction2Form(Action2Form inAction2Form) {
>>> >> >>> >     this.action2Form = inAction2Form;
>>> >> >>> >   }
>>> >> >>> >   public Action2Form getAction2Form() {
>>> >> >>> >     return this.action2Form;
>>> >> >>> >   }
>>> >> >>> > }
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > The Action everything gets submitted to is just a
>>> ForwardAction,
>>> >> >>> which
>>> >> >>> > forwards to:
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > <%@ page language="java" import="app.test.formbeans.*" %>
>>> >> >>> > <%
>>> >> >>> >   MasterForm masterForm =
>>> >> >>> (MasterForm)request.getAttribute("masterForm");
>>> >> >>> > %>
>>> >> >>> > <%="masterForm = " + masterForm + "<br>"%>
>>> >> >>> > <%
>>> >> >>> >   Tab1Form tab1Form = null;
>>> >> >>> >   Tab2Form tab2Form = null;
>>> >> >>> >   if (masterForm != null) {
>>> >> >>> >     tab1Form = masterForm.getTab1Form();
>>> >> >>> >     tab2Form = masterForm.getTab2Form();
>>> >> >>> >   }
>>> >> >>> > %>
>>> >> >>> > <%="tab1Form = " + tab1Form + "<br>"%>
>>> >> >>> > <%="tab2Form = " + tab2Form + "<br>"%>
>>> >> >>> > <% if (tab1Form != null) { %>
>>> >> >>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>>> >> >>> > <% } %>
>>> >> >>> > <% if (tab2Form != null) { %>
>>> >> >>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>>> >> >>> > <% } %>
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > The result I see from this is:
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > masterForm = app.test.formbeans.MasterForm@e3849c
>>> >> >>> > tab1Form = null
>>> >> >>> > tab2Form = null
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > The page that does that submit, in its final rendered form on
>>> the
>>> >> >>> client
>>> >> >>> > is:
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > <html>
>>> >> >>> > <head>
>>> >> >>> >   <script>
>>> >> >>> >     var finalSubmit = null;
>>> >> >>> >     function getXHR() {
>>> >> >>> >       if (window.XMLHttpRequest) {
>>> >> >>> >         return new XMLHttpRequest();
>>> >> >>> >       } else if (window.ActiveXObject) {
>>> >> >>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>>> >> >>> >       }
>>> >> >>> >     }
>>> >> >>> >     function submitAll() {
>>> >> >>> >       var tab1Form = dojo.io.encodeForm(
>>> >> >>> >         document.getElementById("tab1Form"));
>>> >> >>> >       var tab2Form = dojo.io.encodeForm(
>>> >> >>> >         document.getElementById("tab2Form"));
>>> >> >>> >       finalSubmit = getXHR();
>>> >> >>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>>> >> >>> >       finalSubmit.open("POST", "final.do", true);
>>> >> >>> >       finalSubmit.send(tab1Form + tab2Form);
>>> >> >>> >     }
>>> >> >>> >     function finalSubmitCallback() {
>>> >> >>> >       if (finalSubmit.readyState == 4) {
>>> >> >>> >         document.getElementById("divResult").innerHTML =
>>> >> >>> > finalSubmit.responseText;
>>> >> >>> >       }
>>> >> >>> >     }
>>> >> >>> >   </script>
>>> >> >>> > </head>
>>> >> >>> > <body onload="init();">
>>> >> >>> >   <form name="masterForm" id="tab1Form" method="post"
>>> >> >>> > action="/test/tab1.do">
>>> >> >>> >     Field1: <input name="tab1Form.field1" value="val1"
>>> >> >>> type="text"><br>
>>> >> >>> >   </form>
>>> >> >>> >   <br>
>>> >> >>> >   <form name="masterForm" id="tab2Form" method="post"
>>> >> >>> > action="/test/tab2.do">
>>> >> >>> >     Field2: <input name="tab2Form.field2" value="val2"
>>> >> >>> type="text"><br>
>>> >> >>> >   </form>
>>> >> >>> >   <br>
>>> >> >>> >   <input value="Submit All" onclick="submitAll();"
>>> type="button">
>>> >> >>> >   <br><br>
>>> >> >>> >   <div id="divResult"></div>
>>> >> >>> > </body>
>>> >> >>> > </html>
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > Note that I removed all the Dojo-related stuff, and some stuff
>>> >> that
>>> >> >>> isn't
>>> >> >>> > related to this submissino, just to try and keep it small,
>>> but,
>>> >> the
>>> >> >>> > important thing to note is that when the submission is made,
>>> the
>>> >> >>> request
>>> >> >>> > that goes across is a POST to
>>> http://localhost:8080/test/final.do,
>>> >> as
>>> >> >>> > expected, and the POST body is:
>>> >> >>> >
>>> >> >>> > tab1Form.field1=val1&tab2Form.field2=val2&
>>> >> >>> >
>>> >> >>> > ...also as expected, verified in Firebug.  Lastly, here's
>>> >> >>> struts-config:
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>>> >> >>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software
>>> Foundation//DTD
>>> >> >>> Struts
>>> >> >>> > Configuration 1.2//EN"
>>> >> >>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>>> >> >>> > <struts-config>
>>> >> >>> >   <form-beans>
>>> >> >>> >     <form-bean name="masterForm"
>>> >> type="app.test.formbeans.MasterForm"
>>> >> >>> />
>>> >> >>> >   </form-beans>
>>> >> >>> >   <action-mappings>
>>> >> >>> >     <action path="/final" type="app.test.actions.FinalAction"
>>> >> >>> > name="masterForm" scope="request" validate="false">
>>> >> >>> >       <forward name="defaultForward" path="/final.jsp" />
>>> >> >>> >     </action>
>>> >> >>> >   </action-mappings>
>>> >> >>> > </struts-config>
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > Note here that I removed the stuff that generated the markup
>>> from
>>> >> >>> above
>>> >> >>> > too, since that seems to be working just fine, I'm pretty sure
>>> >> this
>>> >> >>> is
>>> >> >>> all
>>> >> >>> > that would be relevant.
>>> >> >>> >
>>> >> >>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>>> >> >>> >
>>> >> >>> > Frank
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > --
>>> >> >>> > Frank W. Zammetti
>>> >> >>> > Founder and Chief Software Architect
>>> >> >>> > Omnytex Technologies
>>> >> >>> > http://www.omnytex.com
>>> >> >>> > AIM/Yahoo: fzammetti
>>> >> >>> > MSN: fzammetti@hotmail.com
>>> >> >>> > Author of "Practical Ajax Projects With Java Technology"
>>> >> >>> >  (2006, Apress, ISBN 1-59059-695-1)
>>> >> >>> > Java Web Parts - http://javawebparts.sourceforge.net
>>> >> >>> >  Supplying the wheel, so you don't have to reinvent it!
>>> >> >>> >
>>> >> >>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>>> >> >>> >> So what does happen when you submit the form?  Are you
>>> getting
>>> >> NPEs?
>>> >> >>> >>
>>> >> >>> >> By the time Struts attempts to populate the form bean, the
>>> nested
>>> >> >>> >> forms should already be instantiated.  You should have
>>> getters
>>> >> and
>>> >> >>> >> setters for af1 and af2, and getAf1() and getAf2() should not
>>> >> return
>>> >> >>> a
>>> >> >>> >> null.  This could be an issue if the form bean is new, either
>>> >> >>> because
>>> >> >>> >> it's in request scope, or in session scope but was not
>>> previously
>>> >> >>> >> instantiated.
>>> >> >>> >>
>>> >> >>> >> Hubert
>>> >> >>> >>
>>> >> >>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>> >> >>> >>> I'm facing a situation where ideally I'd like to have a
>>> single
>>> >> >>> >>> ActionForm
>>> >> >>> >>> like so:
>>> >> >>> >>>
>>> >> >>> >>> public class MyActionForm extends ActionForm {
>>> >> >>> >>>   AnotherActionForm1 af1;
>>> >> >>> >>>   AnotherActionForm2 af2;
>>> >> >>> >>> }
>>> >> >>> >>>
>>> >> >>> >>> When in my JSP I do:
>>> >> >>> >>>
>>> >> >>> >>> <html:text property="af1.field1" />
>>> >> >>> >>>
>>> >> >>> >>> ...I do indeed see the value as I expect.  The way I did
>>> this
>>> is
>>> >> to
>>> >> >>> >>> have
>>> >> >>> >>> an Action mapping that references MyActionForm, then within
>>> the
>>> >> >>> Action
>>> >> >>> >>> I
>>> >> >>> >>> instantiate AnotherActionForm1, set the value of field1 on
>>> it,
>>> >> and
>>> >> >>> then
>>> >> >>> >>> set af1 to that new AnotherActionForm1 instance.  That all
>>> works
>>> >> >>> >>> nicely.
>>> >> >>> >>>
>>> >> >>> >>> Here's where I run into a problem...
>>> >> >>> >>>
>>> >> >>> >>> On the page I basically have 2 separate HTML forms, one for
>>> >> >>> >>> AnotherActionForm1 and another for AnotherActionForm2.
>>> However,
>>> >> I
>>> >> >>> have
>>> >> >>> >>> a
>>> >> >>> >>> SINGLE submit button at the end (just plain button that
>>> makes
>>> an
>>> >> >>> AJAX
>>> >> >>> >>> request).  onClick of that button, I create a query string
>>> from
>>> >> the
>>> >> >>> >>> values
>>> >> >>> >>> of both forms, and make a request to the server with the
>>> query
>>> >> >>> string
>>> >> >>> >>> attached.  The parameter names of the query string arguments
>>> are
>>> >> >>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.
>>> The
>>> >> >>> >>> mapping
>>> >> >>> >>> that the request goes to again references MyActionForm.
>>> >> >>> >>>
>>> >> >>> >>> What I've been told should happen is that Struts should be
>>> able
>>> >> to
>>> >> >>> >>> instantiate those two nested beans and set the properties,
>>> since
>>> >> >>> the
>>> >> >>> >>> parameter names give it the information it needs.  This does
>>> not
>>> >> >>> >>> however
>>> >> >>> >>> seem to be happening.
>>> >> >>> >>>
>>> >> >>> >>> So, two questions... first, is that in fact the expected
>>> >> >>> behavoir?  And
>>> >> >>> >>> two, if so, any ideas what I'm doing wrong?  I can post all
>>> the
>>> >> >>> >>> pertinent
>>> >> >>> >>> config and code, but thought it might be something more
>>> generic
>>> >> >>> that
>>> >> >>> >>> wouldn't require all that.  This is the first time I've ever
>>> had
>>> >> a
>>> >> >>> need
>>> >> >>> >>> to
>>> >> >>> >>> nest forms like this, so it's a new question for me.
>>> >> >>> >>>
>>> >> >>> >>> Thanks all!
>>> >> >>> >>>
>>> >> >>> >>> Frank
>>> >> >>> >>>
>>> >> >>> >>>
>>> >> >>> >>> --
>>> >> >>> >>> Frank W. Zammetti
>>> >> >>> >>> Founder and Chief Software Architect
>>> >> >>> >>> Omnytex Technologies
>>> >> >>> >>> http://www.omnytex.com
>>> >> >>> >>> AIM/Yahoo: fzammetti
>>> >> >>> >>> MSN: fzammetti@hotmail.com
>>> >> >>> >>> Author of "Practical Ajax Projects With Java Technology"
>>> >> >>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>>> >> >>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>>> >> >>> >>>  Supplying the wheel, so you don't have to reinvent it!
>>> >> >>> >>>
>>> >> >>> >>> ---------------------------------------------------------------------
>>> >> >>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> >>> >>> For additional commands, e-mail: user-help@struts.apache.org
>>> >> >>> >>>
>>> >> >>> >>>
>>> >> >>> >>
>>> >> >>> >> ---------------------------------------------------------------------
>>> >> >>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> >>> >> For additional commands, e-mail: user-help@struts.apache.org
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > ---------------------------------------------------------------------
>>> >> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> >>> > For additional commands, e-mail: user-help@struts.apache.org
>>> >> >>> >
>>> >> >>> >
>>> >> >>>
>>> >> >>>
>>> >> >>> ---------------------------------------------------------------------
>>> >> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> >>> For additional commands, e-mail: user-help@struts.apache.org
>>> >> >>>
>>> >> >>>
>>> >> >>
>>> >> >
>>> >> >
>>> >> > ---------------------------------------------------------------------
>>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> > For additional commands, e-mail: user-help@struts.apache.org
>>> >> >
>>> >> >
>>> >>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> For additional commands, e-mail: user-help@struts.apache.org
>>> >>
>>> >>
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> > For additional commands, e-mail: user-help@struts.apache.org
>>> >
>>> >
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Nested form beans

Posted by "Jiang, Peiyun " <Pe...@nrc-cnrc.gc.ca>.
Can you just use simple objects in the form?

public class MyActionForm extends ActionForm {
    AnotherActionForm1 af1;
    AnotherActionForm2 af2;

  MyActionForm() {
    af1 = new SimpleObject1AsAnotherActionForm1();
    af2 = new SimpleObject2AsAnotherActionForm2();
  }
}

Access:
<%= masterForm.af1.field1 %>

Peiyun

-----Original Message-----
From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
Sent: September 22, 2006 4:23 PM
To: Struts Users Mailing List
Cc: Struts Users Mailing List
Subject: Re: Nested form beans


On Fri, September 22, 2006 3:59 pm, Hubert Rabago wrote:
> I can't see anything that would cause your problem.
> I guess if it were me, I'd fire up my debugger and start stepping
> through some code.
> Sorry.

Yeah, that's the next step.  Was hoping to avoid it with an easy answer,
but that's the way it goes sometimes :)

> All I can say at this point is that I know what you're doing is
> possible cause that's how FormDef does nested beans.

Actually, that's a pretty big help in and of itself... I wasn't frankly
aware the subbeans would get populated, so knowing it *should* work at
least means I'm not on a wild goose chase.  Thanks for the effort, I
definitely appreciate it!

> Hubert

Frank

> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> Hehe, way ahead of you :)  I put logging in every method...
>> constructors,
>> getters setter, all three forms.  Here's the output:
>>
>> MasterForm constructor
>> Tab1Form constructor
>> Tab2Form constructor
>> --NOW IN JSP--
>> MasterForm getTab1Form() = app.test.formbeans.Tab1Form@8ab08f
>> MasterForm getTab2Form() = app.test.formbeans.Tab2Form@14d921a
>> getting field1 = null
>> getting field2 = null
>>
>> Notice the fields don't get set, nor do the subbeans get set on the
>> containing bean.  The MasterForm constructor instantiates Tab1Form and
>> Tab2Form, as the output indicates.
>>
>> Frank
>>
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>>  (2006, Apress, ISBN 1-59059-695-1)
>> Java Web Parts - http://javawebparts.sourceforge.net
>>  Supplying the wheel, so you don't have to reinvent it!
>>
>> On Fri, September 22, 2006 2:53 pm, Hubert Rabago wrote:
>> > It still sounds like Struts is getting nulls for the subbeans when it
>> > tries to populate subbean.fieldX.  Put some more logging, this time in
>> > the getters for the subbean in MasterForm, and log what it's
>> > returning.
>> >
>> > Hubert
>> >
>> > On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >> As a follow-up, I threw some logging in the field1 and field2 setters
>> in
>> >> the subbeans... they don't appear to ever get called.  I don't have
>> to
>> >> do
>> >> anything special to tell Struts I'm using nested beans, do I?  I
>> didn't
>> >> think so...
>> >>
>> >> Frank
>> >>
>> >>
>> >> --
>> >> Frank W. Zammetti
>> >> Founder and Chief Software Architect
>> >> Omnytex Technologies
>> >> http://www.omnytex.com
>> >> AIM/Yahoo: fzammetti
>> >> MSN: fzammetti@hotmail.com
>> >> Author of "Practical Ajax Projects With Java Technology"
>> >>  (2006, Apress, ISBN 1-59059-695-1)
>> >> Java Web Parts - http://javawebparts.sourceforge.net
>> >>  Supplying the wheel, so you don't have to reinvent it!
>> >>
>> >> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
>> >> > Hi Chris.. thanks for the suggestion, I gave that a shot at one
>> point
>> >> > actually... what I get is now the fields in the subforms (I guess
>> >> that's
>> >> > as good a term as any!) don't get set...
>> >> >
>> >> > masterForm = app.test.formbeans.MasterForm@141fab6
>> >> > tab1Form = app.test.formbeans.Tab1Form@b301f2
>> >> > tab2Form = app.test.formbeans.Tab2Form@44cbbe
>> >> > field1 = null
>> >> > field2 = null
>> >> >
>> >> > That's what I see in my final JSP output.
>> >> >
>> >> > Frank
>> >> >
>> >> >
>> >> > --
>> >> > Frank W. Zammetti
>> >> > Founder and Chief Software Architect
>> >> > Omnytex Technologies
>> >> > http://www.omnytex.com
>> >> > AIM/Yahoo: fzammetti
>> >> > MSN: fzammetti@hotmail.com
>> >> > Author of "Practical Ajax Projects With Java Technology"
>> >> >  (2006, Apress, ISBN 1-59059-695-1)
>> >> > Java Web Parts - http://javawebparts.sourceforge.net
>> >> >  Supplying the wheel, so you don't have to reinvent it!
>> >> >
>> >> > On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
>> >> >> In your no-arg constructor of your outer ActionForm (the
>> container),
>> >> >> make
>> >> >> sure it instantiates each of the nested ActionForms using their
>> >> no-arg
>> >> >> constructors.
>> >> >>   (*Chris*)
>> >> >>
>> >> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >> >>>
>> >> >>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2...
>> my
>> >> >>> mistake
>> >> >>> wasn't quite *THAT* obvious! ;) LOL
>> >> >>>
>> >> >>> Frank
>> >> >>>
>> >> >>>
>> >> >>> --
>> >> >>> Frank W. Zammetti
>> >> >>> Founder and Chief Software Architect
>> >> >>> Omnytex Technologies
>> >> >>> http://www.omnytex.com
>> >> >>> AIM/Yahoo: fzammetti
>> >> >>> MSN: fzammetti@hotmail.com
>> >> >>> Author of "Practical Ajax Projects With Java Technology"
>> >> >>> (2006, Apress, ISBN 1-59059-695-1)
>> >> >>> Java Web Parts - http://javawebparts.sourceforge.net
>> >> >>> Supplying the wheel, so you don't have to reinvent it!
>> >> >>>
>> >> >>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>> >> >>> > Hi Hubert,
>> >> >>> >
>> >> >>> > Yes, I get nulls for af1 and af2... I do have getters and
>> setters
>> >> for
>> >> >>> > them.
>> >> >>> >
>> >> >>> > Lemme throw some data your way... I was hoping to avoid posting
>> >> all
>> >> >>> this,
>> >> >>> > but I suspect there to be something my eyes just aren't
>> catching,
>> >> >>> so...
>> >> >>> >
>> >> >>> >
>> >> >>> > Here's ActionForm1:
>> >> >>> >
>> >> >>> >
>> >> >>> > package app.test.formbeans;
>> >> >>> > import org.apache.struts.action.ActionForm;
>> >> >>> > public class Action1Form extends ActionForm {
>> >> >>> >   private String field1;
>> >> >>> >   public void setField1(String inField1) {
>> >> >>> >     this.field1 = inField1;
>> >> >>> >   }
>> >> >>> >   public String getField1() {
>> >> >>> >     return this.field1;
>> >> >>> >   }
>> >> >>> > }
>> >> >>> >
>> >> >>> >
>> >> >>> > ActionForm2 is identical, just replacing the number 1 with 2
>> >> >>> everywhere.
>> >> >>> > Here's MasterForm:
>> >> >>> >
>> >> >>> >
>> >> >>> > package app.test.formbeans;
>> >> >>> > import org.apache.struts.action.ActionForm;
>> >> >>> > public class MasterForm extends ActionForm {
>> >> >>> >   public Action1Form action1Form;
>> >> >>> >   public Action2Form action2Form;
>> >> >>> >   public void setAction1Form(Action1Form inAction1Form) {
>> >> >>> >     this.action1Form = inAction1Form;
>> >> >>> >   }
>> >> >>> >   public Action1Form getAction1Form() {
>> >> >>> >     return this.action1Form;
>> >> >>> >   }
>> >> >>> >   public void setAction2Form(Action2Form inAction2Form) {
>> >> >>> >     this.action2Form = inAction2Form;
>> >> >>> >   }
>> >> >>> >   public Action2Form getAction2Form() {
>> >> >>> >     return this.action2Form;
>> >> >>> >   }
>> >> >>> > }
>> >> >>> >
>> >> >>> >
>> >> >>> > The Action everything gets submitted to is just a
>> ForwardAction,
>> >> >>> which
>> >> >>> > forwards to:
>> >> >>> >
>> >> >>> >
>> >> >>> > <%@ page language="java" import="app.test.formbeans.*" %>
>> >> >>> > <%
>> >> >>> >   MasterForm masterForm =
>> >> >>> (MasterForm)request.getAttribute("masterForm");
>> >> >>> > %>
>> >> >>> > <%="masterForm = " + masterForm + "<br>"%>
>> >> >>> > <%
>> >> >>> >   Tab1Form tab1Form = null;
>> >> >>> >   Tab2Form tab2Form = null;
>> >> >>> >   if (masterForm != null) {
>> >> >>> >     tab1Form = masterForm.getTab1Form();
>> >> >>> >     tab2Form = masterForm.getTab2Form();
>> >> >>> >   }
>> >> >>> > %>
>> >> >>> > <%="tab1Form = " + tab1Form + "<br>"%>
>> >> >>> > <%="tab2Form = " + tab2Form + "<br>"%>
>> >> >>> > <% if (tab1Form != null) { %>
>> >> >>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>> >> >>> > <% } %>
>> >> >>> > <% if (tab2Form != null) { %>
>> >> >>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>> >> >>> > <% } %>
>> >> >>> >
>> >> >>> >
>> >> >>> > The result I see from this is:
>> >> >>> >
>> >> >>> >
>> >> >>> > masterForm = app.test.formbeans.MasterForm@e3849c
>> >> >>> > tab1Form = null
>> >> >>> > tab2Form = null
>> >> >>> >
>> >> >>> >
>> >> >>> > The page that does that submit, in its final rendered form on
>> the
>> >> >>> client
>> >> >>> > is:
>> >> >>> >
>> >> >>> >
>> >> >>> > <html>
>> >> >>> > <head>
>> >> >>> >   <script>
>> >> >>> >     var finalSubmit = null;
>> >> >>> >     function getXHR() {
>> >> >>> >       if (window.XMLHttpRequest) {
>> >> >>> >         return new XMLHttpRequest();
>> >> >>> >       } else if (window.ActiveXObject) {
>> >> >>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>> >> >>> >       }
>> >> >>> >     }
>> >> >>> >     function submitAll() {
>> >> >>> >       var tab1Form = dojo.io.encodeForm(
>> >> >>> >         document.getElementById("tab1Form"));
>> >> >>> >       var tab2Form = dojo.io.encodeForm(
>> >> >>> >         document.getElementById("tab2Form"));
>> >> >>> >       finalSubmit = getXHR();
>> >> >>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>> >> >>> >       finalSubmit.open("POST", "final.do", true);
>> >> >>> >       finalSubmit.send(tab1Form + tab2Form);
>> >> >>> >     }
>> >> >>> >     function finalSubmitCallback() {
>> >> >>> >       if (finalSubmit.readyState == 4) {
>> >> >>> >         document.getElementById("divResult").innerHTML =
>> >> >>> > finalSubmit.responseText;
>> >> >>> >       }
>> >> >>> >     }
>> >> >>> >   </script>
>> >> >>> > </head>
>> >> >>> > <body onload="init();">
>> >> >>> >   <form name="masterForm" id="tab1Form" method="post"
>> >> >>> > action="/test/tab1.do">
>> >> >>> >     Field1: <input name="tab1Form.field1" value="val1"
>> >> >>> type="text"><br>
>> >> >>> >   </form>
>> >> >>> >   <br>
>> >> >>> >   <form name="masterForm" id="tab2Form" method="post"
>> >> >>> > action="/test/tab2.do">
>> >> >>> >     Field2: <input name="tab2Form.field2" value="val2"
>> >> >>> type="text"><br>
>> >> >>> >   </form>
>> >> >>> >   <br>
>> >> >>> >   <input value="Submit All" onclick="submitAll();"
>> type="button">
>> >> >>> >   <br><br>
>> >> >>> >   <div id="divResult"></div>
>> >> >>> > </body>
>> >> >>> > </html>
>> >> >>> >
>> >> >>> >
>> >> >>> > Note that I removed all the Dojo-related stuff, and some stuff
>> >> that
>> >> >>> isn't
>> >> >>> > related to this submissino, just to try and keep it small, but,
>> >> the
>> >> >>> > important thing to note is that when the submission is made,
>> the
>> >> >>> request
>> >> >>> > that goes across is a POST to
>> http://localhost:8080/test/final.do,
>> >> as
>> >> >>> > expected, and the POST body is:
>> >> >>> >
>> >> >>> > tab1Form.field1=val1&tab2Form.field2=val2&
>> >> >>> >
>> >> >>> > ...also as expected, verified in Firebug.  Lastly, here's
>> >> >>> struts-config:
>> >> >>> >
>> >> >>> >
>> >> >>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>> >> >>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software
>> Foundation//DTD
>> >> >>> Struts
>> >> >>> > Configuration 1.2//EN"
>> >> >>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>> >> >>> > <struts-config>
>> >> >>> >   <form-beans>
>> >> >>> >     <form-bean name="masterForm"
>> >> type="app.test.formbeans.MasterForm"
>> >> >>> />
>> >> >>> >   </form-beans>
>> >> >>> >   <action-mappings>
>> >> >>> >     <action path="/final" type="app.test.actions.FinalAction"
>> >> >>> > name="masterForm" scope="request" validate="false">
>> >> >>> >       <forward name="defaultForward" path="/final.jsp" />
>> >> >>> >     </action>
>> >> >>> >   </action-mappings>
>> >> >>> > </struts-config>
>> >> >>> >
>> >> >>> >
>> >> >>> > Note here that I removed the stuff that generated the markup
>> from
>> >> >>> above
>> >> >>> > too, since that seems to be working just fine, I'm pretty sure
>> >> this
>> >> >>> is
>> >> >>> all
>> >> >>> > that would be relevant.
>> >> >>> >
>> >> >>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>> >> >>> >
>> >> >>> > Frank
>> >> >>> >
>> >> >>> >
>> >> >>> > --
>> >> >>> > Frank W. Zammetti
>> >> >>> > Founder and Chief Software Architect
>> >> >>> > Omnytex Technologies
>> >> >>> > http://www.omnytex.com
>> >> >>> > AIM/Yahoo: fzammetti
>> >> >>> > MSN: fzammetti@hotmail.com
>> >> >>> > Author of "Practical Ajax Projects With Java Technology"
>> >> >>> >  (2006, Apress, ISBN 1-59059-695-1)
>> >> >>> > Java Web Parts - http://javawebparts.sourceforge.net
>> >> >>> >  Supplying the wheel, so you don't have to reinvent it!
>> >> >>> >
>> >> >>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>> >> >>> >> So what does happen when you submit the form?  Are you getting
>> >> NPEs?
>> >> >>> >>
>> >> >>> >> By the time Struts attempts to populate the form bean, the
>> nested
>> >> >>> >> forms should already be instantiated.  You should have getters
>> >> and
>> >> >>> >> setters for af1 and af2, and getAf1() and getAf2() should not
>> >> return
>> >> >>> a
>> >> >>> >> null.  This could be an issue if the form bean is new, either
>> >> >>> because
>> >> >>> >> it's in request scope, or in session scope but was not
>> previously
>> >> >>> >> instantiated.
>> >> >>> >>
>> >> >>> >> Hubert
>> >> >>> >>
>> >> >>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >> >>> >>> I'm facing a situation where ideally I'd like to have a
>> single
>> >> >>> >>> ActionForm
>> >> >>> >>> like so:
>> >> >>> >>>
>> >> >>> >>> public class MyActionForm extends ActionForm {
>> >> >>> >>>   AnotherActionForm1 af1;
>> >> >>> >>>   AnotherActionForm2 af2;
>> >> >>> >>> }
>> >> >>> >>>
>> >> >>> >>> When in my JSP I do:
>> >> >>> >>>
>> >> >>> >>> <html:text property="af1.field1" />
>> >> >>> >>>
>> >> >>> >>> ...I do indeed see the value as I expect.  The way I did this
>> is
>> >> to
>> >> >>> >>> have
>> >> >>> >>> an Action mapping that references MyActionForm, then within
>> the
>> >> >>> Action
>> >> >>> >>> I
>> >> >>> >>> instantiate AnotherActionForm1, set the value of field1 on
>> it,
>> >> and
>> >> >>> then
>> >> >>> >>> set af1 to that new AnotherActionForm1 instance.  That all
>> works
>> >> >>> >>> nicely.
>> >> >>> >>>
>> >> >>> >>> Here's where I run into a problem...
>> >> >>> >>>
>> >> >>> >>> On the page I basically have 2 separate HTML forms, one for
>> >> >>> >>> AnotherActionForm1 and another for AnotherActionForm2.
>> However,
>> >> I
>> >> >>> have
>> >> >>> >>> a
>> >> >>> >>> SINGLE submit button at the end (just plain button that makes
>> an
>> >> >>> AJAX
>> >> >>> >>> request).  onClick of that button, I create a query string
>> from
>> >> the
>> >> >>> >>> values
>> >> >>> >>> of both forms, and make a request to the server with the
>> query
>> >> >>> string
>> >> >>> >>> attached.  The parameter names of the query string arguments
>> are
>> >> >>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.
>> The
>> >> >>> >>> mapping
>> >> >>> >>> that the request goes to again references MyActionForm.
>> >> >>> >>>
>> >> >>> >>> What I've been told should happen is that Struts should be
>> able
>> >> to
>> >> >>> >>> instantiate those two nested beans and set the properties,
>> since
>> >> >>> the
>> >> >>> >>> parameter names give it the information it needs.  This does
>> not
>> >> >>> >>> however
>> >> >>> >>> seem to be happening.
>> >> >>> >>>
>> >> >>> >>> So, two questions... first, is that in fact the expected
>> >> >>> behavoir?  And
>> >> >>> >>> two, if so, any ideas what I'm doing wrong?  I can post all
>> the
>> >> >>> >>> pertinent
>> >> >>> >>> config and code, but thought it might be something more
>> generic
>> >> >>> that
>> >> >>> >>> wouldn't require all that.  This is the first time I've ever
>> had
>> >> a
>> >> >>> need
>> >> >>> >>> to
>> >> >>> >>> nest forms like this, so it's a new question for me.
>> >> >>> >>>
>> >> >>> >>> Thanks all!
>> >> >>> >>>
>> >> >>> >>> Frank
>> >> >>> >>>
>> >> >>> >>>
>> >> >>> >>> --
>> >> >>> >>> Frank W. Zammetti
>> >> >>> >>> Founder and Chief Software Architect
>> >> >>> >>> Omnytex Technologies
>> >> >>> >>> http://www.omnytex.com
>> >> >>> >>> AIM/Yahoo: fzammetti
>> >> >>> >>> MSN: fzammetti@hotmail.com
>> >> >>> >>> Author of "Practical Ajax Projects With Java Technology"
>> >> >>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>> >> >>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>> >> >>> >>>  Supplying the wheel, so you don't have to reinvent it!
>> >> >>> >>>
>> >> >>> >>> ---------------------------------------------------------------------
>> >> >>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> >>> For additional commands, e-mail: user-help@struts.apache.org
>> >> >>> >>>
>> >> >>> >>>
>> >> >>> >>
>> >> >>> >> ---------------------------------------------------------------------
>> >> >>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >> >>> >>
>> >> >>> >>
>> >> >>> >
>> >> >>> >
>> >> >>> > ---------------------------------------------------------------------
>> >> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> > For additional commands, e-mail: user-help@struts.apache.org
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >> >>>
>> >> >>> ---------------------------------------------------------------------
>> >> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> For additional commands, e-mail: user-help@struts.apache.org
>> >> >>>
>> >> >>>
>> >> >>
>> >> >
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> > For additional commands, e-mail: user-help@struts.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On Fri, September 22, 2006 3:59 pm, Hubert Rabago wrote:
> I can't see anything that would cause your problem.
> I guess if it were me, I'd fire up my debugger and start stepping
> through some code.
> Sorry.

Yeah, that's the next step.  Was hoping to avoid it with an easy answer,
but that's the way it goes sometimes :)

> All I can say at this point is that I know what you're doing is
> possible cause that's how FormDef does nested beans.

Actually, that's a pretty big help in and of itself... I wasn't frankly
aware the subbeans would get populated, so knowing it *should* work at
least means I'm not on a wild goose chase.  Thanks for the effort, I
definitely appreciate it!

> Hubert

Frank

> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> Hehe, way ahead of you :)  I put logging in every method...
>> constructors,
>> getters setter, all three forms.  Here's the output:
>>
>> MasterForm constructor
>> Tab1Form constructor
>> Tab2Form constructor
>> --NOW IN JSP--
>> MasterForm getTab1Form() = app.test.formbeans.Tab1Form@8ab08f
>> MasterForm getTab2Form() = app.test.formbeans.Tab2Form@14d921a
>> getting field1 = null
>> getting field2 = null
>>
>> Notice the fields don't get set, nor do the subbeans get set on the
>> containing bean.  The MasterForm constructor instantiates Tab1Form and
>> Tab2Form, as the output indicates.
>>
>> Frank
>>
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>>  (2006, Apress, ISBN 1-59059-695-1)
>> Java Web Parts - http://javawebparts.sourceforge.net
>>  Supplying the wheel, so you don't have to reinvent it!
>>
>> On Fri, September 22, 2006 2:53 pm, Hubert Rabago wrote:
>> > It still sounds like Struts is getting nulls for the subbeans when it
>> > tries to populate subbean.fieldX.  Put some more logging, this time in
>> > the getters for the subbean in MasterForm, and log what it's
>> > returning.
>> >
>> > Hubert
>> >
>> > On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >> As a follow-up, I threw some logging in the field1 and field2 setters
>> in
>> >> the subbeans... they don't appear to ever get called.  I don't have
>> to
>> >> do
>> >> anything special to tell Struts I'm using nested beans, do I?  I
>> didn't
>> >> think so...
>> >>
>> >> Frank
>> >>
>> >>
>> >> --
>> >> Frank W. Zammetti
>> >> Founder and Chief Software Architect
>> >> Omnytex Technologies
>> >> http://www.omnytex.com
>> >> AIM/Yahoo: fzammetti
>> >> MSN: fzammetti@hotmail.com
>> >> Author of "Practical Ajax Projects With Java Technology"
>> >>  (2006, Apress, ISBN 1-59059-695-1)
>> >> Java Web Parts - http://javawebparts.sourceforge.net
>> >>  Supplying the wheel, so you don't have to reinvent it!
>> >>
>> >> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
>> >> > Hi Chris.. thanks for the suggestion, I gave that a shot at one
>> point
>> >> > actually... what I get is now the fields in the subforms (I guess
>> >> that's
>> >> > as good a term as any!) don't get set...
>> >> >
>> >> > masterForm = app.test.formbeans.MasterForm@141fab6
>> >> > tab1Form = app.test.formbeans.Tab1Form@b301f2
>> >> > tab2Form = app.test.formbeans.Tab2Form@44cbbe
>> >> > field1 = null
>> >> > field2 = null
>> >> >
>> >> > That's what I see in my final JSP output.
>> >> >
>> >> > Frank
>> >> >
>> >> >
>> >> > --
>> >> > Frank W. Zammetti
>> >> > Founder and Chief Software Architect
>> >> > Omnytex Technologies
>> >> > http://www.omnytex.com
>> >> > AIM/Yahoo: fzammetti
>> >> > MSN: fzammetti@hotmail.com
>> >> > Author of "Practical Ajax Projects With Java Technology"
>> >> >  (2006, Apress, ISBN 1-59059-695-1)
>> >> > Java Web Parts - http://javawebparts.sourceforge.net
>> >> >  Supplying the wheel, so you don't have to reinvent it!
>> >> >
>> >> > On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
>> >> >> In your no-arg constructor of your outer ActionForm (the
>> container),
>> >> >> make
>> >> >> sure it instantiates each of the nested ActionForms using their
>> >> no-arg
>> >> >> constructors.
>> >> >>   (*Chris*)
>> >> >>
>> >> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >> >>>
>> >> >>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2...
>> my
>> >> >>> mistake
>> >> >>> wasn't quite *THAT* obvious! ;) LOL
>> >> >>>
>> >> >>> Frank
>> >> >>>
>> >> >>>
>> >> >>> --
>> >> >>> Frank W. Zammetti
>> >> >>> Founder and Chief Software Architect
>> >> >>> Omnytex Technologies
>> >> >>> http://www.omnytex.com
>> >> >>> AIM/Yahoo: fzammetti
>> >> >>> MSN: fzammetti@hotmail.com
>> >> >>> Author of "Practical Ajax Projects With Java Technology"
>> >> >>> (2006, Apress, ISBN 1-59059-695-1)
>> >> >>> Java Web Parts - http://javawebparts.sourceforge.net
>> >> >>> Supplying the wheel, so you don't have to reinvent it!
>> >> >>>
>> >> >>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>> >> >>> > Hi Hubert,
>> >> >>> >
>> >> >>> > Yes, I get nulls for af1 and af2... I do have getters and
>> setters
>> >> for
>> >> >>> > them.
>> >> >>> >
>> >> >>> > Lemme throw some data your way... I was hoping to avoid posting
>> >> all
>> >> >>> this,
>> >> >>> > but I suspect there to be something my eyes just aren't
>> catching,
>> >> >>> so...
>> >> >>> >
>> >> >>> >
>> >> >>> > Here's ActionForm1:
>> >> >>> >
>> >> >>> >
>> >> >>> > package app.test.formbeans;
>> >> >>> > import org.apache.struts.action.ActionForm;
>> >> >>> > public class Action1Form extends ActionForm {
>> >> >>> >   private String field1;
>> >> >>> >   public void setField1(String inField1) {
>> >> >>> >     this.field1 = inField1;
>> >> >>> >   }
>> >> >>> >   public String getField1() {
>> >> >>> >     return this.field1;
>> >> >>> >   }
>> >> >>> > }
>> >> >>> >
>> >> >>> >
>> >> >>> > ActionForm2 is identical, just replacing the number 1 with 2
>> >> >>> everywhere.
>> >> >>> > Here's MasterForm:
>> >> >>> >
>> >> >>> >
>> >> >>> > package app.test.formbeans;
>> >> >>> > import org.apache.struts.action.ActionForm;
>> >> >>> > public class MasterForm extends ActionForm {
>> >> >>> >   public Action1Form action1Form;
>> >> >>> >   public Action2Form action2Form;
>> >> >>> >   public void setAction1Form(Action1Form inAction1Form) {
>> >> >>> >     this.action1Form = inAction1Form;
>> >> >>> >   }
>> >> >>> >   public Action1Form getAction1Form() {
>> >> >>> >     return this.action1Form;
>> >> >>> >   }
>> >> >>> >   public void setAction2Form(Action2Form inAction2Form) {
>> >> >>> >     this.action2Form = inAction2Form;
>> >> >>> >   }
>> >> >>> >   public Action2Form getAction2Form() {
>> >> >>> >     return this.action2Form;
>> >> >>> >   }
>> >> >>> > }
>> >> >>> >
>> >> >>> >
>> >> >>> > The Action everything gets submitted to is just a
>> ForwardAction,
>> >> >>> which
>> >> >>> > forwards to:
>> >> >>> >
>> >> >>> >
>> >> >>> > <%@ page language="java" import="app.test.formbeans.*" %>
>> >> >>> > <%
>> >> >>> >   MasterForm masterForm =
>> >> >>> (MasterForm)request.getAttribute("masterForm");
>> >> >>> > %>
>> >> >>> > <%="masterForm = " + masterForm + "<br>"%>
>> >> >>> > <%
>> >> >>> >   Tab1Form tab1Form = null;
>> >> >>> >   Tab2Form tab2Form = null;
>> >> >>> >   if (masterForm != null) {
>> >> >>> >     tab1Form = masterForm.getTab1Form();
>> >> >>> >     tab2Form = masterForm.getTab2Form();
>> >> >>> >   }
>> >> >>> > %>
>> >> >>> > <%="tab1Form = " + tab1Form + "<br>"%>
>> >> >>> > <%="tab2Form = " + tab2Form + "<br>"%>
>> >> >>> > <% if (tab1Form != null) { %>
>> >> >>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>> >> >>> > <% } %>
>> >> >>> > <% if (tab2Form != null) { %>
>> >> >>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>> >> >>> > <% } %>
>> >> >>> >
>> >> >>> >
>> >> >>> > The result I see from this is:
>> >> >>> >
>> >> >>> >
>> >> >>> > masterForm = app.test.formbeans.MasterForm@e3849c
>> >> >>> > tab1Form = null
>> >> >>> > tab2Form = null
>> >> >>> >
>> >> >>> >
>> >> >>> > The page that does that submit, in its final rendered form on
>> the
>> >> >>> client
>> >> >>> > is:
>> >> >>> >
>> >> >>> >
>> >> >>> > <html>
>> >> >>> > <head>
>> >> >>> >   <script>
>> >> >>> >     var finalSubmit = null;
>> >> >>> >     function getXHR() {
>> >> >>> >       if (window.XMLHttpRequest) {
>> >> >>> >         return new XMLHttpRequest();
>> >> >>> >       } else if (window.ActiveXObject) {
>> >> >>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>> >> >>> >       }
>> >> >>> >     }
>> >> >>> >     function submitAll() {
>> >> >>> >       var tab1Form = dojo.io.encodeForm(
>> >> >>> >         document.getElementById("tab1Form"));
>> >> >>> >       var tab2Form = dojo.io.encodeForm(
>> >> >>> >         document.getElementById("tab2Form"));
>> >> >>> >       finalSubmit = getXHR();
>> >> >>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>> >> >>> >       finalSubmit.open("POST", "final.do", true);
>> >> >>> >       finalSubmit.send(tab1Form + tab2Form);
>> >> >>> >     }
>> >> >>> >     function finalSubmitCallback() {
>> >> >>> >       if (finalSubmit.readyState == 4) {
>> >> >>> >         document.getElementById("divResult").innerHTML =
>> >> >>> > finalSubmit.responseText;
>> >> >>> >       }
>> >> >>> >     }
>> >> >>> >   </script>
>> >> >>> > </head>
>> >> >>> > <body onload="init();">
>> >> >>> >   <form name="masterForm" id="tab1Form" method="post"
>> >> >>> > action="/test/tab1.do">
>> >> >>> >     Field1: <input name="tab1Form.field1" value="val1"
>> >> >>> type="text"><br>
>> >> >>> >   </form>
>> >> >>> >   <br>
>> >> >>> >   <form name="masterForm" id="tab2Form" method="post"
>> >> >>> > action="/test/tab2.do">
>> >> >>> >     Field2: <input name="tab2Form.field2" value="val2"
>> >> >>> type="text"><br>
>> >> >>> >   </form>
>> >> >>> >   <br>
>> >> >>> >   <input value="Submit All" onclick="submitAll();"
>> type="button">
>> >> >>> >   <br><br>
>> >> >>> >   <div id="divResult"></div>
>> >> >>> > </body>
>> >> >>> > </html>
>> >> >>> >
>> >> >>> >
>> >> >>> > Note that I removed all the Dojo-related stuff, and some stuff
>> >> that
>> >> >>> isn't
>> >> >>> > related to this submissino, just to try and keep it small, but,
>> >> the
>> >> >>> > important thing to note is that when the submission is made,
>> the
>> >> >>> request
>> >> >>> > that goes across is a POST to
>> http://localhost:8080/test/final.do,
>> >> as
>> >> >>> > expected, and the POST body is:
>> >> >>> >
>> >> >>> > tab1Form.field1=val1&tab2Form.field2=val2&
>> >> >>> >
>> >> >>> > ...also as expected, verified in Firebug.  Lastly, here's
>> >> >>> struts-config:
>> >> >>> >
>> >> >>> >
>> >> >>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>> >> >>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software
>> Foundation//DTD
>> >> >>> Struts
>> >> >>> > Configuration 1.2//EN"
>> >> >>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>> >> >>> > <struts-config>
>> >> >>> >   <form-beans>
>> >> >>> >     <form-bean name="masterForm"
>> >> type="app.test.formbeans.MasterForm"
>> >> >>> />
>> >> >>> >   </form-beans>
>> >> >>> >   <action-mappings>
>> >> >>> >     <action path="/final" type="app.test.actions.FinalAction"
>> >> >>> > name="masterForm" scope="request" validate="false">
>> >> >>> >       <forward name="defaultForward" path="/final.jsp" />
>> >> >>> >     </action>
>> >> >>> >   </action-mappings>
>> >> >>> > </struts-config>
>> >> >>> >
>> >> >>> >
>> >> >>> > Note here that I removed the stuff that generated the markup
>> from
>> >> >>> above
>> >> >>> > too, since that seems to be working just fine, I'm pretty sure
>> >> this
>> >> >>> is
>> >> >>> all
>> >> >>> > that would be relevant.
>> >> >>> >
>> >> >>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>> >> >>> >
>> >> >>> > Frank
>> >> >>> >
>> >> >>> >
>> >> >>> > --
>> >> >>> > Frank W. Zammetti
>> >> >>> > Founder and Chief Software Architect
>> >> >>> > Omnytex Technologies
>> >> >>> > http://www.omnytex.com
>> >> >>> > AIM/Yahoo: fzammetti
>> >> >>> > MSN: fzammetti@hotmail.com
>> >> >>> > Author of "Practical Ajax Projects With Java Technology"
>> >> >>> >  (2006, Apress, ISBN 1-59059-695-1)
>> >> >>> > Java Web Parts - http://javawebparts.sourceforge.net
>> >> >>> >  Supplying the wheel, so you don't have to reinvent it!
>> >> >>> >
>> >> >>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>> >> >>> >> So what does happen when you submit the form?  Are you getting
>> >> NPEs?
>> >> >>> >>
>> >> >>> >> By the time Struts attempts to populate the form bean, the
>> nested
>> >> >>> >> forms should already be instantiated.  You should have getters
>> >> and
>> >> >>> >> setters for af1 and af2, and getAf1() and getAf2() should not
>> >> return
>> >> >>> a
>> >> >>> >> null.  This could be an issue if the form bean is new, either
>> >> >>> because
>> >> >>> >> it's in request scope, or in session scope but was not
>> previously
>> >> >>> >> instantiated.
>> >> >>> >>
>> >> >>> >> Hubert
>> >> >>> >>
>> >> >>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >> >>> >>> I'm facing a situation where ideally I'd like to have a
>> single
>> >> >>> >>> ActionForm
>> >> >>> >>> like so:
>> >> >>> >>>
>> >> >>> >>> public class MyActionForm extends ActionForm {
>> >> >>> >>>   AnotherActionForm1 af1;
>> >> >>> >>>   AnotherActionForm2 af2;
>> >> >>> >>> }
>> >> >>> >>>
>> >> >>> >>> When in my JSP I do:
>> >> >>> >>>
>> >> >>> >>> <html:text property="af1.field1" />
>> >> >>> >>>
>> >> >>> >>> ...I do indeed see the value as I expect.  The way I did this
>> is
>> >> to
>> >> >>> >>> have
>> >> >>> >>> an Action mapping that references MyActionForm, then within
>> the
>> >> >>> Action
>> >> >>> >>> I
>> >> >>> >>> instantiate AnotherActionForm1, set the value of field1 on
>> it,
>> >> and
>> >> >>> then
>> >> >>> >>> set af1 to that new AnotherActionForm1 instance.  That all
>> works
>> >> >>> >>> nicely.
>> >> >>> >>>
>> >> >>> >>> Here's where I run into a problem...
>> >> >>> >>>
>> >> >>> >>> On the page I basically have 2 separate HTML forms, one for
>> >> >>> >>> AnotherActionForm1 and another for AnotherActionForm2.
>> However,
>> >> I
>> >> >>> have
>> >> >>> >>> a
>> >> >>> >>> SINGLE submit button at the end (just plain button that makes
>> an
>> >> >>> AJAX
>> >> >>> >>> request).  onClick of that button, I create a query string
>> from
>> >> the
>> >> >>> >>> values
>> >> >>> >>> of both forms, and make a request to the server with the
>> query
>> >> >>> string
>> >> >>> >>> attached.  The parameter names of the query string arguments
>> are
>> >> >>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.
>> The
>> >> >>> >>> mapping
>> >> >>> >>> that the request goes to again references MyActionForm.
>> >> >>> >>>
>> >> >>> >>> What I've been told should happen is that Struts should be
>> able
>> >> to
>> >> >>> >>> instantiate those two nested beans and set the properties,
>> since
>> >> >>> the
>> >> >>> >>> parameter names give it the information it needs.  This does
>> not
>> >> >>> >>> however
>> >> >>> >>> seem to be happening.
>> >> >>> >>>
>> >> >>> >>> So, two questions... first, is that in fact the expected
>> >> >>> behavoir?  And
>> >> >>> >>> two, if so, any ideas what I'm doing wrong?  I can post all
>> the
>> >> >>> >>> pertinent
>> >> >>> >>> config and code, but thought it might be something more
>> generic
>> >> >>> that
>> >> >>> >>> wouldn't require all that.  This is the first time I've ever
>> had
>> >> a
>> >> >>> need
>> >> >>> >>> to
>> >> >>> >>> nest forms like this, so it's a new question for me.
>> >> >>> >>>
>> >> >>> >>> Thanks all!
>> >> >>> >>>
>> >> >>> >>> Frank
>> >> >>> >>>
>> >> >>> >>>
>> >> >>> >>> --
>> >> >>> >>> Frank W. Zammetti
>> >> >>> >>> Founder and Chief Software Architect
>> >> >>> >>> Omnytex Technologies
>> >> >>> >>> http://www.omnytex.com
>> >> >>> >>> AIM/Yahoo: fzammetti
>> >> >>> >>> MSN: fzammetti@hotmail.com
>> >> >>> >>> Author of "Practical Ajax Projects With Java Technology"
>> >> >>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>> >> >>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>> >> >>> >>>  Supplying the wheel, so you don't have to reinvent it!
>> >> >>> >>>
>> >> >>> >>> ---------------------------------------------------------------------
>> >> >>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> >>> For additional commands, e-mail: user-help@struts.apache.org
>> >> >>> >>>
>> >> >>> >>>
>> >> >>> >>
>> >> >>> >> ---------------------------------------------------------------------
>> >> >>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >> >>> >>
>> >> >>> >>
>> >> >>> >
>> >> >>> >
>> >> >>> > ---------------------------------------------------------------------
>> >> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> > For additional commands, e-mail: user-help@struts.apache.org
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >> >>>
>> >> >>> ---------------------------------------------------------------------
>> >> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>> For additional commands, e-mail: user-help@struts.apache.org
>> >> >>>
>> >> >>>
>> >> >>
>> >> >
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> > For additional commands, e-mail: user-help@struts.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by Hubert Rabago <hr...@gmail.com>.
I can't see anything that would cause your problem.
I guess if it were me, I'd fire up my debugger and start stepping
through some code.
Sorry.
All I can say at this point is that I know what you're doing is
possible cause that's how FormDef does nested beans.

Hubert

On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> Hehe, way ahead of you :)  I put logging in every method... constructors,
> getters setter, all three forms.  Here's the output:
>
> MasterForm constructor
> Tab1Form constructor
> Tab2Form constructor
> --NOW IN JSP--
> MasterForm getTab1Form() = app.test.formbeans.Tab1Form@8ab08f
> MasterForm getTab2Form() = app.test.formbeans.Tab2Form@14d921a
> getting field1 = null
> getting field2 = null
>
> Notice the fields don't get set, nor do the subbeans get set on the
> containing bean.  The MasterForm constructor instantiates Tab1Form and
> Tab2Form, as the output indicates.
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> On Fri, September 22, 2006 2:53 pm, Hubert Rabago wrote:
> > It still sounds like Struts is getting nulls for the subbeans when it
> > tries to populate subbean.fieldX.  Put some more logging, this time in
> > the getters for the subbean in MasterForm, and log what it's
> > returning.
> >
> > Hubert
> >
> > On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >> As a follow-up, I threw some logging in the field1 and field2 setters in
> >> the subbeans... they don't appear to ever get called.  I don't have to
> >> do
> >> anything special to tell Struts I'm using nested beans, do I?  I didn't
> >> think so...
> >>
> >> Frank
> >>
> >>
> >> --
> >> Frank W. Zammetti
> >> Founder and Chief Software Architect
> >> Omnytex Technologies
> >> http://www.omnytex.com
> >> AIM/Yahoo: fzammetti
> >> MSN: fzammetti@hotmail.com
> >> Author of "Practical Ajax Projects With Java Technology"
> >>  (2006, Apress, ISBN 1-59059-695-1)
> >> Java Web Parts - http://javawebparts.sourceforge.net
> >>  Supplying the wheel, so you don't have to reinvent it!
> >>
> >> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
> >> > Hi Chris.. thanks for the suggestion, I gave that a shot at one point
> >> > actually... what I get is now the fields in the subforms (I guess
> >> that's
> >> > as good a term as any!) don't get set...
> >> >
> >> > masterForm = app.test.formbeans.MasterForm@141fab6
> >> > tab1Form = app.test.formbeans.Tab1Form@b301f2
> >> > tab2Form = app.test.formbeans.Tab2Form@44cbbe
> >> > field1 = null
> >> > field2 = null
> >> >
> >> > That's what I see in my final JSP output.
> >> >
> >> > Frank
> >> >
> >> >
> >> > --
> >> > Frank W. Zammetti
> >> > Founder and Chief Software Architect
> >> > Omnytex Technologies
> >> > http://www.omnytex.com
> >> > AIM/Yahoo: fzammetti
> >> > MSN: fzammetti@hotmail.com
> >> > Author of "Practical Ajax Projects With Java Technology"
> >> >  (2006, Apress, ISBN 1-59059-695-1)
> >> > Java Web Parts - http://javawebparts.sourceforge.net
> >> >  Supplying the wheel, so you don't have to reinvent it!
> >> >
> >> > On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
> >> >> In your no-arg constructor of your outer ActionForm (the container),
> >> >> make
> >> >> sure it instantiates each of the nested ActionForms using their
> >> no-arg
> >> >> constructors.
> >> >>   (*Chris*)
> >> >>
> >> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >> >>>
> >> >>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my
> >> >>> mistake
> >> >>> wasn't quite *THAT* obvious! ;) LOL
> >> >>>
> >> >>> Frank
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Frank W. Zammetti
> >> >>> Founder and Chief Software Architect
> >> >>> Omnytex Technologies
> >> >>> http://www.omnytex.com
> >> >>> AIM/Yahoo: fzammetti
> >> >>> MSN: fzammetti@hotmail.com
> >> >>> Author of "Practical Ajax Projects With Java Technology"
> >> >>> (2006, Apress, ISBN 1-59059-695-1)
> >> >>> Java Web Parts - http://javawebparts.sourceforge.net
> >> >>> Supplying the wheel, so you don't have to reinvent it!
> >> >>>
> >> >>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
> >> >>> > Hi Hubert,
> >> >>> >
> >> >>> > Yes, I get nulls for af1 and af2... I do have getters and setters
> >> for
> >> >>> > them.
> >> >>> >
> >> >>> > Lemme throw some data your way... I was hoping to avoid posting
> >> all
> >> >>> this,
> >> >>> > but I suspect there to be something my eyes just aren't catching,
> >> >>> so...
> >> >>> >
> >> >>> >
> >> >>> > Here's ActionForm1:
> >> >>> >
> >> >>> >
> >> >>> > package app.test.formbeans;
> >> >>> > import org.apache.struts.action.ActionForm;
> >> >>> > public class Action1Form extends ActionForm {
> >> >>> >   private String field1;
> >> >>> >   public void setField1(String inField1) {
> >> >>> >     this.field1 = inField1;
> >> >>> >   }
> >> >>> >   public String getField1() {
> >> >>> >     return this.field1;
> >> >>> >   }
> >> >>> > }
> >> >>> >
> >> >>> >
> >> >>> > ActionForm2 is identical, just replacing the number 1 with 2
> >> >>> everywhere.
> >> >>> > Here's MasterForm:
> >> >>> >
> >> >>> >
> >> >>> > package app.test.formbeans;
> >> >>> > import org.apache.struts.action.ActionForm;
> >> >>> > public class MasterForm extends ActionForm {
> >> >>> >   public Action1Form action1Form;
> >> >>> >   public Action2Form action2Form;
> >> >>> >   public void setAction1Form(Action1Form inAction1Form) {
> >> >>> >     this.action1Form = inAction1Form;
> >> >>> >   }
> >> >>> >   public Action1Form getAction1Form() {
> >> >>> >     return this.action1Form;
> >> >>> >   }
> >> >>> >   public void setAction2Form(Action2Form inAction2Form) {
> >> >>> >     this.action2Form = inAction2Form;
> >> >>> >   }
> >> >>> >   public Action2Form getAction2Form() {
> >> >>> >     return this.action2Form;
> >> >>> >   }
> >> >>> > }
> >> >>> >
> >> >>> >
> >> >>> > The Action everything gets submitted to is just a ForwardAction,
> >> >>> which
> >> >>> > forwards to:
> >> >>> >
> >> >>> >
> >> >>> > <%@ page language="java" import="app.test.formbeans.*" %>
> >> >>> > <%
> >> >>> >   MasterForm masterForm =
> >> >>> (MasterForm)request.getAttribute("masterForm");
> >> >>> > %>
> >> >>> > <%="masterForm = " + masterForm + "<br>"%>
> >> >>> > <%
> >> >>> >   Tab1Form tab1Form = null;
> >> >>> >   Tab2Form tab2Form = null;
> >> >>> >   if (masterForm != null) {
> >> >>> >     tab1Form = masterForm.getTab1Form();
> >> >>> >     tab2Form = masterForm.getTab2Form();
> >> >>> >   }
> >> >>> > %>
> >> >>> > <%="tab1Form = " + tab1Form + "<br>"%>
> >> >>> > <%="tab2Form = " + tab2Form + "<br>"%>
> >> >>> > <% if (tab1Form != null) { %>
> >> >>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
> >> >>> > <% } %>
> >> >>> > <% if (tab2Form != null) { %>
> >> >>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
> >> >>> > <% } %>
> >> >>> >
> >> >>> >
> >> >>> > The result I see from this is:
> >> >>> >
> >> >>> >
> >> >>> > masterForm = app.test.formbeans.MasterForm@e3849c
> >> >>> > tab1Form = null
> >> >>> > tab2Form = null
> >> >>> >
> >> >>> >
> >> >>> > The page that does that submit, in its final rendered form on the
> >> >>> client
> >> >>> > is:
> >> >>> >
> >> >>> >
> >> >>> > <html>
> >> >>> > <head>
> >> >>> >   <script>
> >> >>> >     var finalSubmit = null;
> >> >>> >     function getXHR() {
> >> >>> >       if (window.XMLHttpRequest) {
> >> >>> >         return new XMLHttpRequest();
> >> >>> >       } else if (window.ActiveXObject) {
> >> >>> >         return new ActiveXObject("Microsoft.XMLHTTP");
> >> >>> >       }
> >> >>> >     }
> >> >>> >     function submitAll() {
> >> >>> >       var tab1Form = dojo.io.encodeForm(
> >> >>> >         document.getElementById("tab1Form"));
> >> >>> >       var tab2Form = dojo.io.encodeForm(
> >> >>> >         document.getElementById("tab2Form"));
> >> >>> >       finalSubmit = getXHR();
> >> >>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
> >> >>> >       finalSubmit.open("POST", "final.do", true);
> >> >>> >       finalSubmit.send(tab1Form + tab2Form);
> >> >>> >     }
> >> >>> >     function finalSubmitCallback() {
> >> >>> >       if (finalSubmit.readyState == 4) {
> >> >>> >         document.getElementById("divResult").innerHTML =
> >> >>> > finalSubmit.responseText;
> >> >>> >       }
> >> >>> >     }
> >> >>> >   </script>
> >> >>> > </head>
> >> >>> > <body onload="init();">
> >> >>> >   <form name="masterForm" id="tab1Form" method="post"
> >> >>> > action="/test/tab1.do">
> >> >>> >     Field1: <input name="tab1Form.field1" value="val1"
> >> >>> type="text"><br>
> >> >>> >   </form>
> >> >>> >   <br>
> >> >>> >   <form name="masterForm" id="tab2Form" method="post"
> >> >>> > action="/test/tab2.do">
> >> >>> >     Field2: <input name="tab2Form.field2" value="val2"
> >> >>> type="text"><br>
> >> >>> >   </form>
> >> >>> >   <br>
> >> >>> >   <input value="Submit All" onclick="submitAll();" type="button">
> >> >>> >   <br><br>
> >> >>> >   <div id="divResult"></div>
> >> >>> > </body>
> >> >>> > </html>
> >> >>> >
> >> >>> >
> >> >>> > Note that I removed all the Dojo-related stuff, and some stuff
> >> that
> >> >>> isn't
> >> >>> > related to this submissino, just to try and keep it small, but,
> >> the
> >> >>> > important thing to note is that when the submission is made, the
> >> >>> request
> >> >>> > that goes across is a POST to http://localhost:8080/test/final.do,
> >> as
> >> >>> > expected, and the POST body is:
> >> >>> >
> >> >>> > tab1Form.field1=val1&tab2Form.field2=val2&
> >> >>> >
> >> >>> > ...also as expected, verified in Firebug.  Lastly, here's
> >> >>> struts-config:
> >> >>> >
> >> >>> >
> >> >>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> >> >>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
> >> >>> Struts
> >> >>> > Configuration 1.2//EN"
> >> >>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
> >> >>> > <struts-config>
> >> >>> >   <form-beans>
> >> >>> >     <form-bean name="masterForm"
> >> type="app.test.formbeans.MasterForm"
> >> >>> />
> >> >>> >   </form-beans>
> >> >>> >   <action-mappings>
> >> >>> >     <action path="/final" type="app.test.actions.FinalAction"
> >> >>> > name="masterForm" scope="request" validate="false">
> >> >>> >       <forward name="defaultForward" path="/final.jsp" />
> >> >>> >     </action>
> >> >>> >   </action-mappings>
> >> >>> > </struts-config>
> >> >>> >
> >> >>> >
> >> >>> > Note here that I removed the stuff that generated the markup from
> >> >>> above
> >> >>> > too, since that seems to be working just fine, I'm pretty sure
> >> this
> >> >>> is
> >> >>> all
> >> >>> > that would be relevant.
> >> >>> >
> >> >>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
> >> >>> >
> >> >>> > Frank
> >> >>> >
> >> >>> >
> >> >>> > --
> >> >>> > Frank W. Zammetti
> >> >>> > Founder and Chief Software Architect
> >> >>> > Omnytex Technologies
> >> >>> > http://www.omnytex.com
> >> >>> > AIM/Yahoo: fzammetti
> >> >>> > MSN: fzammetti@hotmail.com
> >> >>> > Author of "Practical Ajax Projects With Java Technology"
> >> >>> >  (2006, Apress, ISBN 1-59059-695-1)
> >> >>> > Java Web Parts - http://javawebparts.sourceforge.net
> >> >>> >  Supplying the wheel, so you don't have to reinvent it!
> >> >>> >
> >> >>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
> >> >>> >> So what does happen when you submit the form?  Are you getting
> >> NPEs?
> >> >>> >>
> >> >>> >> By the time Struts attempts to populate the form bean, the nested
> >> >>> >> forms should already be instantiated.  You should have getters
> >> and
> >> >>> >> setters for af1 and af2, and getAf1() and getAf2() should not
> >> return
> >> >>> a
> >> >>> >> null.  This could be an issue if the form bean is new, either
> >> >>> because
> >> >>> >> it's in request scope, or in session scope but was not previously
> >> >>> >> instantiated.
> >> >>> >>
> >> >>> >> Hubert
> >> >>> >>
> >> >>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >> >>> >>> I'm facing a situation where ideally I'd like to have a single
> >> >>> >>> ActionForm
> >> >>> >>> like so:
> >> >>> >>>
> >> >>> >>> public class MyActionForm extends ActionForm {
> >> >>> >>>   AnotherActionForm1 af1;
> >> >>> >>>   AnotherActionForm2 af2;
> >> >>> >>> }
> >> >>> >>>
> >> >>> >>> When in my JSP I do:
> >> >>> >>>
> >> >>> >>> <html:text property="af1.field1" />
> >> >>> >>>
> >> >>> >>> ...I do indeed see the value as I expect.  The way I did this is
> >> to
> >> >>> >>> have
> >> >>> >>> an Action mapping that references MyActionForm, then within the
> >> >>> Action
> >> >>> >>> I
> >> >>> >>> instantiate AnotherActionForm1, set the value of field1 on it,
> >> and
> >> >>> then
> >> >>> >>> set af1 to that new AnotherActionForm1 instance.  That all works
> >> >>> >>> nicely.
> >> >>> >>>
> >> >>> >>> Here's where I run into a problem...
> >> >>> >>>
> >> >>> >>> On the page I basically have 2 separate HTML forms, one for
> >> >>> >>> AnotherActionForm1 and another for AnotherActionForm2.  However,
> >> I
> >> >>> have
> >> >>> >>> a
> >> >>> >>> SINGLE submit button at the end (just plain button that makes an
> >> >>> AJAX
> >> >>> >>> request).  onClick of that button, I create a query string from
> >> the
> >> >>> >>> values
> >> >>> >>> of both forms, and make a request to the server with the query
> >> >>> string
> >> >>> >>> attached.  The parameter names of the query string arguments are
> >> >>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
> >> >>> >>> mapping
> >> >>> >>> that the request goes to again references MyActionForm.
> >> >>> >>>
> >> >>> >>> What I've been told should happen is that Struts should be able
> >> to
> >> >>> >>> instantiate those two nested beans and set the properties, since
> >> >>> the
> >> >>> >>> parameter names give it the information it needs.  This does not
> >> >>> >>> however
> >> >>> >>> seem to be happening.
> >> >>> >>>
> >> >>> >>> So, two questions... first, is that in fact the expected
> >> >>> behavoir?  And
> >> >>> >>> two, if so, any ideas what I'm doing wrong?  I can post all the
> >> >>> >>> pertinent
> >> >>> >>> config and code, but thought it might be something more generic
> >> >>> that
> >> >>> >>> wouldn't require all that.  This is the first time I've ever had
> >> a
> >> >>> need
> >> >>> >>> to
> >> >>> >>> nest forms like this, so it's a new question for me.
> >> >>> >>>
> >> >>> >>> Thanks all!
> >> >>> >>>
> >> >>> >>> Frank
> >> >>> >>>
> >> >>> >>>
> >> >>> >>> --
> >> >>> >>> Frank W. Zammetti
> >> >>> >>> Founder and Chief Software Architect
> >> >>> >>> Omnytex Technologies
> >> >>> >>> http://www.omnytex.com
> >> >>> >>> AIM/Yahoo: fzammetti
> >> >>> >>> MSN: fzammetti@hotmail.com
> >> >>> >>> Author of "Practical Ajax Projects With Java Technology"
> >> >>> >>>  (2006, Apress, ISBN 1-59059-695-1)
> >> >>> >>> Java Web Parts - http://javawebparts.sourceforge.net
> >> >>> >>>  Supplying the wheel, so you don't have to reinvent it!
> >> >>> >>>
> >> >>> >>> ---------------------------------------------------------------------
> >> >>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> >>> >>> For additional commands, e-mail: user-help@struts.apache.org
> >> >>> >>>
> >> >>> >>>
> >> >>> >>
> >> >>> >> ---------------------------------------------------------------------
> >> >>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> >>> >> For additional commands, e-mail: user-help@struts.apache.org
> >> >>> >>
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>> > ---------------------------------------------------------------------
> >> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> >>> > For additional commands, e-mail: user-help@struts.apache.org
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> >>> For additional commands, e-mail: user-help@struts.apache.org
> >> >>>
> >> >>>
> >> >>
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Hehe, way ahead of you :)  I put logging in every method... constructors,
getters setter, all three forms.  Here's the output:

MasterForm constructor
Tab1Form constructor
Tab2Form constructor
--NOW IN JSP--
MasterForm getTab1Form() = app.test.formbeans.Tab1Form@8ab08f
MasterForm getTab2Form() = app.test.formbeans.Tab2Form@14d921a
getting field1 = null
getting field2 = null

Notice the fields don't get set, nor do the subbeans get set on the
containing bean.  The MasterForm constructor instantiates Tab1Form and
Tab2Form, as the output indicates.

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 2:53 pm, Hubert Rabago wrote:
> It still sounds like Struts is getting nulls for the subbeans when it
> tries to populate subbean.fieldX.  Put some more logging, this time in
> the getters for the subbean in MasterForm, and log what it's
> returning.
>
> Hubert
>
> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> As a follow-up, I threw some logging in the field1 and field2 setters in
>> the subbeans... they don't appear to ever get called.  I don't have to
>> do
>> anything special to tell Struts I'm using nested beans, do I?  I didn't
>> think so...
>>
>> Frank
>>
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>>  (2006, Apress, ISBN 1-59059-695-1)
>> Java Web Parts - http://javawebparts.sourceforge.net
>>  Supplying the wheel, so you don't have to reinvent it!
>>
>> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
>> > Hi Chris.. thanks for the suggestion, I gave that a shot at one point
>> > actually... what I get is now the fields in the subforms (I guess
>> that's
>> > as good a term as any!) don't get set...
>> >
>> > masterForm = app.test.formbeans.MasterForm@141fab6
>> > tab1Form = app.test.formbeans.Tab1Form@b301f2
>> > tab2Form = app.test.formbeans.Tab2Form@44cbbe
>> > field1 = null
>> > field2 = null
>> >
>> > That's what I see in my final JSP output.
>> >
>> > Frank
>> >
>> >
>> > --
>> > Frank W. Zammetti
>> > Founder and Chief Software Architect
>> > Omnytex Technologies
>> > http://www.omnytex.com
>> > AIM/Yahoo: fzammetti
>> > MSN: fzammetti@hotmail.com
>> > Author of "Practical Ajax Projects With Java Technology"
>> >  (2006, Apress, ISBN 1-59059-695-1)
>> > Java Web Parts - http://javawebparts.sourceforge.net
>> >  Supplying the wheel, so you don't have to reinvent it!
>> >
>> > On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
>> >> In your no-arg constructor of your outer ActionForm (the container),
>> >> make
>> >> sure it instantiates each of the nested ActionForms using their
>> no-arg
>> >> constructors.
>> >>   (*Chris*)
>> >>
>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >>>
>> >>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my
>> >>> mistake
>> >>> wasn't quite *THAT* obvious! ;) LOL
>> >>>
>> >>> Frank
>> >>>
>> >>>
>> >>> --
>> >>> Frank W. Zammetti
>> >>> Founder and Chief Software Architect
>> >>> Omnytex Technologies
>> >>> http://www.omnytex.com
>> >>> AIM/Yahoo: fzammetti
>> >>> MSN: fzammetti@hotmail.com
>> >>> Author of "Practical Ajax Projects With Java Technology"
>> >>> (2006, Apress, ISBN 1-59059-695-1)
>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>> >>> Supplying the wheel, so you don't have to reinvent it!
>> >>>
>> >>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>> >>> > Hi Hubert,
>> >>> >
>> >>> > Yes, I get nulls for af1 and af2... I do have getters and setters
>> for
>> >>> > them.
>> >>> >
>> >>> > Lemme throw some data your way... I was hoping to avoid posting
>> all
>> >>> this,
>> >>> > but I suspect there to be something my eyes just aren't catching,
>> >>> so...
>> >>> >
>> >>> >
>> >>> > Here's ActionForm1:
>> >>> >
>> >>> >
>> >>> > package app.test.formbeans;
>> >>> > import org.apache.struts.action.ActionForm;
>> >>> > public class Action1Form extends ActionForm {
>> >>> >   private String field1;
>> >>> >   public void setField1(String inField1) {
>> >>> >     this.field1 = inField1;
>> >>> >   }
>> >>> >   public String getField1() {
>> >>> >     return this.field1;
>> >>> >   }
>> >>> > }
>> >>> >
>> >>> >
>> >>> > ActionForm2 is identical, just replacing the number 1 with 2
>> >>> everywhere.
>> >>> > Here's MasterForm:
>> >>> >
>> >>> >
>> >>> > package app.test.formbeans;
>> >>> > import org.apache.struts.action.ActionForm;
>> >>> > public class MasterForm extends ActionForm {
>> >>> >   public Action1Form action1Form;
>> >>> >   public Action2Form action2Form;
>> >>> >   public void setAction1Form(Action1Form inAction1Form) {
>> >>> >     this.action1Form = inAction1Form;
>> >>> >   }
>> >>> >   public Action1Form getAction1Form() {
>> >>> >     return this.action1Form;
>> >>> >   }
>> >>> >   public void setAction2Form(Action2Form inAction2Form) {
>> >>> >     this.action2Form = inAction2Form;
>> >>> >   }
>> >>> >   public Action2Form getAction2Form() {
>> >>> >     return this.action2Form;
>> >>> >   }
>> >>> > }
>> >>> >
>> >>> >
>> >>> > The Action everything gets submitted to is just a ForwardAction,
>> >>> which
>> >>> > forwards to:
>> >>> >
>> >>> >
>> >>> > <%@ page language="java" import="app.test.formbeans.*" %>
>> >>> > <%
>> >>> >   MasterForm masterForm =
>> >>> (MasterForm)request.getAttribute("masterForm");
>> >>> > %>
>> >>> > <%="masterForm = " + masterForm + "<br>"%>
>> >>> > <%
>> >>> >   Tab1Form tab1Form = null;
>> >>> >   Tab2Form tab2Form = null;
>> >>> >   if (masterForm != null) {
>> >>> >     tab1Form = masterForm.getTab1Form();
>> >>> >     tab2Form = masterForm.getTab2Form();
>> >>> >   }
>> >>> > %>
>> >>> > <%="tab1Form = " + tab1Form + "<br>"%>
>> >>> > <%="tab2Form = " + tab2Form + "<br>"%>
>> >>> > <% if (tab1Form != null) { %>
>> >>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>> >>> > <% } %>
>> >>> > <% if (tab2Form != null) { %>
>> >>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>> >>> > <% } %>
>> >>> >
>> >>> >
>> >>> > The result I see from this is:
>> >>> >
>> >>> >
>> >>> > masterForm = app.test.formbeans.MasterForm@e3849c
>> >>> > tab1Form = null
>> >>> > tab2Form = null
>> >>> >
>> >>> >
>> >>> > The page that does that submit, in its final rendered form on the
>> >>> client
>> >>> > is:
>> >>> >
>> >>> >
>> >>> > <html>
>> >>> > <head>
>> >>> >   <script>
>> >>> >     var finalSubmit = null;
>> >>> >     function getXHR() {
>> >>> >       if (window.XMLHttpRequest) {
>> >>> >         return new XMLHttpRequest();
>> >>> >       } else if (window.ActiveXObject) {
>> >>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>> >>> >       }
>> >>> >     }
>> >>> >     function submitAll() {
>> >>> >       var tab1Form = dojo.io.encodeForm(
>> >>> >         document.getElementById("tab1Form"));
>> >>> >       var tab2Form = dojo.io.encodeForm(
>> >>> >         document.getElementById("tab2Form"));
>> >>> >       finalSubmit = getXHR();
>> >>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>> >>> >       finalSubmit.open("POST", "final.do", true);
>> >>> >       finalSubmit.send(tab1Form + tab2Form);
>> >>> >     }
>> >>> >     function finalSubmitCallback() {
>> >>> >       if (finalSubmit.readyState == 4) {
>> >>> >         document.getElementById("divResult").innerHTML =
>> >>> > finalSubmit.responseText;
>> >>> >       }
>> >>> >     }
>> >>> >   </script>
>> >>> > </head>
>> >>> > <body onload="init();">
>> >>> >   <form name="masterForm" id="tab1Form" method="post"
>> >>> > action="/test/tab1.do">
>> >>> >     Field1: <input name="tab1Form.field1" value="val1"
>> >>> type="text"><br>
>> >>> >   </form>
>> >>> >   <br>
>> >>> >   <form name="masterForm" id="tab2Form" method="post"
>> >>> > action="/test/tab2.do">
>> >>> >     Field2: <input name="tab2Form.field2" value="val2"
>> >>> type="text"><br>
>> >>> >   </form>
>> >>> >   <br>
>> >>> >   <input value="Submit All" onclick="submitAll();" type="button">
>> >>> >   <br><br>
>> >>> >   <div id="divResult"></div>
>> >>> > </body>
>> >>> > </html>
>> >>> >
>> >>> >
>> >>> > Note that I removed all the Dojo-related stuff, and some stuff
>> that
>> >>> isn't
>> >>> > related to this submissino, just to try and keep it small, but,
>> the
>> >>> > important thing to note is that when the submission is made, the
>> >>> request
>> >>> > that goes across is a POST to http://localhost:8080/test/final.do,
>> as
>> >>> > expected, and the POST body is:
>> >>> >
>> >>> > tab1Form.field1=val1&tab2Form.field2=val2&
>> >>> >
>> >>> > ...also as expected, verified in Firebug.  Lastly, here's
>> >>> struts-config:
>> >>> >
>> >>> >
>> >>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>> >>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
>> >>> Struts
>> >>> > Configuration 1.2//EN"
>> >>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>> >>> > <struts-config>
>> >>> >   <form-beans>
>> >>> >     <form-bean name="masterForm"
>> type="app.test.formbeans.MasterForm"
>> >>> />
>> >>> >   </form-beans>
>> >>> >   <action-mappings>
>> >>> >     <action path="/final" type="app.test.actions.FinalAction"
>> >>> > name="masterForm" scope="request" validate="false">
>> >>> >       <forward name="defaultForward" path="/final.jsp" />
>> >>> >     </action>
>> >>> >   </action-mappings>
>> >>> > </struts-config>
>> >>> >
>> >>> >
>> >>> > Note here that I removed the stuff that generated the markup from
>> >>> above
>> >>> > too, since that seems to be working just fine, I'm pretty sure
>> this
>> >>> is
>> >>> all
>> >>> > that would be relevant.
>> >>> >
>> >>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>> >>> >
>> >>> > Frank
>> >>> >
>> >>> >
>> >>> > --
>> >>> > Frank W. Zammetti
>> >>> > Founder and Chief Software Architect
>> >>> > Omnytex Technologies
>> >>> > http://www.omnytex.com
>> >>> > AIM/Yahoo: fzammetti
>> >>> > MSN: fzammetti@hotmail.com
>> >>> > Author of "Practical Ajax Projects With Java Technology"
>> >>> >  (2006, Apress, ISBN 1-59059-695-1)
>> >>> > Java Web Parts - http://javawebparts.sourceforge.net
>> >>> >  Supplying the wheel, so you don't have to reinvent it!
>> >>> >
>> >>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>> >>> >> So what does happen when you submit the form?  Are you getting
>> NPEs?
>> >>> >>
>> >>> >> By the time Struts attempts to populate the form bean, the nested
>> >>> >> forms should already be instantiated.  You should have getters
>> and
>> >>> >> setters for af1 and af2, and getAf1() and getAf2() should not
>> return
>> >>> a
>> >>> >> null.  This could be an issue if the form bean is new, either
>> >>> because
>> >>> >> it's in request scope, or in session scope but was not previously
>> >>> >> instantiated.
>> >>> >>
>> >>> >> Hubert
>> >>> >>
>> >>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >>> >>> I'm facing a situation where ideally I'd like to have a single
>> >>> >>> ActionForm
>> >>> >>> like so:
>> >>> >>>
>> >>> >>> public class MyActionForm extends ActionForm {
>> >>> >>>   AnotherActionForm1 af1;
>> >>> >>>   AnotherActionForm2 af2;
>> >>> >>> }
>> >>> >>>
>> >>> >>> When in my JSP I do:
>> >>> >>>
>> >>> >>> <html:text property="af1.field1" />
>> >>> >>>
>> >>> >>> ...I do indeed see the value as I expect.  The way I did this is
>> to
>> >>> >>> have
>> >>> >>> an Action mapping that references MyActionForm, then within the
>> >>> Action
>> >>> >>> I
>> >>> >>> instantiate AnotherActionForm1, set the value of field1 on it,
>> and
>> >>> then
>> >>> >>> set af1 to that new AnotherActionForm1 instance.  That all works
>> >>> >>> nicely.
>> >>> >>>
>> >>> >>> Here's where I run into a problem...
>> >>> >>>
>> >>> >>> On the page I basically have 2 separate HTML forms, one for
>> >>> >>> AnotherActionForm1 and another for AnotherActionForm2.  However,
>> I
>> >>> have
>> >>> >>> a
>> >>> >>> SINGLE submit button at the end (just plain button that makes an
>> >>> AJAX
>> >>> >>> request).  onClick of that button, I create a query string from
>> the
>> >>> >>> values
>> >>> >>> of both forms, and make a request to the server with the query
>> >>> string
>> >>> >>> attached.  The parameter names of the query string arguments are
>> >>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
>> >>> >>> mapping
>> >>> >>> that the request goes to again references MyActionForm.
>> >>> >>>
>> >>> >>> What I've been told should happen is that Struts should be able
>> to
>> >>> >>> instantiate those two nested beans and set the properties, since
>> >>> the
>> >>> >>> parameter names give it the information it needs.  This does not
>> >>> >>> however
>> >>> >>> seem to be happening.
>> >>> >>>
>> >>> >>> So, two questions... first, is that in fact the expected
>> >>> behavoir?  And
>> >>> >>> two, if so, any ideas what I'm doing wrong?  I can post all the
>> >>> >>> pertinent
>> >>> >>> config and code, but thought it might be something more generic
>> >>> that
>> >>> >>> wouldn't require all that.  This is the first time I've ever had
>> a
>> >>> need
>> >>> >>> to
>> >>> >>> nest forms like this, so it's a new question for me.
>> >>> >>>
>> >>> >>> Thanks all!
>> >>> >>>
>> >>> >>> Frank
>> >>> >>>
>> >>> >>>
>> >>> >>> --
>> >>> >>> Frank W. Zammetti
>> >>> >>> Founder and Chief Software Architect
>> >>> >>> Omnytex Technologies
>> >>> >>> http://www.omnytex.com
>> >>> >>> AIM/Yahoo: fzammetti
>> >>> >>> MSN: fzammetti@hotmail.com
>> >>> >>> Author of "Practical Ajax Projects With Java Technology"
>> >>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>> >>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>> >>> >>>  Supplying the wheel, so you don't have to reinvent it!
>> >>> >>>
>> >>> >>> ---------------------------------------------------------------------
>> >>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >>> >>> For additional commands, e-mail: user-help@struts.apache.org
>> >>> >>>
>> >>> >>>
>> >>> >>
>> >>> >> ---------------------------------------------------------------------
>> >>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>> >>
>> >>> >>
>> >>> >
>> >>> >
>> >>> > ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >>> > For additional commands, e-mail: user-help@struts.apache.org
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >>> For additional commands, e-mail: user-help@struts.apache.org
>> >>>
>> >>>
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by Hubert Rabago <hr...@gmail.com>.
It still sounds like Struts is getting nulls for the subbeans when it
tries to populate subbean.fieldX.  Put some more logging, this time in
the getters for the subbean in MasterForm, and log what it's
returning.

Hubert

On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> As a follow-up, I threw some logging in the field1 and field2 setters in
> the subbeans... they don't appear to ever get called.  I don't have to do
> anything special to tell Struts I'm using nested beans, do I?  I didn't
> think so...
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
> > Hi Chris.. thanks for the suggestion, I gave that a shot at one point
> > actually... what I get is now the fields in the subforms (I guess that's
> > as good a term as any!) don't get set...
> >
> > masterForm = app.test.formbeans.MasterForm@141fab6
> > tab1Form = app.test.formbeans.Tab1Form@b301f2
> > tab2Form = app.test.formbeans.Tab2Form@44cbbe
> > field1 = null
> > field2 = null
> >
> > That's what I see in my final JSP output.
> >
> > Frank
> >
> >
> > --
> > Frank W. Zammetti
> > Founder and Chief Software Architect
> > Omnytex Technologies
> > http://www.omnytex.com
> > AIM/Yahoo: fzammetti
> > MSN: fzammetti@hotmail.com
> > Author of "Practical Ajax Projects With Java Technology"
> >  (2006, Apress, ISBN 1-59059-695-1)
> > Java Web Parts - http://javawebparts.sourceforge.net
> >  Supplying the wheel, so you don't have to reinvent it!
> >
> > On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
> >> In your no-arg constructor of your outer ActionForm (the container),
> >> make
> >> sure it instantiates each of the nested ActionForms using their no-arg
> >> constructors.
> >>   (*Chris*)
> >>
> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >>>
> >>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my
> >>> mistake
> >>> wasn't quite *THAT* obvious! ;) LOL
> >>>
> >>> Frank
> >>>
> >>>
> >>> --
> >>> Frank W. Zammetti
> >>> Founder and Chief Software Architect
> >>> Omnytex Technologies
> >>> http://www.omnytex.com
> >>> AIM/Yahoo: fzammetti
> >>> MSN: fzammetti@hotmail.com
> >>> Author of "Practical Ajax Projects With Java Technology"
> >>> (2006, Apress, ISBN 1-59059-695-1)
> >>> Java Web Parts - http://javawebparts.sourceforge.net
> >>> Supplying the wheel, so you don't have to reinvent it!
> >>>
> >>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
> >>> > Hi Hubert,
> >>> >
> >>> > Yes, I get nulls for af1 and af2... I do have getters and setters for
> >>> > them.
> >>> >
> >>> > Lemme throw some data your way... I was hoping to avoid posting all
> >>> this,
> >>> > but I suspect there to be something my eyes just aren't catching,
> >>> so...
> >>> >
> >>> >
> >>> > Here's ActionForm1:
> >>> >
> >>> >
> >>> > package app.test.formbeans;
> >>> > import org.apache.struts.action.ActionForm;
> >>> > public class Action1Form extends ActionForm {
> >>> >   private String field1;
> >>> >   public void setField1(String inField1) {
> >>> >     this.field1 = inField1;
> >>> >   }
> >>> >   public String getField1() {
> >>> >     return this.field1;
> >>> >   }
> >>> > }
> >>> >
> >>> >
> >>> > ActionForm2 is identical, just replacing the number 1 with 2
> >>> everywhere.
> >>> > Here's MasterForm:
> >>> >
> >>> >
> >>> > package app.test.formbeans;
> >>> > import org.apache.struts.action.ActionForm;
> >>> > public class MasterForm extends ActionForm {
> >>> >   public Action1Form action1Form;
> >>> >   public Action2Form action2Form;
> >>> >   public void setAction1Form(Action1Form inAction1Form) {
> >>> >     this.action1Form = inAction1Form;
> >>> >   }
> >>> >   public Action1Form getAction1Form() {
> >>> >     return this.action1Form;
> >>> >   }
> >>> >   public void setAction2Form(Action2Form inAction2Form) {
> >>> >     this.action2Form = inAction2Form;
> >>> >   }
> >>> >   public Action2Form getAction2Form() {
> >>> >     return this.action2Form;
> >>> >   }
> >>> > }
> >>> >
> >>> >
> >>> > The Action everything gets submitted to is just a ForwardAction,
> >>> which
> >>> > forwards to:
> >>> >
> >>> >
> >>> > <%@ page language="java" import="app.test.formbeans.*" %>
> >>> > <%
> >>> >   MasterForm masterForm =
> >>> (MasterForm)request.getAttribute("masterForm");
> >>> > %>
> >>> > <%="masterForm = " + masterForm + "<br>"%>
> >>> > <%
> >>> >   Tab1Form tab1Form = null;
> >>> >   Tab2Form tab2Form = null;
> >>> >   if (masterForm != null) {
> >>> >     tab1Form = masterForm.getTab1Form();
> >>> >     tab2Form = masterForm.getTab2Form();
> >>> >   }
> >>> > %>
> >>> > <%="tab1Form = " + tab1Form + "<br>"%>
> >>> > <%="tab2Form = " + tab2Form + "<br>"%>
> >>> > <% if (tab1Form != null) { %>
> >>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
> >>> > <% } %>
> >>> > <% if (tab2Form != null) { %>
> >>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
> >>> > <% } %>
> >>> >
> >>> >
> >>> > The result I see from this is:
> >>> >
> >>> >
> >>> > masterForm = app.test.formbeans.MasterForm@e3849c
> >>> > tab1Form = null
> >>> > tab2Form = null
> >>> >
> >>> >
> >>> > The page that does that submit, in its final rendered form on the
> >>> client
> >>> > is:
> >>> >
> >>> >
> >>> > <html>
> >>> > <head>
> >>> >   <script>
> >>> >     var finalSubmit = null;
> >>> >     function getXHR() {
> >>> >       if (window.XMLHttpRequest) {
> >>> >         return new XMLHttpRequest();
> >>> >       } else if (window.ActiveXObject) {
> >>> >         return new ActiveXObject("Microsoft.XMLHTTP");
> >>> >       }
> >>> >     }
> >>> >     function submitAll() {
> >>> >       var tab1Form = dojo.io.encodeForm(
> >>> >         document.getElementById("tab1Form"));
> >>> >       var tab2Form = dojo.io.encodeForm(
> >>> >         document.getElementById("tab2Form"));
> >>> >       finalSubmit = getXHR();
> >>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
> >>> >       finalSubmit.open("POST", "final.do", true);
> >>> >       finalSubmit.send(tab1Form + tab2Form);
> >>> >     }
> >>> >     function finalSubmitCallback() {
> >>> >       if (finalSubmit.readyState == 4) {
> >>> >         document.getElementById("divResult").innerHTML =
> >>> > finalSubmit.responseText;
> >>> >       }
> >>> >     }
> >>> >   </script>
> >>> > </head>
> >>> > <body onload="init();">
> >>> >   <form name="masterForm" id="tab1Form" method="post"
> >>> > action="/test/tab1.do">
> >>> >     Field1: <input name="tab1Form.field1" value="val1"
> >>> type="text"><br>
> >>> >   </form>
> >>> >   <br>
> >>> >   <form name="masterForm" id="tab2Form" method="post"
> >>> > action="/test/tab2.do">
> >>> >     Field2: <input name="tab2Form.field2" value="val2"
> >>> type="text"><br>
> >>> >   </form>
> >>> >   <br>
> >>> >   <input value="Submit All" onclick="submitAll();" type="button">
> >>> >   <br><br>
> >>> >   <div id="divResult"></div>
> >>> > </body>
> >>> > </html>
> >>> >
> >>> >
> >>> > Note that I removed all the Dojo-related stuff, and some stuff that
> >>> isn't
> >>> > related to this submissino, just to try and keep it small, but, the
> >>> > important thing to note is that when the submission is made, the
> >>> request
> >>> > that goes across is a POST to http://localhost:8080/test/final.do, as
> >>> > expected, and the POST body is:
> >>> >
> >>> > tab1Form.field1=val1&tab2Form.field2=val2&
> >>> >
> >>> > ...also as expected, verified in Firebug.  Lastly, here's
> >>> struts-config:
> >>> >
> >>> >
> >>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> >>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
> >>> Struts
> >>> > Configuration 1.2//EN"
> >>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
> >>> > <struts-config>
> >>> >   <form-beans>
> >>> >     <form-bean name="masterForm" type="app.test.formbeans.MasterForm"
> >>> />
> >>> >   </form-beans>
> >>> >   <action-mappings>
> >>> >     <action path="/final" type="app.test.actions.FinalAction"
> >>> > name="masterForm" scope="request" validate="false">
> >>> >       <forward name="defaultForward" path="/final.jsp" />
> >>> >     </action>
> >>> >   </action-mappings>
> >>> > </struts-config>
> >>> >
> >>> >
> >>> > Note here that I removed the stuff that generated the markup from
> >>> above
> >>> > too, since that seems to be working just fine, I'm pretty sure this
> >>> is
> >>> all
> >>> > that would be relevant.
> >>> >
> >>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
> >>> >
> >>> > Frank
> >>> >
> >>> >
> >>> > --
> >>> > Frank W. Zammetti
> >>> > Founder and Chief Software Architect
> >>> > Omnytex Technologies
> >>> > http://www.omnytex.com
> >>> > AIM/Yahoo: fzammetti
> >>> > MSN: fzammetti@hotmail.com
> >>> > Author of "Practical Ajax Projects With Java Technology"
> >>> >  (2006, Apress, ISBN 1-59059-695-1)
> >>> > Java Web Parts - http://javawebparts.sourceforge.net
> >>> >  Supplying the wheel, so you don't have to reinvent it!
> >>> >
> >>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
> >>> >> So what does happen when you submit the form?  Are you getting NPEs?
> >>> >>
> >>> >> By the time Struts attempts to populate the form bean, the nested
> >>> >> forms should already be instantiated.  You should have getters and
> >>> >> setters for af1 and af2, and getAf1() and getAf2() should not return
> >>> a
> >>> >> null.  This could be an issue if the form bean is new, either
> >>> because
> >>> >> it's in request scope, or in session scope but was not previously
> >>> >> instantiated.
> >>> >>
> >>> >> Hubert
> >>> >>
> >>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >>> >>> I'm facing a situation where ideally I'd like to have a single
> >>> >>> ActionForm
> >>> >>> like so:
> >>> >>>
> >>> >>> public class MyActionForm extends ActionForm {
> >>> >>>   AnotherActionForm1 af1;
> >>> >>>   AnotherActionForm2 af2;
> >>> >>> }
> >>> >>>
> >>> >>> When in my JSP I do:
> >>> >>>
> >>> >>> <html:text property="af1.field1" />
> >>> >>>
> >>> >>> ...I do indeed see the value as I expect.  The way I did this is to
> >>> >>> have
> >>> >>> an Action mapping that references MyActionForm, then within the
> >>> Action
> >>> >>> I
> >>> >>> instantiate AnotherActionForm1, set the value of field1 on it, and
> >>> then
> >>> >>> set af1 to that new AnotherActionForm1 instance.  That all works
> >>> >>> nicely.
> >>> >>>
> >>> >>> Here's where I run into a problem...
> >>> >>>
> >>> >>> On the page I basically have 2 separate HTML forms, one for
> >>> >>> AnotherActionForm1 and another for AnotherActionForm2.  However, I
> >>> have
> >>> >>> a
> >>> >>> SINGLE submit button at the end (just plain button that makes an
> >>> AJAX
> >>> >>> request).  onClick of that button, I create a query string from the
> >>> >>> values
> >>> >>> of both forms, and make a request to the server with the query
> >>> string
> >>> >>> attached.  The parameter names of the query string arguments are
> >>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
> >>> >>> mapping
> >>> >>> that the request goes to again references MyActionForm.
> >>> >>>
> >>> >>> What I've been told should happen is that Struts should be able to
> >>> >>> instantiate those two nested beans and set the properties, since
> >>> the
> >>> >>> parameter names give it the information it needs.  This does not
> >>> >>> however
> >>> >>> seem to be happening.
> >>> >>>
> >>> >>> So, two questions... first, is that in fact the expected
> >>> behavoir?  And
> >>> >>> two, if so, any ideas what I'm doing wrong?  I can post all the
> >>> >>> pertinent
> >>> >>> config and code, but thought it might be something more generic
> >>> that
> >>> >>> wouldn't require all that.  This is the first time I've ever had a
> >>> need
> >>> >>> to
> >>> >>> nest forms like this, so it's a new question for me.
> >>> >>>
> >>> >>> Thanks all!
> >>> >>>
> >>> >>> Frank
> >>> >>>
> >>> >>>
> >>> >>> --
> >>> >>> Frank W. Zammetti
> >>> >>> Founder and Chief Software Architect
> >>> >>> Omnytex Technologies
> >>> >>> http://www.omnytex.com
> >>> >>> AIM/Yahoo: fzammetti
> >>> >>> MSN: fzammetti@hotmail.com
> >>> >>> Author of "Practical Ajax Projects With Java Technology"
> >>> >>>  (2006, Apress, ISBN 1-59059-695-1)
> >>> >>> Java Web Parts - http://javawebparts.sourceforge.net
> >>> >>>  Supplying the wheel, so you don't have to reinvent it!
> >>> >>>
> >>> >>> ---------------------------------------------------------------------
> >>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> >>> For additional commands, e-mail: user-help@struts.apache.org
> >>> >>>
> >>> >>>
> >>> >>
> >>> >> ---------------------------------------------------------------------
> >>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> >> For additional commands, e-mail: user-help@struts.apache.org
> >>> >>
> >>> >>
> >>> >
> >>> >
> >>> > ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> > For additional commands, e-mail: user-help@struts.apache.org
> >>> >
> >>> >
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
As a follow-up, I threw some logging in the field1 and field2 setters in
the subbeans... they don't appear to ever get called.  I don't have to do
anything special to tell Struts I'm using nested beans, do I?  I didn't
think so...

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 2:47 pm, Frank W. Zammetti wrote:
> Hi Chris.. thanks for the suggestion, I gave that a shot at one point
> actually... what I get is now the fields in the subforms (I guess that's
> as good a term as any!) don't get set...
>
> masterForm = app.test.formbeans.MasterForm@141fab6
> tab1Form = app.test.formbeans.Tab1Form@b301f2
> tab2Form = app.test.formbeans.Tab2Form@44cbbe
> field1 = null
> field2 = null
>
> That's what I see in my final JSP output.
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
>> In your no-arg constructor of your outer ActionForm (the container),
>> make
>> sure it instantiates each of the nested ActionForms using their no-arg
>> constructors.
>>   (*Chris*)
>>
>> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>
>>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my
>>> mistake
>>> wasn't quite *THAT* obvious! ;) LOL
>>>
>>> Frank
>>>
>>>
>>> --
>>> Frank W. Zammetti
>>> Founder and Chief Software Architect
>>> Omnytex Technologies
>>> http://www.omnytex.com
>>> AIM/Yahoo: fzammetti
>>> MSN: fzammetti@hotmail.com
>>> Author of "Practical Ajax Projects With Java Technology"
>>> (2006, Apress, ISBN 1-59059-695-1)
>>> Java Web Parts - http://javawebparts.sourceforge.net
>>> Supplying the wheel, so you don't have to reinvent it!
>>>
>>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>>> > Hi Hubert,
>>> >
>>> > Yes, I get nulls for af1 and af2... I do have getters and setters for
>>> > them.
>>> >
>>> > Lemme throw some data your way... I was hoping to avoid posting all
>>> this,
>>> > but I suspect there to be something my eyes just aren't catching,
>>> so...
>>> >
>>> >
>>> > Here's ActionForm1:
>>> >
>>> >
>>> > package app.test.formbeans;
>>> > import org.apache.struts.action.ActionForm;
>>> > public class Action1Form extends ActionForm {
>>> >   private String field1;
>>> >   public void setField1(String inField1) {
>>> >     this.field1 = inField1;
>>> >   }
>>> >   public String getField1() {
>>> >     return this.field1;
>>> >   }
>>> > }
>>> >
>>> >
>>> > ActionForm2 is identical, just replacing the number 1 with 2
>>> everywhere.
>>> > Here's MasterForm:
>>> >
>>> >
>>> > package app.test.formbeans;
>>> > import org.apache.struts.action.ActionForm;
>>> > public class MasterForm extends ActionForm {
>>> >   public Action1Form action1Form;
>>> >   public Action2Form action2Form;
>>> >   public void setAction1Form(Action1Form inAction1Form) {
>>> >     this.action1Form = inAction1Form;
>>> >   }
>>> >   public Action1Form getAction1Form() {
>>> >     return this.action1Form;
>>> >   }
>>> >   public void setAction2Form(Action2Form inAction2Form) {
>>> >     this.action2Form = inAction2Form;
>>> >   }
>>> >   public Action2Form getAction2Form() {
>>> >     return this.action2Form;
>>> >   }
>>> > }
>>> >
>>> >
>>> > The Action everything gets submitted to is just a ForwardAction,
>>> which
>>> > forwards to:
>>> >
>>> >
>>> > <%@ page language="java" import="app.test.formbeans.*" %>
>>> > <%
>>> >   MasterForm masterForm =
>>> (MasterForm)request.getAttribute("masterForm");
>>> > %>
>>> > <%="masterForm = " + masterForm + "<br>"%>
>>> > <%
>>> >   Tab1Form tab1Form = null;
>>> >   Tab2Form tab2Form = null;
>>> >   if (masterForm != null) {
>>> >     tab1Form = masterForm.getTab1Form();
>>> >     tab2Form = masterForm.getTab2Form();
>>> >   }
>>> > %>
>>> > <%="tab1Form = " + tab1Form + "<br>"%>
>>> > <%="tab2Form = " + tab2Form + "<br>"%>
>>> > <% if (tab1Form != null) { %>
>>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>>> > <% } %>
>>> > <% if (tab2Form != null) { %>
>>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>>> > <% } %>
>>> >
>>> >
>>> > The result I see from this is:
>>> >
>>> >
>>> > masterForm = app.test.formbeans.MasterForm@e3849c
>>> > tab1Form = null
>>> > tab2Form = null
>>> >
>>> >
>>> > The page that does that submit, in its final rendered form on the
>>> client
>>> > is:
>>> >
>>> >
>>> > <html>
>>> > <head>
>>> >   <script>
>>> >     var finalSubmit = null;
>>> >     function getXHR() {
>>> >       if (window.XMLHttpRequest) {
>>> >         return new XMLHttpRequest();
>>> >       } else if (window.ActiveXObject) {
>>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>>> >       }
>>> >     }
>>> >     function submitAll() {
>>> >       var tab1Form = dojo.io.encodeForm(
>>> >         document.getElementById("tab1Form"));
>>> >       var tab2Form = dojo.io.encodeForm(
>>> >         document.getElementById("tab2Form"));
>>> >       finalSubmit = getXHR();
>>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>>> >       finalSubmit.open("POST", "final.do", true);
>>> >       finalSubmit.send(tab1Form + tab2Form);
>>> >     }
>>> >     function finalSubmitCallback() {
>>> >       if (finalSubmit.readyState == 4) {
>>> >         document.getElementById("divResult").innerHTML =
>>> > finalSubmit.responseText;
>>> >       }
>>> >     }
>>> >   </script>
>>> > </head>
>>> > <body onload="init();">
>>> >   <form name="masterForm" id="tab1Form" method="post"
>>> > action="/test/tab1.do">
>>> >     Field1: <input name="tab1Form.field1" value="val1"
>>> type="text"><br>
>>> >   </form>
>>> >   <br>
>>> >   <form name="masterForm" id="tab2Form" method="post"
>>> > action="/test/tab2.do">
>>> >     Field2: <input name="tab2Form.field2" value="val2"
>>> type="text"><br>
>>> >   </form>
>>> >   <br>
>>> >   <input value="Submit All" onclick="submitAll();" type="button">
>>> >   <br><br>
>>> >   <div id="divResult"></div>
>>> > </body>
>>> > </html>
>>> >
>>> >
>>> > Note that I removed all the Dojo-related stuff, and some stuff that
>>> isn't
>>> > related to this submissino, just to try and keep it small, but, the
>>> > important thing to note is that when the submission is made, the
>>> request
>>> > that goes across is a POST to http://localhost:8080/test/final.do, as
>>> > expected, and the POST body is:
>>> >
>>> > tab1Form.field1=val1&tab2Form.field2=val2&
>>> >
>>> > ...also as expected, verified in Firebug.  Lastly, here's
>>> struts-config:
>>> >
>>> >
>>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
>>> Struts
>>> > Configuration 1.2//EN"
>>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>>> > <struts-config>
>>> >   <form-beans>
>>> >     <form-bean name="masterForm" type="app.test.formbeans.MasterForm"
>>> />
>>> >   </form-beans>
>>> >   <action-mappings>
>>> >     <action path="/final" type="app.test.actions.FinalAction"
>>> > name="masterForm" scope="request" validate="false">
>>> >       <forward name="defaultForward" path="/final.jsp" />
>>> >     </action>
>>> >   </action-mappings>
>>> > </struts-config>
>>> >
>>> >
>>> > Note here that I removed the stuff that generated the markup from
>>> above
>>> > too, since that seems to be working just fine, I'm pretty sure this
>>> is
>>> all
>>> > that would be relevant.
>>> >
>>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>>> >
>>> > Frank
>>> >
>>> >
>>> > --
>>> > Frank W. Zammetti
>>> > Founder and Chief Software Architect
>>> > Omnytex Technologies
>>> > http://www.omnytex.com
>>> > AIM/Yahoo: fzammetti
>>> > MSN: fzammetti@hotmail.com
>>> > Author of "Practical Ajax Projects With Java Technology"
>>> >  (2006, Apress, ISBN 1-59059-695-1)
>>> > Java Web Parts - http://javawebparts.sourceforge.net
>>> >  Supplying the wheel, so you don't have to reinvent it!
>>> >
>>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>>> >> So what does happen when you submit the form?  Are you getting NPEs?
>>> >>
>>> >> By the time Struts attempts to populate the form bean, the nested
>>> >> forms should already be instantiated.  You should have getters and
>>> >> setters for af1 and af2, and getAf1() and getAf2() should not return
>>> a
>>> >> null.  This could be an issue if the form bean is new, either
>>> because
>>> >> it's in request scope, or in session scope but was not previously
>>> >> instantiated.
>>> >>
>>> >> Hubert
>>> >>
>>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>> >>> I'm facing a situation where ideally I'd like to have a single
>>> >>> ActionForm
>>> >>> like so:
>>> >>>
>>> >>> public class MyActionForm extends ActionForm {
>>> >>>   AnotherActionForm1 af1;
>>> >>>   AnotherActionForm2 af2;
>>> >>> }
>>> >>>
>>> >>> When in my JSP I do:
>>> >>>
>>> >>> <html:text property="af1.field1" />
>>> >>>
>>> >>> ...I do indeed see the value as I expect.  The way I did this is to
>>> >>> have
>>> >>> an Action mapping that references MyActionForm, then within the
>>> Action
>>> >>> I
>>> >>> instantiate AnotherActionForm1, set the value of field1 on it, and
>>> then
>>> >>> set af1 to that new AnotherActionForm1 instance.  That all works
>>> >>> nicely.
>>> >>>
>>> >>> Here's where I run into a problem...
>>> >>>
>>> >>> On the page I basically have 2 separate HTML forms, one for
>>> >>> AnotherActionForm1 and another for AnotherActionForm2.  However, I
>>> have
>>> >>> a
>>> >>> SINGLE submit button at the end (just plain button that makes an
>>> AJAX
>>> >>> request).  onClick of that button, I create a query string from the
>>> >>> values
>>> >>> of both forms, and make a request to the server with the query
>>> string
>>> >>> attached.  The parameter names of the query string arguments are
>>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
>>> >>> mapping
>>> >>> that the request goes to again references MyActionForm.
>>> >>>
>>> >>> What I've been told should happen is that Struts should be able to
>>> >>> instantiate those two nested beans and set the properties, since
>>> the
>>> >>> parameter names give it the information it needs.  This does not
>>> >>> however
>>> >>> seem to be happening.
>>> >>>
>>> >>> So, two questions... first, is that in fact the expected
>>> behavoir?  And
>>> >>> two, if so, any ideas what I'm doing wrong?  I can post all the
>>> >>> pertinent
>>> >>> config and code, but thought it might be something more generic
>>> that
>>> >>> wouldn't require all that.  This is the first time I've ever had a
>>> need
>>> >>> to
>>> >>> nest forms like this, so it's a new question for me.
>>> >>>
>>> >>> Thanks all!
>>> >>>
>>> >>> Frank
>>> >>>
>>> >>>
>>> >>> --
>>> >>> Frank W. Zammetti
>>> >>> Founder and Chief Software Architect
>>> >>> Omnytex Technologies
>>> >>> http://www.omnytex.com
>>> >>> AIM/Yahoo: fzammetti
>>> >>> MSN: fzammetti@hotmail.com
>>> >>> Author of "Practical Ajax Projects With Java Technology"
>>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>>> >>>  Supplying the wheel, so you don't have to reinvent it!
>>> >>>
>>> >>> ---------------------------------------------------------------------
>>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >>> For additional commands, e-mail: user-help@struts.apache.org
>>> >>>
>>> >>>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> For additional commands, e-mail: user-help@struts.apache.org
>>> >>
>>> >>
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> > For additional commands, e-mail: user-help@struts.apache.org
>>> >
>>> >
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Hi Chris.. thanks for the suggestion, I gave that a shot at one point
actually... what I get is now the fields in the subforms (I guess that's
as good a term as any!) don't get set...

masterForm = app.test.formbeans.MasterForm@141fab6
tab1Form = app.test.formbeans.Tab1Form@b301f2
tab2Form = app.test.formbeans.Tab2Form@44cbbe
field1 = null
field2 = null

That's what I see in my final JSP output.

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 2:40 pm, Chris Pratt wrote:
> In your no-arg constructor of your outer ActionForm (the container), make
> sure it instantiates each of the nested ActionForms using their no-arg
> constructors.
>   (*Chris*)
>
> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>
>> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my
>> mistake
>> wasn't quite *THAT* obvious! ;) LOL
>>
>> Frank
>>
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>> (2006, Apress, ISBN 1-59059-695-1)
>> Java Web Parts - http://javawebparts.sourceforge.net
>> Supplying the wheel, so you don't have to reinvent it!
>>
>> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
>> > Hi Hubert,
>> >
>> > Yes, I get nulls for af1 and af2... I do have getters and setters for
>> > them.
>> >
>> > Lemme throw some data your way... I was hoping to avoid posting all
>> this,
>> > but I suspect there to be something my eyes just aren't catching,
>> so...
>> >
>> >
>> > Here's ActionForm1:
>> >
>> >
>> > package app.test.formbeans;
>> > import org.apache.struts.action.ActionForm;
>> > public class Action1Form extends ActionForm {
>> >   private String field1;
>> >   public void setField1(String inField1) {
>> >     this.field1 = inField1;
>> >   }
>> >   public String getField1() {
>> >     return this.field1;
>> >   }
>> > }
>> >
>> >
>> > ActionForm2 is identical, just replacing the number 1 with 2
>> everywhere.
>> > Here's MasterForm:
>> >
>> >
>> > package app.test.formbeans;
>> > import org.apache.struts.action.ActionForm;
>> > public class MasterForm extends ActionForm {
>> >   public Action1Form action1Form;
>> >   public Action2Form action2Form;
>> >   public void setAction1Form(Action1Form inAction1Form) {
>> >     this.action1Form = inAction1Form;
>> >   }
>> >   public Action1Form getAction1Form() {
>> >     return this.action1Form;
>> >   }
>> >   public void setAction2Form(Action2Form inAction2Form) {
>> >     this.action2Form = inAction2Form;
>> >   }
>> >   public Action2Form getAction2Form() {
>> >     return this.action2Form;
>> >   }
>> > }
>> >
>> >
>> > The Action everything gets submitted to is just a ForwardAction, which
>> > forwards to:
>> >
>> >
>> > <%@ page language="java" import="app.test.formbeans.*" %>
>> > <%
>> >   MasterForm masterForm =
>> (MasterForm)request.getAttribute("masterForm");
>> > %>
>> > <%="masterForm = " + masterForm + "<br>"%>
>> > <%
>> >   Tab1Form tab1Form = null;
>> >   Tab2Form tab2Form = null;
>> >   if (masterForm != null) {
>> >     tab1Form = masterForm.getTab1Form();
>> >     tab2Form = masterForm.getTab2Form();
>> >   }
>> > %>
>> > <%="tab1Form = " + tab1Form + "<br>"%>
>> > <%="tab2Form = " + tab2Form + "<br>"%>
>> > <% if (tab1Form != null) { %>
>> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
>> > <% } %>
>> > <% if (tab2Form != null) { %>
>> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
>> > <% } %>
>> >
>> >
>> > The result I see from this is:
>> >
>> >
>> > masterForm = app.test.formbeans.MasterForm@e3849c
>> > tab1Form = null
>> > tab2Form = null
>> >
>> >
>> > The page that does that submit, in its final rendered form on the
>> client
>> > is:
>> >
>> >
>> > <html>
>> > <head>
>> >   <script>
>> >     var finalSubmit = null;
>> >     function getXHR() {
>> >       if (window.XMLHttpRequest) {
>> >         return new XMLHttpRequest();
>> >       } else if (window.ActiveXObject) {
>> >         return new ActiveXObject("Microsoft.XMLHTTP");
>> >       }
>> >     }
>> >     function submitAll() {
>> >       var tab1Form = dojo.io.encodeForm(
>> >         document.getElementById("tab1Form"));
>> >       var tab2Form = dojo.io.encodeForm(
>> >         document.getElementById("tab2Form"));
>> >       finalSubmit = getXHR();
>> >       finalSubmit.onreadystatechange = finalSubmitCallback;
>> >       finalSubmit.open("POST", "final.do", true);
>> >       finalSubmit.send(tab1Form + tab2Form);
>> >     }
>> >     function finalSubmitCallback() {
>> >       if (finalSubmit.readyState == 4) {
>> >         document.getElementById("divResult").innerHTML =
>> > finalSubmit.responseText;
>> >       }
>> >     }
>> >   </script>
>> > </head>
>> > <body onload="init();">
>> >   <form name="masterForm" id="tab1Form" method="post"
>> > action="/test/tab1.do">
>> >     Field1: <input name="tab1Form.field1" value="val1"
>> type="text"><br>
>> >   </form>
>> >   <br>
>> >   <form name="masterForm" id="tab2Form" method="post"
>> > action="/test/tab2.do">
>> >     Field2: <input name="tab2Form.field2" value="val2"
>> type="text"><br>
>> >   </form>
>> >   <br>
>> >   <input value="Submit All" onclick="submitAll();" type="button">
>> >   <br><br>
>> >   <div id="divResult"></div>
>> > </body>
>> > </html>
>> >
>> >
>> > Note that I removed all the Dojo-related stuff, and some stuff that
>> isn't
>> > related to this submissino, just to try and keep it small, but, the
>> > important thing to note is that when the submission is made, the
>> request
>> > that goes across is a POST to http://localhost:8080/test/final.do, as
>> > expected, and the POST body is:
>> >
>> > tab1Form.field1=val1&tab2Form.field2=val2&
>> >
>> > ...also as expected, verified in Firebug.  Lastly, here's
>> struts-config:
>> >
>> >
>> > <?xml version="1.0" encoding="ISO-8859-1" ?>
>> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
>> Struts
>> > Configuration 1.2//EN"
>> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
>> > <struts-config>
>> >   <form-beans>
>> >     <form-bean name="masterForm" type="app.test.formbeans.MasterForm"
>> />
>> >   </form-beans>
>> >   <action-mappings>
>> >     <action path="/final" type="app.test.actions.FinalAction"
>> > name="masterForm" scope="request" validate="false">
>> >       <forward name="defaultForward" path="/final.jsp" />
>> >     </action>
>> >   </action-mappings>
>> > </struts-config>
>> >
>> >
>> > Note here that I removed the stuff that generated the markup from
>> above
>> > too, since that seems to be working just fine, I'm pretty sure this is
>> all
>> > that would be relevant.
>> >
>> > So, seeing any obvious blunders on my part?  Thanks Hubert!
>> >
>> > Frank
>> >
>> >
>> > --
>> > Frank W. Zammetti
>> > Founder and Chief Software Architect
>> > Omnytex Technologies
>> > http://www.omnytex.com
>> > AIM/Yahoo: fzammetti
>> > MSN: fzammetti@hotmail.com
>> > Author of "Practical Ajax Projects With Java Technology"
>> >  (2006, Apress, ISBN 1-59059-695-1)
>> > Java Web Parts - http://javawebparts.sourceforge.net
>> >  Supplying the wheel, so you don't have to reinvent it!
>> >
>> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>> >> So what does happen when you submit the form?  Are you getting NPEs?
>> >>
>> >> By the time Struts attempts to populate the form bean, the nested
>> >> forms should already be instantiated.  You should have getters and
>> >> setters for af1 and af2, and getAf1() and getAf2() should not return
>> a
>> >> null.  This could be an issue if the form bean is new, either because
>> >> it's in request scope, or in session scope but was not previously
>> >> instantiated.
>> >>
>> >> Hubert
>> >>
>> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >>> I'm facing a situation where ideally I'd like to have a single
>> >>> ActionForm
>> >>> like so:
>> >>>
>> >>> public class MyActionForm extends ActionForm {
>> >>>   AnotherActionForm1 af1;
>> >>>   AnotherActionForm2 af2;
>> >>> }
>> >>>
>> >>> When in my JSP I do:
>> >>>
>> >>> <html:text property="af1.field1" />
>> >>>
>> >>> ...I do indeed see the value as I expect.  The way I did this is to
>> >>> have
>> >>> an Action mapping that references MyActionForm, then within the
>> Action
>> >>> I
>> >>> instantiate AnotherActionForm1, set the value of field1 on it, and
>> then
>> >>> set af1 to that new AnotherActionForm1 instance.  That all works
>> >>> nicely.
>> >>>
>> >>> Here's where I run into a problem...
>> >>>
>> >>> On the page I basically have 2 separate HTML forms, one for
>> >>> AnotherActionForm1 and another for AnotherActionForm2.  However, I
>> have
>> >>> a
>> >>> SINGLE submit button at the end (just plain button that makes an
>> AJAX
>> >>> request).  onClick of that button, I create a query string from the
>> >>> values
>> >>> of both forms, and make a request to the server with the query
>> string
>> >>> attached.  The parameter names of the query string arguments are
>> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
>> >>> mapping
>> >>> that the request goes to again references MyActionForm.
>> >>>
>> >>> What I've been told should happen is that Struts should be able to
>> >>> instantiate those two nested beans and set the properties, since the
>> >>> parameter names give it the information it needs.  This does not
>> >>> however
>> >>> seem to be happening.
>> >>>
>> >>> So, two questions... first, is that in fact the expected
>> behavoir?  And
>> >>> two, if so, any ideas what I'm doing wrong?  I can post all the
>> >>> pertinent
>> >>> config and code, but thought it might be something more generic that
>> >>> wouldn't require all that.  This is the first time I've ever had a
>> need
>> >>> to
>> >>> nest forms like this, so it's a new question for me.
>> >>>
>> >>> Thanks all!
>> >>>
>> >>> Frank
>> >>>
>> >>>
>> >>> --
>> >>> Frank W. Zammetti
>> >>> Founder and Chief Software Architect
>> >>> Omnytex Technologies
>> >>> http://www.omnytex.com
>> >>> AIM/Yahoo: fzammetti
>> >>> MSN: fzammetti@hotmail.com
>> >>> Author of "Practical Ajax Projects With Java Technology"
>> >>>  (2006, Apress, ISBN 1-59059-695-1)
>> >>> Java Web Parts - http://javawebparts.sourceforge.net
>> >>>  Supplying the wheel, so you don't have to reinvent it!
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >>> For additional commands, e-mail: user-help@struts.apache.org
>> >>>
>> >>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by Hubert Rabago <hr...@gmail.com>.
Either that or create new beans (if they're null) when their getters are called.

By the time Struts attempts to populate the form bean, the nested
forms should already be instantiated.  MasterForm.getAction1Form() and
MasterForm.getAction2Form() should not return a null.

Hubert

On 9/22/06, Chris Pratt <th...@gmail.com> wrote:
> In your no-arg constructor of your outer ActionForm (the container), make
> sure it instantiates each of the nested ActionForms using their no-arg
> constructors.
>   (*Chris*)
>
> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >
> > Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my mistake
> > wasn't quite *THAT* obvious! ;) LOL
> >
> > Frank
> >
> >
> > --
> > Frank W. Zammetti
> > Founder and Chief Software Architect
> > Omnytex Technologies
> > http://www.omnytex.com
> > AIM/Yahoo: fzammetti
> > MSN: fzammetti@hotmail.com
> > Author of "Practical Ajax Projects With Java Technology"
> > (2006, Apress, ISBN 1-59059-695-1)
> > Java Web Parts - http://javawebparts.sourceforge.net
> > Supplying the wheel, so you don't have to reinvent it!
> >
> > On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
> > > Hi Hubert,
> > >
> > > Yes, I get nulls for af1 and af2... I do have getters and setters for
> > > them.
> > >
> > > Lemme throw some data your way... I was hoping to avoid posting all
> > this,
> > > but I suspect there to be something my eyes just aren't catching, so...
> > >
> > >
> > > Here's ActionForm1:
> > >
> > >
> > > package app.test.formbeans;
> > > import org.apache.struts.action.ActionForm;
> > > public class Action1Form extends ActionForm {
> > >   private String field1;
> > >   public void setField1(String inField1) {
> > >     this.field1 = inField1;
> > >   }
> > >   public String getField1() {
> > >     return this.field1;
> > >   }
> > > }
> > >
> > >
> > > ActionForm2 is identical, just replacing the number 1 with 2 everywhere.
> > > Here's MasterForm:
> > >
> > >
> > > package app.test.formbeans;
> > > import org.apache.struts.action.ActionForm;
> > > public class MasterForm extends ActionForm {
> > >   public Action1Form action1Form;
> > >   public Action2Form action2Form;
> > >   public void setAction1Form(Action1Form inAction1Form) {
> > >     this.action1Form = inAction1Form;
> > >   }
> > >   public Action1Form getAction1Form() {
> > >     return this.action1Form;
> > >   }
> > >   public void setAction2Form(Action2Form inAction2Form) {
> > >     this.action2Form = inAction2Form;
> > >   }
> > >   public Action2Form getAction2Form() {
> > >     return this.action2Form;
> > >   }
> > > }
> > >
> > >
> > > The Action everything gets submitted to is just a ForwardAction, which
> > > forwards to:
> > >
> > >
> > > <%@ page language="java" import="app.test.formbeans.*" %>
> > > <%
> > >   MasterForm masterForm =
> > (MasterForm)request.getAttribute("masterForm");
> > > %>
> > > <%="masterForm = " + masterForm + "<br>"%>
> > > <%
> > >   Tab1Form tab1Form = null;
> > >   Tab2Form tab2Form = null;
> > >   if (masterForm != null) {
> > >     tab1Form = masterForm.getTab1Form();
> > >     tab2Form = masterForm.getTab2Form();
> > >   }
> > > %>
> > > <%="tab1Form = " + tab1Form + "<br>"%>
> > > <%="tab2Form = " + tab2Form + "<br>"%>
> > > <% if (tab1Form != null) { %>
> > >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
> > > <% } %>
> > > <% if (tab2Form != null) { %>
> > >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
> > > <% } %>
> > >
> > >
> > > The result I see from this is:
> > >
> > >
> > > masterForm = app.test.formbeans.MasterForm@e3849c
> > > tab1Form = null
> > > tab2Form = null
> > >
> > >
> > > The page that does that submit, in its final rendered form on the client
> > > is:
> > >
> > >
> > > <html>
> > > <head>
> > >   <script>
> > >     var finalSubmit = null;
> > >     function getXHR() {
> > >       if (window.XMLHttpRequest) {
> > >         return new XMLHttpRequest();
> > >       } else if (window.ActiveXObject) {
> > >         return new ActiveXObject("Microsoft.XMLHTTP");
> > >       }
> > >     }
> > >     function submitAll() {
> > >       var tab1Form = dojo.io.encodeForm(
> > >         document.getElementById("tab1Form"));
> > >       var tab2Form = dojo.io.encodeForm(
> > >         document.getElementById("tab2Form"));
> > >       finalSubmit = getXHR();
> > >       finalSubmit.onreadystatechange = finalSubmitCallback;
> > >       finalSubmit.open("POST", "final.do", true);
> > >       finalSubmit.send(tab1Form + tab2Form);
> > >     }
> > >     function finalSubmitCallback() {
> > >       if (finalSubmit.readyState == 4) {
> > >         document.getElementById("divResult").innerHTML =
> > > finalSubmit.responseText;
> > >       }
> > >     }
> > >   </script>
> > > </head>
> > > <body onload="init();">
> > >   <form name="masterForm" id="tab1Form" method="post"
> > > action="/test/tab1.do">
> > >     Field1: <input name="tab1Form.field1" value="val1" type="text"><br>
> > >   </form>
> > >   <br>
> > >   <form name="masterForm" id="tab2Form" method="post"
> > > action="/test/tab2.do">
> > >     Field2: <input name="tab2Form.field2" value="val2" type="text"><br>
> > >   </form>
> > >   <br>
> > >   <input value="Submit All" onclick="submitAll();" type="button">
> > >   <br><br>
> > >   <div id="divResult"></div>
> > > </body>
> > > </html>
> > >
> > >
> > > Note that I removed all the Dojo-related stuff, and some stuff that
> > isn't
> > > related to this submissino, just to try and keep it small, but, the
> > > important thing to note is that when the submission is made, the request
> > > that goes across is a POST to http://localhost:8080/test/final.do, as
> > > expected, and the POST body is:
> > >
> > > tab1Form.field1=val1&tab2Form.field2=val2&
> > >
> > > ...also as expected, verified in Firebug.  Lastly, here's struts-config:
> > >
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1" ?>
> > > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
> > Struts
> > > Configuration 1.2//EN"
> > > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
> > > <struts-config>
> > >   <form-beans>
> > >     <form-bean name="masterForm" type="app.test.formbeans.MasterForm" />
> > >   </form-beans>
> > >   <action-mappings>
> > >     <action path="/final" type="app.test.actions.FinalAction"
> > > name="masterForm" scope="request" validate="false">
> > >       <forward name="defaultForward" path="/final.jsp" />
> > >     </action>
> > >   </action-mappings>
> > > </struts-config>
> > >
> > >
> > > Note here that I removed the stuff that generated the markup from above
> > > too, since that seems to be working just fine, I'm pretty sure this is
> > all
> > > that would be relevant.
> > >
> > > So, seeing any obvious blunders on my part?  Thanks Hubert!
> > >
> > > Frank
> > >
> > >
> > > --
> > > Frank W. Zammetti
> > > Founder and Chief Software Architect
> > > Omnytex Technologies
> > > http://www.omnytex.com
> > > AIM/Yahoo: fzammetti
> > > MSN: fzammetti@hotmail.com
> > > Author of "Practical Ajax Projects With Java Technology"
> > >  (2006, Apress, ISBN 1-59059-695-1)
> > > Java Web Parts - http://javawebparts.sourceforge.net
> > >  Supplying the wheel, so you don't have to reinvent it!
> > >
> > > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
> > >> So what does happen when you submit the form?  Are you getting NPEs?
> > >>
> > >> By the time Struts attempts to populate the form bean, the nested
> > >> forms should already be instantiated.  You should have getters and
> > >> setters for af1 and af2, and getAf1() and getAf2() should not return a
> > >> null.  This could be an issue if the form bean is new, either because
> > >> it's in request scope, or in session scope but was not previously
> > >> instantiated.
> > >>
> > >> Hubert
> > >>
> > >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> > >>> I'm facing a situation where ideally I'd like to have a single
> > >>> ActionForm
> > >>> like so:
> > >>>
> > >>> public class MyActionForm extends ActionForm {
> > >>>   AnotherActionForm1 af1;
> > >>>   AnotherActionForm2 af2;
> > >>> }
> > >>>
> > >>> When in my JSP I do:
> > >>>
> > >>> <html:text property="af1.field1" />
> > >>>
> > >>> ...I do indeed see the value as I expect.  The way I did this is to
> > >>> have
> > >>> an Action mapping that references MyActionForm, then within the Action
> > >>> I
> > >>> instantiate AnotherActionForm1, set the value of field1 on it, and
> > then
> > >>> set af1 to that new AnotherActionForm1 instance.  That all works
> > >>> nicely.
> > >>>
> > >>> Here's where I run into a problem...
> > >>>
> > >>> On the page I basically have 2 separate HTML forms, one for
> > >>> AnotherActionForm1 and another for AnotherActionForm2.  However, I
> > have
> > >>> a
> > >>> SINGLE submit button at the end (just plain button that makes an AJAX
> > >>> request).  onClick of that button, I create a query string from the
> > >>> values
> > >>> of both forms, and make a request to the server with the query string
> > >>> attached.  The parameter names of the query string arguments are
> > >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
> > >>> mapping
> > >>> that the request goes to again references MyActionForm.
> > >>>
> > >>> What I've been told should happen is that Struts should be able to
> > >>> instantiate those two nested beans and set the properties, since the
> > >>> parameter names give it the information it needs.  This does not
> > >>> however
> > >>> seem to be happening.
> > >>>
> > >>> So, two questions... first, is that in fact the expected
> > behavoir?  And
> > >>> two, if so, any ideas what I'm doing wrong?  I can post all the
> > >>> pertinent
> > >>> config and code, but thought it might be something more generic that
> > >>> wouldn't require all that.  This is the first time I've ever had a
> > need
> > >>> to
> > >>> nest forms like this, so it's a new question for me.
> > >>>
> > >>> Thanks all!
> > >>>
> > >>> Frank
> > >>>
> > >>>
> > >>> --
> > >>> Frank W. Zammetti
> > >>> Founder and Chief Software Architect
> > >>> Omnytex Technologies
> > >>> http://www.omnytex.com
> > >>> AIM/Yahoo: fzammetti
> > >>> MSN: fzammetti@hotmail.com
> > >>> Author of "Practical Ajax Projects With Java Technology"
> > >>>  (2006, Apress, ISBN 1-59059-695-1)
> > >>> Java Web Parts - http://javawebparts.sourceforge.net
> > >>>  Supplying the wheel, so you don't have to reinvent it!
> > >>>
> > >>> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >>> For additional commands, e-mail: user-help@struts.apache.org
> > >>>
> > >>>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by Chris Pratt <th...@gmail.com>.
In your no-arg constructor of your outer ActionForm (the container), make
sure it instantiates each of the nested ActionForms using their no-arg
constructors.
  (*Chris*)

On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>
> Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my mistake
> wasn't quite *THAT* obvious! ;) LOL
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
> (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
> Supplying the wheel, so you don't have to reinvent it!
>
> On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
> > Hi Hubert,
> >
> > Yes, I get nulls for af1 and af2... I do have getters and setters for
> > them.
> >
> > Lemme throw some data your way... I was hoping to avoid posting all
> this,
> > but I suspect there to be something my eyes just aren't catching, so...
> >
> >
> > Here's ActionForm1:
> >
> >
> > package app.test.formbeans;
> > import org.apache.struts.action.ActionForm;
> > public class Action1Form extends ActionForm {
> >   private String field1;
> >   public void setField1(String inField1) {
> >     this.field1 = inField1;
> >   }
> >   public String getField1() {
> >     return this.field1;
> >   }
> > }
> >
> >
> > ActionForm2 is identical, just replacing the number 1 with 2 everywhere.
> > Here's MasterForm:
> >
> >
> > package app.test.formbeans;
> > import org.apache.struts.action.ActionForm;
> > public class MasterForm extends ActionForm {
> >   public Action1Form action1Form;
> >   public Action2Form action2Form;
> >   public void setAction1Form(Action1Form inAction1Form) {
> >     this.action1Form = inAction1Form;
> >   }
> >   public Action1Form getAction1Form() {
> >     return this.action1Form;
> >   }
> >   public void setAction2Form(Action2Form inAction2Form) {
> >     this.action2Form = inAction2Form;
> >   }
> >   public Action2Form getAction2Form() {
> >     return this.action2Form;
> >   }
> > }
> >
> >
> > The Action everything gets submitted to is just a ForwardAction, which
> > forwards to:
> >
> >
> > <%@ page language="java" import="app.test.formbeans.*" %>
> > <%
> >   MasterForm masterForm =
> (MasterForm)request.getAttribute("masterForm");
> > %>
> > <%="masterForm = " + masterForm + "<br>"%>
> > <%
> >   Tab1Form tab1Form = null;
> >   Tab2Form tab2Form = null;
> >   if (masterForm != null) {
> >     tab1Form = masterForm.getTab1Form();
> >     tab2Form = masterForm.getTab2Form();
> >   }
> > %>
> > <%="tab1Form = " + tab1Form + "<br>"%>
> > <%="tab2Form = " + tab2Form + "<br>"%>
> > <% if (tab1Form != null) { %>
> >   <%="field1 = " + tab1Form.getField1() + "<br>"%>
> > <% } %>
> > <% if (tab2Form != null) { %>
> >   <%="field2 = " + tab2Form.getField2() + "<br>"%>
> > <% } %>
> >
> >
> > The result I see from this is:
> >
> >
> > masterForm = app.test.formbeans.MasterForm@e3849c
> > tab1Form = null
> > tab2Form = null
> >
> >
> > The page that does that submit, in its final rendered form on the client
> > is:
> >
> >
> > <html>
> > <head>
> >   <script>
> >     var finalSubmit = null;
> >     function getXHR() {
> >       if (window.XMLHttpRequest) {
> >         return new XMLHttpRequest();
> >       } else if (window.ActiveXObject) {
> >         return new ActiveXObject("Microsoft.XMLHTTP");
> >       }
> >     }
> >     function submitAll() {
> >       var tab1Form = dojo.io.encodeForm(
> >         document.getElementById("tab1Form"));
> >       var tab2Form = dojo.io.encodeForm(
> >         document.getElementById("tab2Form"));
> >       finalSubmit = getXHR();
> >       finalSubmit.onreadystatechange = finalSubmitCallback;
> >       finalSubmit.open("POST", "final.do", true);
> >       finalSubmit.send(tab1Form + tab2Form);
> >     }
> >     function finalSubmitCallback() {
> >       if (finalSubmit.readyState == 4) {
> >         document.getElementById("divResult").innerHTML =
> > finalSubmit.responseText;
> >       }
> >     }
> >   </script>
> > </head>
> > <body onload="init();">
> >   <form name="masterForm" id="tab1Form" method="post"
> > action="/test/tab1.do">
> >     Field1: <input name="tab1Form.field1" value="val1" type="text"><br>
> >   </form>
> >   <br>
> >   <form name="masterForm" id="tab2Form" method="post"
> > action="/test/tab2.do">
> >     Field2: <input name="tab2Form.field2" value="val2" type="text"><br>
> >   </form>
> >   <br>
> >   <input value="Submit All" onclick="submitAll();" type="button">
> >   <br><br>
> >   <div id="divResult"></div>
> > </body>
> > </html>
> >
> >
> > Note that I removed all the Dojo-related stuff, and some stuff that
> isn't
> > related to this submissino, just to try and keep it small, but, the
> > important thing to note is that when the submission is made, the request
> > that goes across is a POST to http://localhost:8080/test/final.do, as
> > expected, and the POST body is:
> >
> > tab1Form.field1=val1&tab2Form.field2=val2&
> >
> > ...also as expected, verified in Firebug.  Lastly, here's struts-config:
> >
> >
> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
> Struts
> > Configuration 1.2//EN"
> > "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
> > <struts-config>
> >   <form-beans>
> >     <form-bean name="masterForm" type="app.test.formbeans.MasterForm" />
> >   </form-beans>
> >   <action-mappings>
> >     <action path="/final" type="app.test.actions.FinalAction"
> > name="masterForm" scope="request" validate="false">
> >       <forward name="defaultForward" path="/final.jsp" />
> >     </action>
> >   </action-mappings>
> > </struts-config>
> >
> >
> > Note here that I removed the stuff that generated the markup from above
> > too, since that seems to be working just fine, I'm pretty sure this is
> all
> > that would be relevant.
> >
> > So, seeing any obvious blunders on my part?  Thanks Hubert!
> >
> > Frank
> >
> >
> > --
> > Frank W. Zammetti
> > Founder and Chief Software Architect
> > Omnytex Technologies
> > http://www.omnytex.com
> > AIM/Yahoo: fzammetti
> > MSN: fzammetti@hotmail.com
> > Author of "Practical Ajax Projects With Java Technology"
> >  (2006, Apress, ISBN 1-59059-695-1)
> > Java Web Parts - http://javawebparts.sourceforge.net
> >  Supplying the wheel, so you don't have to reinvent it!
> >
> > On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
> >> So what does happen when you submit the form?  Are you getting NPEs?
> >>
> >> By the time Struts attempts to populate the form bean, the nested
> >> forms should already be instantiated.  You should have getters and
> >> setters for af1 and af2, and getAf1() and getAf2() should not return a
> >> null.  This could be an issue if the form bean is new, either because
> >> it's in request scope, or in session scope but was not previously
> >> instantiated.
> >>
> >> Hubert
> >>
> >> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >>> I'm facing a situation where ideally I'd like to have a single
> >>> ActionForm
> >>> like so:
> >>>
> >>> public class MyActionForm extends ActionForm {
> >>>   AnotherActionForm1 af1;
> >>>   AnotherActionForm2 af2;
> >>> }
> >>>
> >>> When in my JSP I do:
> >>>
> >>> <html:text property="af1.field1" />
> >>>
> >>> ...I do indeed see the value as I expect.  The way I did this is to
> >>> have
> >>> an Action mapping that references MyActionForm, then within the Action
> >>> I
> >>> instantiate AnotherActionForm1, set the value of field1 on it, and
> then
> >>> set af1 to that new AnotherActionForm1 instance.  That all works
> >>> nicely.
> >>>
> >>> Here's where I run into a problem...
> >>>
> >>> On the page I basically have 2 separate HTML forms, one for
> >>> AnotherActionForm1 and another for AnotherActionForm2.  However, I
> have
> >>> a
> >>> SINGLE submit button at the end (just plain button that makes an AJAX
> >>> request).  onClick of that button, I create a query string from the
> >>> values
> >>> of both forms, and make a request to the server with the query string
> >>> attached.  The parameter names of the query string arguments are
> >>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
> >>> mapping
> >>> that the request goes to again references MyActionForm.
> >>>
> >>> What I've been told should happen is that Struts should be able to
> >>> instantiate those two nested beans and set the properties, since the
> >>> parameter names give it the information it needs.  This does not
> >>> however
> >>> seem to be happening.
> >>>
> >>> So, two questions... first, is that in fact the expected
> behavoir?  And
> >>> two, if so, any ideas what I'm doing wrong?  I can post all the
> >>> pertinent
> >>> config and code, but thought it might be something more generic that
> >>> wouldn't require all that.  This is the first time I've ever had a
> need
> >>> to
> >>> nest forms like this, so it's a new question for me.
> >>>
> >>> Thanks all!
> >>>
> >>> Frank
> >>>
> >>>
> >>> --
> >>> Frank W. Zammetti
> >>> Founder and Chief Software Architect
> >>> Omnytex Technologies
> >>> http://www.omnytex.com
> >>> AIM/Yahoo: fzammetti
> >>> MSN: fzammetti@hotmail.com
> >>> Author of "Practical Ajax Projects With Java Technology"
> >>>  (2006, Apress, ISBN 1-59059-695-1)
> >>> Java Web Parts - http://javawebparts.sourceforge.net
> >>>  Supplying the wheel, so you don't have to reinvent it!
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Sorry, by af1 and af2 I did mean actionForm1 and actionForm2... my mistake
wasn't quite *THAT* obvious! ;) LOL

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 1:31 pm, Frank W. Zammetti wrote:
> Hi Hubert,
>
> Yes, I get nulls for af1 and af2... I do have getters and setters for
> them.
>
> Lemme throw some data your way... I was hoping to avoid posting all this,
> but I suspect there to be something my eyes just aren't catching, so...
>
>
> Here's ActionForm1:
>
>
> package app.test.formbeans;
> import org.apache.struts.action.ActionForm;
> public class Action1Form extends ActionForm {
>   private String field1;
>   public void setField1(String inField1) {
>     this.field1 = inField1;
>   }
>   public String getField1() {
>     return this.field1;
>   }
> }
>
>
> ActionForm2 is identical, just replacing the number 1 with 2 everywhere.
> Here's MasterForm:
>
>
> package app.test.formbeans;
> import org.apache.struts.action.ActionForm;
> public class MasterForm extends ActionForm {
>   public Action1Form action1Form;
>   public Action2Form action2Form;
>   public void setAction1Form(Action1Form inAction1Form) {
>     this.action1Form = inAction1Form;
>   }
>   public Action1Form getAction1Form() {
>     return this.action1Form;
>   }
>   public void setAction2Form(Action2Form inAction2Form) {
>     this.action2Form = inAction2Form;
>   }
>   public Action2Form getAction2Form() {
>     return this.action2Form;
>   }
> }
>
>
> The Action everything gets submitted to is just a ForwardAction, which
> forwards to:
>
>
> <%@ page language="java" import="app.test.formbeans.*" %>
> <%
>   MasterForm masterForm = (MasterForm)request.getAttribute("masterForm");
> %>
> <%="masterForm = " + masterForm + "<br>"%>
> <%
>   Tab1Form tab1Form = null;
>   Tab2Form tab2Form = null;
>   if (masterForm != null) {
>     tab1Form = masterForm.getTab1Form();
>     tab2Form = masterForm.getTab2Form();
>   }
> %>
> <%="tab1Form = " + tab1Form + "<br>"%>
> <%="tab2Form = " + tab2Form + "<br>"%>
> <% if (tab1Form != null) { %>
>   <%="field1 = " + tab1Form.getField1() + "<br>"%>
> <% } %>
> <% if (tab2Form != null) { %>
>   <%="field2 = " + tab2Form.getField2() + "<br>"%>
> <% } %>
>
>
> The result I see from this is:
>
>
> masterForm = app.test.formbeans.MasterForm@e3849c
> tab1Form = null
> tab2Form = null
>
>
> The page that does that submit, in its final rendered form on the client
> is:
>
>
> <html>
> <head>
>   <script>
>     var finalSubmit = null;
>     function getXHR() {
>       if (window.XMLHttpRequest) {
>         return new XMLHttpRequest();
>       } else if (window.ActiveXObject) {
>         return new ActiveXObject("Microsoft.XMLHTTP");
>       }
>     }
>     function submitAll() {
>       var tab1Form = dojo.io.encodeForm(
>         document.getElementById("tab1Form"));
>       var tab2Form = dojo.io.encodeForm(
>         document.getElementById("tab2Form"));
>       finalSubmit = getXHR();
>       finalSubmit.onreadystatechange = finalSubmitCallback;
>       finalSubmit.open("POST", "final.do", true);
>       finalSubmit.send(tab1Form + tab2Form);
>     }
>     function finalSubmitCallback() {
>       if (finalSubmit.readyState == 4) {
>         document.getElementById("divResult").innerHTML =
> finalSubmit.responseText;
>       }
>     }
>   </script>
> </head>
> <body onload="init();">
>   <form name="masterForm" id="tab1Form" method="post"
> action="/test/tab1.do">
>     Field1: <input name="tab1Form.field1" value="val1" type="text"><br>
>   </form>
>   <br>
>   <form name="masterForm" id="tab2Form" method="post"
> action="/test/tab2.do">
>     Field2: <input name="tab2Form.field2" value="val2" type="text"><br>
>   </form>
>   <br>
>   <input value="Submit All" onclick="submitAll();" type="button">
>   <br><br>
>   <div id="divResult"></div>
> </body>
> </html>
>
>
> Note that I removed all the Dojo-related stuff, and some stuff that isn't
> related to this submissino, just to try and keep it small, but, the
> important thing to note is that when the submission is made, the request
> that goes across is a POST to http://localhost:8080/test/final.do, as
> expected, and the POST body is:
>
> tab1Form.field1=val1&tab2Form.field2=val2&
>
> ...also as expected, verified in Firebug.  Lastly, here's struts-config:
>
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
> Configuration 1.2//EN"
> "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
> <struts-config>
>   <form-beans>
>     <form-bean name="masterForm" type="app.test.formbeans.MasterForm" />
>   </form-beans>
>   <action-mappings>
>     <action path="/final" type="app.test.actions.FinalAction"
> name="masterForm" scope="request" validate="false">
>       <forward name="defaultForward" path="/final.jsp" />
>     </action>
>   </action-mappings>
> </struts-config>
>
>
> Note here that I removed the stuff that generated the markup from above
> too, since that seems to be working just fine, I'm pretty sure this is all
> that would be relevant.
>
> So, seeing any obvious blunders on my part?  Thanks Hubert!
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
>> So what does happen when you submit the form?  Are you getting NPEs?
>>
>> By the time Struts attempts to populate the form bean, the nested
>> forms should already be instantiated.  You should have getters and
>> setters for af1 and af2, and getAf1() and getAf2() should not return a
>> null.  This could be an issue if the form bean is new, either because
>> it's in request scope, or in session scope but was not previously
>> instantiated.
>>
>> Hubert
>>
>> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>> I'm facing a situation where ideally I'd like to have a single
>>> ActionForm
>>> like so:
>>>
>>> public class MyActionForm extends ActionForm {
>>>   AnotherActionForm1 af1;
>>>   AnotherActionForm2 af2;
>>> }
>>>
>>> When in my JSP I do:
>>>
>>> <html:text property="af1.field1" />
>>>
>>> ...I do indeed see the value as I expect.  The way I did this is to
>>> have
>>> an Action mapping that references MyActionForm, then within the Action
>>> I
>>> instantiate AnotherActionForm1, set the value of field1 on it, and then
>>> set af1 to that new AnotherActionForm1 instance.  That all works
>>> nicely.
>>>
>>> Here's where I run into a problem...
>>>
>>> On the page I basically have 2 separate HTML forms, one for
>>> AnotherActionForm1 and another for AnotherActionForm2.  However, I have
>>> a
>>> SINGLE submit button at the end (just plain button that makes an AJAX
>>> request).  onClick of that button, I create a query string from the
>>> values
>>> of both forms, and make a request to the server with the query string
>>> attached.  The parameter names of the query string arguments are
>>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The
>>> mapping
>>> that the request goes to again references MyActionForm.
>>>
>>> What I've been told should happen is that Struts should be able to
>>> instantiate those two nested beans and set the properties, since the
>>> parameter names give it the information it needs.  This does not
>>> however
>>> seem to be happening.
>>>
>>> So, two questions... first, is that in fact the expected behavoir?  And
>>> two, if so, any ideas what I'm doing wrong?  I can post all the
>>> pertinent
>>> config and code, but thought it might be something more generic that
>>> wouldn't require all that.  This is the first time I've ever had a need
>>> to
>>> nest forms like this, so it's a new question for me.
>>>
>>> Thanks all!
>>>
>>> Frank
>>>
>>>
>>> --
>>> Frank W. Zammetti
>>> Founder and Chief Software Architect
>>> Omnytex Technologies
>>> http://www.omnytex.com
>>> AIM/Yahoo: fzammetti
>>> MSN: fzammetti@hotmail.com
>>> Author of "Practical Ajax Projects With Java Technology"
>>>  (2006, Apress, ISBN 1-59059-695-1)
>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>  Supplying the wheel, so you don't have to reinvent it!
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Hi Hubert,

Yes, I get nulls for af1 and af2... I do have getters and setters for them.

Lemme throw some data your way... I was hoping to avoid posting all this,
but I suspect there to be something my eyes just aren't catching, so...


Here's ActionForm1:


package app.test.formbeans;
import org.apache.struts.action.ActionForm;
public class Action1Form extends ActionForm {
  private String field1;
  public void setField1(String inField1) {
    this.field1 = inField1;
  }
  public String getField1() {
    return this.field1;
  }
}


ActionForm2 is identical, just replacing the number 1 with 2 everywhere. 
Here's MasterForm:


package app.test.formbeans;
import org.apache.struts.action.ActionForm;
public class MasterForm extends ActionForm {
  public Action1Form action1Form;
  public Action2Form action2Form;
  public void setAction1Form(Action1Form inAction1Form) {
    this.action1Form = inAction1Form;
  }
  public Action1Form getAction1Form() {
    return this.action1Form;
  }
  public void setAction2Form(Action2Form inAction2Form) {
    this.action2Form = inAction2Form;
  }
  public Action2Form getAction2Form() {
    return this.action2Form;
  }
}


The Action everything gets submitted to is just a ForwardAction, which
forwards to:


<%@ page language="java" import="app.test.formbeans.*" %>
<%
  MasterForm masterForm = (MasterForm)request.getAttribute("masterForm");
%>
<%="masterForm = " + masterForm + "<br>"%>
<%
  Tab1Form tab1Form = null;
  Tab2Form tab2Form = null;
  if (masterForm != null) {
    tab1Form = masterForm.getTab1Form();
    tab2Form = masterForm.getTab2Form();
  }
%>
<%="tab1Form = " + tab1Form + "<br>"%>
<%="tab2Form = " + tab2Form + "<br>"%>
<% if (tab1Form != null) { %>
  <%="field1 = " + tab1Form.getField1() + "<br>"%>
<% } %>
<% if (tab2Form != null) { %>
  <%="field2 = " + tab2Form.getField2() + "<br>"%>
<% } %>


The result I see from this is:


masterForm = app.test.formbeans.MasterForm@e3849c
tab1Form = null
tab2Form = null


The page that does that submit, in its final rendered form on the client is:


<html>
<head>
  <script>
    var finalSubmit = null;
    function getXHR() {
      if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    function submitAll() {
      var tab1Form = dojo.io.encodeForm(
        document.getElementById("tab1Form"));
      var tab2Form = dojo.io.encodeForm(
        document.getElementById("tab2Form"));
      finalSubmit = getXHR();
      finalSubmit.onreadystatechange = finalSubmitCallback;
      finalSubmit.open("POST", "final.do", true);
      finalSubmit.send(tab1Form + tab2Form);
    }
    function finalSubmitCallback() {
      if (finalSubmit.readyState == 4) {
        document.getElementById("divResult").innerHTML =
finalSubmit.responseText;
      }
    }
  </script>
</head>
<body onload="init();">
  <form name="masterForm" id="tab1Form" method="post" action="/test/tab1.do">
    Field1: <input name="tab1Form.field1" value="val1" type="text"><br>
  </form>
  <br>
  <form name="masterForm" id="tab2Form" method="post" action="/test/tab2.do">
    Field2: <input name="tab2Form.field2" value="val2" type="text"><br>
  </form>
  <br>
  <input value="Submit All" onclick="submitAll();" type="button">
  <br><br>
  <div id="divResult"></div>
</body>
</html>


Note that I removed all the Dojo-related stuff, and some stuff that isn't
related to this submissino, just to try and keep it small, but, the
important thing to note is that when the submission is made, the request
that goes across is a POST to http://localhost:8080/test/final.do, as
expected, and the POST body is:

tab1Form.field1=val1&tab2Form.field2=val2&

...also as expected, verified in Firebug.  Lastly, here's struts-config:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
  <form-beans>
    <form-bean name="masterForm" type="app.test.formbeans.MasterForm" />
  </form-beans>
  <action-mappings>
    <action path="/final" type="app.test.actions.FinalAction"
name="masterForm" scope="request" validate="false">
      <forward name="defaultForward" path="/final.jsp" />
    </action>
  </action-mappings>
</struts-config>


Note here that I removed the stuff that generated the markup from above
too, since that seems to be working just fine, I'm pretty sure this is all
that would be relevant.

So, seeing any obvious blunders on my part?  Thanks Hubert!

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Fri, September 22, 2006 1:10 pm, Hubert Rabago wrote:
> So what does happen when you submit the form?  Are you getting NPEs?
>
> By the time Struts attempts to populate the form bean, the nested
> forms should already be instantiated.  You should have getters and
> setters for af1 and af2, and getAf1() and getAf2() should not return a
> null.  This could be an issue if the form bean is new, either because
> it's in request scope, or in session scope but was not previously
> instantiated.
>
> Hubert
>
> On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> I'm facing a situation where ideally I'd like to have a single
>> ActionForm
>> like so:
>>
>> public class MyActionForm extends ActionForm {
>>   AnotherActionForm1 af1;
>>   AnotherActionForm2 af2;
>> }
>>
>> When in my JSP I do:
>>
>> <html:text property="af1.field1" />
>>
>> ...I do indeed see the value as I expect.  The way I did this is to have
>> an Action mapping that references MyActionForm, then within the Action I
>> instantiate AnotherActionForm1, set the value of field1 on it, and then
>> set af1 to that new AnotherActionForm1 instance.  That all works nicely.
>>
>> Here's where I run into a problem...
>>
>> On the page I basically have 2 separate HTML forms, one for
>> AnotherActionForm1 and another for AnotherActionForm2.  However, I have
>> a
>> SINGLE submit button at the end (just plain button that makes an AJAX
>> request).  onClick of that button, I create a query string from the
>> values
>> of both forms, and make a request to the server with the query string
>> attached.  The parameter names of the query string arguments are
>> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The mapping
>> that the request goes to again references MyActionForm.
>>
>> What I've been told should happen is that Struts should be able to
>> instantiate those two nested beans and set the properties, since the
>> parameter names give it the information it needs.  This does not however
>> seem to be happening.
>>
>> So, two questions... first, is that in fact the expected behavoir?  And
>> two, if so, any ideas what I'm doing wrong?  I can post all the
>> pertinent
>> config and code, but thought it might be something more generic that
>> wouldn't require all that.  This is the first time I've ever had a need
>> to
>> nest forms like this, so it's a new question for me.
>>
>> Thanks all!
>>
>> Frank
>>
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>>  (2006, Apress, ISBN 1-59059-695-1)
>> Java Web Parts - http://javawebparts.sourceforge.net
>>  Supplying the wheel, so you don't have to reinvent it!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Nested form beans

Posted by Hubert Rabago <hr...@gmail.com>.
So what does happen when you submit the form?  Are you getting NPEs?

By the time Struts attempts to populate the form bean, the nested
forms should already be instantiated.  You should have getters and
setters for af1 and af2, and getAf1() and getAf2() should not return a
null.  This could be an issue if the form bean is new, either because
it's in request scope, or in session scope but was not previously
instantiated.

Hubert

On 9/22/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> I'm facing a situation where ideally I'd like to have a single ActionForm
> like so:
>
> public class MyActionForm extends ActionForm {
>   AnotherActionForm1 af1;
>   AnotherActionForm2 af2;
> }
>
> When in my JSP I do:
>
> <html:text property="af1.field1" />
>
> ...I do indeed see the value as I expect.  The way I did this is to have
> an Action mapping that references MyActionForm, then within the Action I
> instantiate AnotherActionForm1, set the value of field1 on it, and then
> set af1 to that new AnotherActionForm1 instance.  That all works nicely.
>
> Here's where I run into a problem...
>
> On the page I basically have 2 separate HTML forms, one for
> AnotherActionForm1 and another for AnotherActionForm2.  However, I have a
> SINGLE submit button at the end (just plain button that makes an AJAX
> request).  onClick of that button, I create a query string from the values
> of both forms, and make a request to the server with the query string
> attached.  The parameter names of the query string arguments are
> af1.field1 and af2.field2, mimicing what's in MyActionForm.  The mapping
> that the request goes to again references MyActionForm.
>
> What I've been told should happen is that Struts should be able to
> instantiate those two nested beans and set the properties, since the
> parameter names give it the information it needs.  This does not however
> seem to be happening.
>
> So, two questions... first, is that in fact the expected behavoir?  And
> two, if so, any ideas what I'm doing wrong?  I can post all the pertinent
> config and code, but thought it might be something more generic that
> wouldn't require all that.  This is the first time I've ever had a need to
> nest forms like this, so it's a new question for me.
>
> Thanks all!
>
> Frank
>
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org