ps. My post added some "3D" text that isn't supposed to be there ...

Thanks Jeromy.

Yes I do have a <s:head> attribute, maybe not *exactly* but I have:
<s:head theme="ajax" />

Apologies for the confusion.
What I meant in my pevious post was that I had tried a few ways to do this 
validation task.
In my initial post I had described one of these attempts which I think should 
have worked.

What I am getting regardless of what sort of validation I try to implement is 
this error:

java.lang.StringIndexOutOfBoundsException: String index out of range: -7

You mentioned the getters and setters for the fieldnames ... this only works 
though if the fields are stored in the action right?
coz the fields I have aren't stored in the action, they are stored in a Form 
class.

Ie my action looks something like:

public String execute() {
        MyForm myForm = (MyForm)super.form;
        String myField = myForm.getFieldName();
}

Markus: Thanks for your reply too, I am trying it right now. Just want this to 
work grrr


-----Original Message-----
From: Jeromy Evans [mailto:[EMAIL PROTECTED]
Sent: Monday, 14 July 2008 4:25 PM
To: Struts Users Mailing List
Subject: Re: struts2 validation

Nicole Luneburg wrote:
>
>
>
> <s:form action=3D"myaction" method=3D"post" validate=3D"true">
>
The validate attribute here is used to enable client-side validation
only.  That will only work if you include the <s:head> attribute in the
page.


>
>
> My setup is that I have an Action class, which uses a Form to set and get f= 
> ield values from the JSP page.
>
> In Struts1 I was using the validate(...) method in the Form class.
>
> It seems none of the Struts2 validation examples on the net are working for=  
> me.
>
>

You haven't mentioned whether you're using XML validation or
annotation-based validation.  If by not working you mean "does nothing",
then your XML file is probably incorrectly named or your missing an
annotation.  (You need to enable this separately from client-side
validation)

Whatever the case, the main difference between Struts1 and Struts2 here
is that Struts2 performs validation on the Object, not on the form
parameters.
That means, to check that "fieldName" is non-blank, it will call
getFieldName() after setFieldName() was called by the ParametersInterceptor.

A common problem is to forget the getter, but in that case Struts will
keep returning INPUT (validation failed) instead of invoking your action.

Hope that helps,
Jeromy Evans





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


The contents of this email are confidential and may be subject to legal or 
professional privilege and copyright. No representation is made that this email 
is free of viruses or other defects. If you have received this communication in 
error, you may not copy or distribute any part of it or otherwise disclose its 
contents to anyone. Please advise the sender of your incorrect receipt of this 
correspondence.

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

Reply via email to