jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Is  it possible to use DynaActionForm for the following? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Is  it possible to use DynaActionForm for the following?" Watch "Is  it possible to use DynaActionForm for the following?" New topic
Author

Is it possible to use DynaActionForm for the following?

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I have a form which if the user contains no serial # a text box needs to appear. Which I have done now. My problem is that I am trying to validate the field. However it does not seem to get to the validation method which I have defined. Can this be done with org.apache.struts.action.DynaActionForm?
Im using <html:multibox in my jsp and that is why I am using DynaActionForm.

thank you all for your time

In my jsp I have the following

I have the following in the struts-config

In the validator-rules.xml I have

[ February 11, 2005: Message edited by: john mattucci ]
Nathan Hook
Ranch Hand

Joined: Jan 10, 2005
Posts: 81
Where is your entry for your validation.xml? The file that is used to state how forms are validated?

Best of Luck,

Nate
[ February 10, 2005: Message edited by: Nathan Hook ]
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I have also tried to set the form to use org.apache.struts.validator.DynaValidatorActionForm, but the validation is never called. In validation.xml I defined the form

<form name="myTonesActionForm">
<field property="serialnumber"
Nathan Hook
Ranch Hand

Joined: Jan 10, 2005
Posts: 81
does your validator.xml file look like the following?



Also, do you define the validator-rules.xml and validator.xml in your struts -config.xml file?



Finally, are you just checking to see if the registration number is present? Or are you checking it for a specific format?

Best of Luck,

Nate
[ February 10, 2005: Message edited by: Nathan Hook ]
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Yes to all questions. The page can either have a serial number text box if the user does not have a serial number or not if he does have one. So I cant use required since the field might not appear at times. But for now I even changed the field to required and it still does not validate
Nathan Hook
Ranch Hand

Joined: Jan 10, 2005
Posts: 81
Ah, I might see part of the problem.

In your form, you have two attributes named newtones and oldtones.

Then in your validator.xml you are looking for a attribute named serialnumber.

All these values have to be named the same. If they arn't then you will run into problems. You should at least add the attribute serialnumber to your form. FYI, You don't have to have all the attributes of your form in the validator.xml.

Best of Luck,

Nate
[ February 10, 2005: Message edited by: Nathan Hook ]
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
No i dont have all my fields in the validator.xml only serial number. But serial number is only present some of the time in other words i cant mark it required. I created my own method in the validator-rules.xml. The problem im facing now is that this method is not even being called and even I mark the field as required in the validator.xml no error is shown it always goes directly to the action.
Peter Vennel
Ranch Hand

Joined: Dec 18, 2003
Posts: 46
Hi John,

This is pertaining to another posting you did earlier. I am getting the same error. I tried your approach of rebuilding the project to remove any stale files. But that did not work. Did you do anything else??

Can you please reply to my post [b]IllegalArgumentException: argument type mismatch[b] posted on February 10, 2005 02:24 PM.

Any help appreciated.

Thanks.

Peter.

p.s. I tried to email you, but the mail bounced back.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is it possible to use DynaActionForm for the following?
 
Similar Threads
Show a progress page using Struts
How to get a new instance of a form bean?
How can I access hidden value from nested:hidden indexed property
Unable to find setter method for attribute: locale
hi