RE: How to instantiate a DynaActionForm?

2003-06-19 Thread Joseph Yang
This is wonderful!! Now it's working great!

Thank you so much Ted!


P.S

In case someone also wants to use this approach, after populate the profile
info and put the bean into request, you have to do:

request.setAttribute("profileForm", formObj) instead of
request.setAttribute("baseForm", formObj)

-Original Message-
From: Ted Husted [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 19, 2003 4:44 AM
To: Struts Users Mailing List
Subject: Re: How to instantiate a DynaActionForm?


The validator actually goes by the ActionMapping attribute name, which
by default is the formbean name. So you can have a base formbean,
defined as an DynaActionForm, and then give it different attributes in
each mapping.

 Thanks for all the answers!
>
> I used Carl's example, and it works
>
> But I do like Ted's idea, so I tried it out, combined the two forms
> together, then the validator is not working, because when I define the
> validation, there are no "firstName" or "lastName" on the login page...
>
> Any suggestions on this?





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to instantiate a DynaActionForm?

2003-06-18 Thread Joseph Yang
Thanks for all the answers!

I used Carl's example, and it works

But I do like Ted's idea, so I tried it out, combined the two forms
together, then the validator is not working, because when I define the
validation, there are no "firstName" or "lastName" on the login page...

Any suggestions on this?


-Original Message-
From: Ted Husted [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 1:13 PM
To: Struts Users Mailing List
Subject: Re: How to instantiate a DynaActionForm?


Another approach would be to combine the loginForm and the
userProfileForm into a single coarse-grained form. Then you could simply
set the additional properties, rather than instantiate another object.

> http://www.mail-archive.com/[EMAIL PROTECTED]/msg12356.html
>
> -----Original Message-
> From: Joseph Yang [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 18, 2003 11:07 AM
> To: 'Struts Users Mailing List'
> Subject: How to instantiate a DynaActionForm?
>
>
> Hello,
>
> I have two pages: login.jsp and userProfile.jsp
>
> I defined two DynaActionForm(s) in struts-config.xml: loginForm and
> userProfileForm
>
> Now inside loginAction class, after handle the authentication, I want to
get
> the user profile information from database, then instantiate
userProfileForm
> and put it into the request. what I did was:
>
> DynaActionForm form = new DynaActionForm();
> form.set("firstName", "John");
> form.set("lastName", "Doe");
> ...
> request.setAttribute("userProfileForm", form);
>
> The setters throw Null pointer exception
>
> Please help me out here
>
> Thanks
>
>
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to instantiate a DynaActionForm?

2003-06-18 Thread Joseph Yang
Hello,

I have two pages: login.jsp and userProfile.jsp

I defined two DynaActionForm(s) in struts-config.xml: loginForm and
userProfileForm

Now inside loginAction class, after handle the authentication, I want to get
the user profile information from database, then instantiate userProfileForm
and put it into the request. what I did was:

DynaActionForm form = new DynaActionForm();
form.set("firstName", "John");
form.set("lastName", "Doe");
...
request.setAttribute("userProfileForm", form);

The setters throw Null pointer exception

Please help me out here

Thanks



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Pre-populate DynaActionForm

2003-06-13 Thread Joseph Yang
Hi everyone,

I have a login page and client profile page(name, phone, address...), after
login, the client's information will be displayed so the client can modify

When I use ActionForm (clientInfoForm), in loginAction, I get the
information for the client, set up the setters of clientInfoForm, put this
form in request, then it's done

Now I want to do the same thing but use DynaActionForm for my
clientInfoForm, what should I do to pre-populate it? (there will be no
setters any more)


Thanks



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]