Struts - Validation

T

Tim

I seem to be getting an error in the validation method of the
ValidatorForm sub class but the controller still passes the info to the
Action class which proceeds to bomb due to a missing startDate property.
How does Struts determine that an error has been found (ActionErrors
object not null?) and what causes it to show the error on the sending
page rather than executing the Action bean?
Any ideas?

The System.out.println("Entering validate in ScheduleSelectForm");
prints so I am getting into the method.
What do I put in the sending page to see the errors?
<html:errors/>



ValidatorForm method

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors result = super.validate(mapping, request);

System.out.println("Entering validate in ScheduleSelectForm");

return( result );
}


Struts-config.xml file portion

<action path="/gamesScheduleList"
type="hockeybeans.Test"
name="scheduleSelectForm"
scope="request"
validate="true"<forward
name="failure"
path="/criticalError.jsp"/>
<forward
name="success"
path="/gamesScheduleList.jsp"/>
</action>
 
S

Sudsy

Tim wrote:
<action path="/gamesScheduleList"
type="hockeybeans.Test"
name="scheduleSelectForm"
scope="request"
validate="true"

Did you read my article? Did you even read the struts-config_1_0.dtd
file? Here's an excerpt:

input Context-relative path of the input form to which control
should be returned if a validation error is encountered.
Required if "name" is specified and the input bean
returns validation errors. Optional if "name" is
specified and the input bean does not return validation
errors. Not allowed if "name" is not specified.

(HINT: input is an attribute of the action element)
 
T

Tim

I read it. It didn't help.
Tim wrote:



Did you read my article? Did you even read the struts-config_1_0.dtd
file? Here's an excerpt:

input Context-relative path of the input form to which control
should be returned if a validation error is encountered.
Required if "name" is specified and the input bean
returns validation errors. Optional if "name" is
specified and the input bean does not return validation
errors. Not allowed if "name" is not specified.

(HINT: input is an attribute of the action element)
 
T

Tim

Anyway, I had tried using that previously and it didn't solve the
problem. I just tried it again and it still went to the Action bean.
So there must be some other problem with my setup.
 
S

Sudsy

Tim said:
Anyway, I had tried using that previously and it didn't solve the
problem. I just tried it again and it still went to the Action bean.
So there must be some other problem with my setup.

Drop me a note off-list with the following attached:
- the complete struts-config.xml
- the form source
- the action source
Should be easy enough to run a quick test on one of my
prototyping servers...
 
T

Tim

To be honest with you, your page seems to have too much fragmented code
examples to follow and when you switch to the ccnum example, whose
OptionTestForm source is shown, you don't show the rest of the files
related to it, which may have been helpful to me.
So yes, I did look but the example I wanted to look at had only part of
the information so I couldn't trace through to see if I was specifying
something wrong.
 
T

Tim

Sudsy said:
Drop me a note off-list with the following attached:
What does off-list mean? email.
Do you need the "sending" html too?
- the complete struts-config.xml
- the form source
Do you mean the ValidatorForm java source code?
 
S

Sudsy

Tim wrote:
What does off-list mean? email.
Do you need the "sending" html too?

Yes and yes. The address I use for posting is actually valid,
apparently an oddity these days.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top