Re: How do I populate a DynaValidatorForm?

2003-09-26 Thread Pratik Patel
DynaActionForms are not a drop-in replacement for ActionForms. If you
need to access ActionForm properties in your Action, you will need to
use the map-style accessor, like myForm.get(name). If you actively use
the ActionForm object in your Action, then you may want to use
conventional ActionForms instead.
Why aren't you just using ActionForms? To be honest, I never use 
DynaActionForms. Sure, there's an extra Java class that needs to be 
written, but I find it easier to write an ActionForm class than write 
out a XML descriptor for a DynaActionForm. Plus it's easier to unit test 
 a concrete class than one that assumes its properties at runtime. If 
you're too lazy (like me) to actually write the ActionForm class, just 
use XDoclet to generate one for you.

cheers,
Pratik


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


RE: How do I populate a DynaValidatorForm?

2003-09-26 Thread Fenderbosch, Eric
Where do you specify the
@struts.form-field (0..*)
tags so that XDoclet creates the form for you?
Right now, I have a hand coded form and XDoclet creates the form-bean/ section of my 
struts-config for me, but I'm not creating the actual ActionForm subclass with XDoclet.

-Original Message-
From: Pratik Patel [mailto:[EMAIL PROTECTED]
Sent: Friday, September 26, 2003 06:53
To: [EMAIL PROTECTED]
Subject: Re: How do I populate a DynaValidatorForm?


 DynaActionForms are not a drop-in replacement for ActionForms. If you
 need to access ActionForm properties in your Action, you will need to
 use the map-style accessor, like myForm.get(name). If you actively use
 the ActionForm object in your Action, then you may want to use
 conventional ActionForms instead.

Why aren't you just using ActionForms? To be honest, I never use 
DynaActionForms. Sure, there's an extra Java class that needs to be 
written, but I find it easier to write an ActionForm class than write 
out a XML descriptor for a DynaActionForm. Plus it's easier to unit test 
  a concrete class than one that assumes its properties at runtime. If 
you're too lazy (like me) to actually write the ActionForm class, just 
use XDoclet to generate one for you.


cheers,
Pratik



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



Re: How do I populate a DynaValidatorForm?

2003-09-26 Thread Pratik Patel
Fenderbosch, Eric wrote:

Where do you specify the
@struts.form-field (0..*)
tags so that XDoclet creates the form for you?
Right now, I have a hand coded form and XDoclet creates the form-bean/ section of my 
struts-config for me, but I'm not creating the actual ActionForm subclass with XDoclet.
In my domain objects; here's the objects from a Struts app I'm currently 
working on:

Domain Object   XDoclet Generated ActionForm
UserUserForm
Forum   ForumForm
PostPostForm
Thread  ThreadForm
Sample domain object:

package org.sourceforge.jwebforum.model;
import java.util.Date;
/**
 * @struts.form include-all=true
 * extends=org.sourceforge.jwebforum.webapp.form.BaseForm
 */
public class User {
private String password;
private String email;
private Date signupdate;
private String firstname;
private String lastname;
private String username;
private long userid;
public User(String password, String email, java.sql.Timestamp 
signupdate, String firstname, String lastname, String username, long 
userid) {
this.password = password;
this.email = email;
this.signupdate = signupdate;
this.firstname = firstname;
this.lastname = lastname;
this.username = username;
this.userid = userid;
}

public User() {
}
/** Password of the user.
 * @struts.validator type=required msgkey=errors.required
 */
public String getPassword() {
return password;
}
...


I hope to have this Struts application uploaded to sourceforge within 
two weeks (with full source, of course). It's still undergoing some 
refactoring, but I can send you the current snapshot if you're interested.

cheers,
Pratik


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


How do I populate a DynaValidatorForm?

2003-09-25 Thread Barry Volpe
With an Action Form we do the following:

form = new UserForm();
form.setUserid(5); 

What is the equivalent for a DynaValidatorForm?

Let's say my DynaValidatorForm is myForm

Of course this does not work (compiler does not know what myForm is.)

DynaValidatorForm dynaForm = (DynaValidatorForm)myForm; 

myForm.setUserid(5);


Thanks,
Barry


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



Re: How do I populate a DynaValidatorForm?

2003-09-25 Thread Mick Knutson
In the Action itself, there is a form object already created. Then this
should work inside the action:
( ( DynaActionForm ) form ).set( Constants.USER_ID_KEY, 5);

---
Thanks
Mick Knutson
http://www.baselogic.com

+001(805) 563-0666 Office
+001 (708) 570-2772 Fax
---

- Original Message - 
From: Barry Volpe [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, September 25, 2003 2:16 PM
Subject: How do I populate a DynaValidatorForm?


 With an Action Form we do the following:

 form = new UserForm();
 form.setUserid(5);

 What is the equivalent for a DynaValidatorForm?

 Let's say my DynaValidatorForm is myForm

 Of course this does not work (compiler does not know what myForm is.)

 DynaValidatorForm dynaForm = (DynaValidatorForm)myForm;

 myForm.setUserid(5);


 Thanks,
 Barry


 -
 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 do I populate a DynaValidatorForm?

2003-09-25 Thread Mick Knutson
That was it. Thanks very much!

---
Thanks
Mick Knutson
http://www.baselogic.com

+001(805) 563-0666 Office
+001 (708) 570-2772 Fax
---

- Original Message - 
From: Barry Volpe [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, September 25, 2003 2:16 PM
Subject: How do I populate a DynaValidatorForm?


 With an Action Form we do the following:
 
 form = new UserForm();
 form.setUserid(5); 
 
 What is the equivalent for a DynaValidatorForm?
 
 Let's say my DynaValidatorForm is myForm
 
 Of course this does not work (compiler does not know what myForm is.)
 
 DynaValidatorForm dynaForm = (DynaValidatorForm)myForm; 
 
 myForm.setUserid(5);
 
 
 Thanks,
 Barry
 
 
 -
 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 do I populate a DynaValidatorForm?

2003-09-25 Thread Barry Volpe
Hi Mick,

This does not appear to be working.  I was also wondering let's say
in my struts-config I have two different DynaValidator forms defined.
Both forms have the same property say units.  I am not using a Constants.
but how would it know which units needs to be populated?

Thanks,
Barry


- Original Message - 
From: Mick Knutson [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, September 25, 2003 2:24 PM
Subject: Re: How do I populate a DynaValidatorForm?


 In the Action itself, there is a form object already created. Then this
 should work inside the action:
 ( ( DynaActionForm ) form ).set( Constants.USER_ID_KEY, 5);

 ---
 Thanks
 Mick Knutson
 http://www.baselogic.com

 +001(805) 563-0666 Office
 +001 (708) 570-2772 Fax
 ---

 - Original Message - 
 From: Barry Volpe [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, September 25, 2003 2:16 PM
 Subject: How do I populate a DynaValidatorForm?


  With an Action Form we do the following:
 
  form = new UserForm();
  form.setUserid(5);
 
  What is the equivalent for a DynaValidatorForm?
 
  Let's say my DynaValidatorForm is myForm
 
  Of course this does not work (compiler does not know what myForm
is.)
 
  DynaValidatorForm dynaForm = (DynaValidatorForm)myForm;
 
  myForm.setUserid(5);
 
 
  Thanks,
  Barry
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

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







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



RE: How do I populate a DynaValidatorForm?

2003-09-25 Thread Wendy Smoak
Barry Volpe wrote:
 With an Action Form we do the following:
 form = new UserForm();
 form.setUserid(5); 
 What is the equivalent for a DynaValidatorForm?
 Let's say my DynaValidatorForm is myForm
 Of course this does not work (compiler does not know what myForm
is.)
 DynaValidatorForm dynaForm = (DynaValidatorForm)myForm; 
 myForm.setUserid(5);

http://jakarta.apache.org/struts/userGuide/building_controller.html#dyna
_action_form_classes

DynaActionForms are not a drop-in replacement for ActionForms. If you
need to access ActionForm properties in your Action, you will need to
use the map-style accessor, like myForm.get(name). If you actively use
the ActionForm object in your Action, then you may want to use
conventional ActionForms instead.

I populate mine largely with BeanUtils.copyProperties(...).  If you need
to address a specific property, you can use the Map contained within the
DVForm:

 DynaValidatorForm dynaForm = (DynaValidatorForm)myForm; 
 myForm.setUserid(5);

2nd line becomes:
myForm.set(userid,5);

http://jakarta.apache.org/struts/api/org/apache/struts/validator/DynaVal
idatorForm.html

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM 


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



Re: How do I populate a DynaValidatorForm?

2003-09-25 Thread Mick Knutson
Each JSP will have 1 DynaForm assigned to a given form. So the formA.units
is different than forB.units in the DynaForm.

So, when you submit a form, there is just 1 Dynaform that is submitted. Or
in your case you want to show formA DynaForm with forma.units.

---
Thanks
Mick Knutson
http://www.baselogic.com

+001(805) 563-0666 Office
+001 (708) 570-2772 Fax
---

- Original Message - 
From: Barry Volpe [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, September 25, 2003 2:35 PM
Subject: Re: How do I populate a DynaValidatorForm?


 Hi Mick,

 This does not appear to be working.  I was also wondering let's say
 in my struts-config I have two different DynaValidator forms defined.
 Both forms have the same property say units.  I am not using a
Constants.
 but how would it know which units needs to be populated?

 Thanks,
 Barry


 - Original Message - 
 From: Mick Knutson [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, September 25, 2003 2:24 PM
 Subject: Re: How do I populate a DynaValidatorForm?


  In the Action itself, there is a form object already created. Then this
  should work inside the action:
  ( ( DynaActionForm ) form ).set( Constants.USER_ID_KEY, 5);
 
  ---
  Thanks
  Mick Knutson
  http://www.baselogic.com
 
  +001(805) 563-0666 Office
  +001 (708) 570-2772 Fax
  ---
 
  - Original Message - 
  From: Barry Volpe [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Sent: Thursday, September 25, 2003 2:16 PM
  Subject: How do I populate a DynaValidatorForm?
 
 
   With an Action Form we do the following:
  
   form = new UserForm();
   form.setUserid(5);
  
   What is the equivalent for a DynaValidatorForm?
  
   Let's say my DynaValidatorForm is myForm
  
   Of course this does not work (compiler does not know what myForm
 is.)
  
   DynaValidatorForm dynaForm = (DynaValidatorForm)myForm;
  
   myForm.setUserid(5);
  
  
   Thanks,
   Barry
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 



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



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