Title: Message
A few comments on the comments:
1. Not really, to make it nice and portable, I use the generated forms as a base and extend it with what else I need bubbled to the front end.  Say a java.sql.Date, I like to collect it as three seperate String, see if it a valid date then set it, so my extended form has these three seperate fields and in validation, if they all match up I set the actual java.sql.Date.  Found this works quite nice.
 
2. Agreed, as you see above, I do manual merging, but I think to keep the generation as generic and usefull to the most people, then extending the form becomes a good solution.
 
3. I absolutly agree that a setData would be great, and should be prety easy to add in, the getData but change x=y to y=x.
 
I am using XDoclet CVS version for a J2EE(jboss)/Struts project and you guys kick a$$.
 
Possible Solution in struts_form.j
    public void setData(<XDtEjbDataObj:dataObjectClass /> dataHolder)
    {
      
       <XDtStrutsForm:forAllFormFields>
 this.XDtMethod:getterMethod/>(dataolder.<XDtMethod:setterMethod/>());
       </XDtStrutsForm:forAllFormFields>
    }
 
Later,
Jake T.
 
 
-----Original Message-----
From: Michael Szlapa [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 3:31 PM
To: [EMAIL PROTECTED]
Subject: [Xdoclet-user] Struts Form comments

Hi,
 
I am relatively new to xDoclet and my problems may come from incorrect use, if it is so pls let me know.
 
While using the Struts form template I have encountered few problems that may be relevant to others as well, if it is the case maybe template should be updated:
 
1. Struts form properties should be of type String rather than of the business type (Date, Integer etc) as they are right now. The fields will be set automatically based on the HTTP request parameters. As HTTP request parameters are Strings xDoclet generated ActionForm with Date field will fail in rather cryptic way.
 
 
2. If you have the Data object with different field types then Action form then bulk data access methods (setData /getData) will not work that easilly. The simplest solution is to provide merge points for body of both methods.
I use the runtime typeconverter (mapper) by Andrej Sobkowski (http://www.mycgiserver.com/~andrej/technical/struts/struts.jsp). It could be used in sample implementations of the merged setDate/getData methods.
 
3. It is usefull to also have setData method generated in addition to getData. Using StrutsForm.setData(myVO) rather then constructor new StrutsForm(myVO) seems better since Struts will ofter provide form object that is already placed in the relevant scope (request, page etc.) under relevant key. All the action has to do is to update contents of this object. Action class does not have to know the scope or the key of the object and does not have to manually insert it. Also there is less objects discarded.
 
Attached is form template I am using currently - seems to work, but may still have bugs. It requires the earlier mentioned mapper. It does not have the constructor, it is useful in some situations, so it can be copied from original template.
 
Regards,
Michael

Reply via email to