RE: How to instantiate a DynaActionForm?
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?
Hi, we found some help in the way to instanciate a DynaActionForm presented by Carl Walker . But actually, we aren't able to put the form in the request. This works only in the session object. Is there anyone to help me? Thanks to answer quickly Julie Cardon
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. Then in the validator, you have have a form for loginForm and another for profileForm (if you need it). -T. Joseph Yang wrote: 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]
RE: How to instantiate a DynaActionForm?
I think ted posted one answer on a previous post: declare the same bean with two different names. The other options it to validate based on the action (assuming you are using validator) instead of the form. sandeep --- Joseph Yang <[EMAIL PROTECTED]> wrote: > 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] > __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to instantiate a DynaActionForm?
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]
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]
Re: How to instantiate a DynaActionForm?
I have an org.apache.struts.validator.DynaValidatorForm called "AccountForm" in my struts-config.xml. The code below is similar to that found in the link referenced below, except I call the initialize() method to get the initial= attributes from the form bean definition. // load up AccountForm ModuleConfig mc = _mapping.getModuleConfig(); FormBeanConfig fbc = mc.findFormBeanConfig("AccountForm"); DynaActionFormClass dafc = DynaActionFormClass.createDynaActionFormClass(fbc); DynaActionForm theForm = (DynaActionForm)dafc.newInstance(); theForm.initialize( _mapping ); theForm.set("accountId", new Integer(account.getAccountId())); theForm.set("username", account.getUsername()); theForm.set("groupslist", account.getGroupslist()); Date expTime = account.getExpTime(); if( expTime != null ) { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/"); theForm.set("expTime", sdf.format(expTime)); } theForm.set("lockable", new Boolean(account.isLockable())); theForm.set("state", new Integer(account.getState())); _request.setAttribute("AccountForm", theForm); "Raible, Matt" wrote: > 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to instantiate a DynaActionForm?
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]
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]