Actually there's a module in xdoclet that will do this the other way around for you - it'll create the struts-config form decs and the validation.xml if you put in javadoc-style hooks into a DTO, with javadoc for getter / setter.

http://xdoclet.sourceforge.net/tags/apache-tags.html

I know what you mean about the action forms. I used a couple of different methodologies now, one of which was quite cunning :) but ultimately I keep coming back to the basic struts dynavalidator solution.

I have a dream of a typed HTTP POST method! Yowsa! But I think it's too strong an idea for the web and they'll assassinate me before I get it pushed through....

On 04/05/2004 10:16 AM Joe Hertz wrote:
I use Hibernate. I wouldnt consider this goal at all obtainable without a robust. ORM tool.

Don't get me wrong, I'm not hellbent on using Maps for everything. I dont mind creating the forms. I mind creating N extra classes because of the JSP type conversion issue.

What I'm going to do in the semi-short term:

Have a build task of some kind go through my DynaForm declarations and create me a class chocked full of static final String declarations. Things like

static final String XformYproperty = "y"; etc.

This way I can refer to the Strings whenever I do a formBean.get() or formBean.set() and get a COMPILE TIME error if I typo.

I believe something ought to be done about the way dynaform properties are declared. 99% of the time they need to be Strings.

Wouldn't it be more useful to have the form object do the type conversion? Have a way to tell it the "JSP type" (99% String) and the "application type". Make the form objects smart enough to give you a properly typed result, much in the same way Hibernate's Session.load(Object obj, Object id) populates the right values into obj.

I came from a JSP based framework that always but Always assumed String's in the JSP, and allowed you to import/declare your "FormBean/PersistenceBean" mappings via JDBC. It worked very well, and I find myself sighing "for the good old days" every time I find myself fighting with BeanUtils.copyProperties.

-Joe


-----Original Message-----
From: Adam Hardy [mailto:[EMAIL PROTECTED] Sent: Sunday, April 04, 2004 6:05 AM
To: Struts Users Mailing List
Subject: Re: integer validation problem



A lofty goal, Joe! What are you using on the back-end to connect to the database?


Until I decided to go with xdoclet which generates the DTOs and the EJBs for me, I was wondering about using some sort of solution like you, where I used a DynaForm mothership that \'released\' its Map to the back-end via the getMap() method (for want of a better metaphor).

There were several drawbacks I could see.

1: there is no setMap() method to go in the other direction

2: the back-end would be strongly coupled to the web-interface by a dependence on it either for validation or, if the back-end did validation, because validation / type-casting errors would only be raised at the back-end

3: there is no clever way to set up a programmatic \'contract\' between the front-end and back-end as to how the variable-keys in the map would be named (front-end keys are based in struts-config.xml)


Adam


On 04/04/2004 10:24 AM Joe Hertz wrote:

Jolly, you answered it yourself:

\"I dont want to write another actionForm class that represent my DTO...I am
in great trouble.\"


This isn\'t Struts causing you the problem. It\'s the JSP spec.

The automatic type conversion it does for you, will cause \"null integers\" to
be sent into your DTO as 0.


So yes, if you cannot be bothered to create another bean

form class,


then
there is no solution. Not one that uses JSP\'s anyway.

I do feel your pain though. It seems on many levels, just

plain silly


to have
to declare objects almost but not completely like the ones

you already have


(complete with the risk of accidental typos) just to

satisfy the web tier.


My suggestion: Find a tool that helps you define your form

bean getter


and
setters, or do what I do: Use DynaBeans. I\'m doing some

reasonably complex


validation and nesting with DynaBeans in forms. In fact, I have a \"GenericListForm\" DynaBean which just contains a List

property. I can use


this form on any JSP that shows a list of objects. For me,

those list objects


are dynabeans themselves.

My goal is to never have to write a getter or setter in a form bean ever
again.


Hope this helps

-Joe




-----Original Message-----
From: jolly [mailto:[EMAIL PROTECTED]
Sent: Saturday, April 03, 2004 11:12 PM
To: Struts Users Mailing List
Subject: Re: integer validation problem


Dear Richard
Thanks for your reply. But I dont want to declare this type
of variable as String. I want to use the DTO as form bean property. For this it is not validated by validator. so I have to make my DTO dirtty that is I have to declare another attribute for all variables that are not String. And I pass that String attribute to the jsp and then I set the validated value to my integer or double variable. This type of solution cant satisfy me. I dont want to write
another bean form class. So I have to comprise myself with that solution.
thanks again for your help
-jolly


On Sat, 03 Apr 2004 12:16:35 -0800, Richard Yee wrote


Jolly,
If you had checked the archives, you would have found your answer immediately since this topic has come up several times in the past two weeks. Anyway, declare your firstCategoryAmount and

incrementDTO



attributes as Strings instead of int and double.

-Richard

At 10:57 PM 4/2/2004, you wrote:



Hi please help me. My form-bean declaration is like this

<form-bean



name=\"payScaleForm\"

type=\"com.mislbd.iris.util.CustomDynaActioForm\">


<form-property name=\"payScaleDTO\" type=\"com.mislbd.iris.hr.core.compensation.PayScaleDTO\" />

and PayScaleDTO has incrementDTO as its attribute.
I define my jsp as:
<layout:text  key=\"payScale.basicPay\"

property=\"payScaleDTO.basicPay\"



styleClass=\"LABEL\" isRequired=\"true\"/>
<layout:text
key=\"payScale.Increment.firstCategoryAmount\"
property=\"payScaleDTO.increment.firstCategoryAmount\"

styleClass=\"LABEL\"



isRequired=\"true\"/>

basicPay and firstCategoryAmount are defined as integer or double.
But this fields are not validated if i enter text and

saved zero to



database. I cant use copyproperties of beanutils because

of the ha a



relationship. I dont want to write another actionForm class that
represent my DTO. How can I solve my problem. please help

me. I am in



great trouble. JOlly
--
jolly



-----------------------------------------------------------

----------


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]


--
jolly


------------------------------------------------------------

---------


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]




--
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian


--------------------------------------------------------------------- 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]




--
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian


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



Reply via email to