struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dug ." <dugdugdug...@googlemail.com>
Subject Validation referencing problem, using annotations
Date Fri, 15 Aug 2008 04:16:36 GMT
Hi guys
I'm close to finishing my 1st project with struts2, which I'm quite excited
about. I've gotten around to validation (!).

I'm having some issues getting validation to work on one of my actions. I
can't reference the variables from the web page in order to validate them.
I've named the variables in such a fashion that they go straight into the
bean (go struts!).

How do I properly reference them to validate them?


*my form:(*fragment)
<s:form action="ApplyForRole" enctype="multipart/form-data" method="post">

    <h3>your contact details</h3>
    <s:hidden name="role_id" value="%{role.role_id}" />
    <s:textfield required="true" labelposition="top" size="25" name="*
applicant.name"* label="name" /><br />
......
</s:form>

*my action:*
...
@Validations(
requiredStrings =
{@RequiredStringValidator(type<%7B@RequiredStringValidator(type>=
ValidatorType.SIMPLE, fieldName = "
*applicant.name*", message = "You must enter a value for name.")}
)
public class SaveApplication extends ActionSupport  {
...
    //add applicant bean to this action
    public void setApplicant(Applicant a) {
        applicant = a;
    }

    public Applicant getApplicant () {
        return applicant;
    }

}

*and the applicant bean:*
public class Applicant {
.....
    private String *name*;
.....

    public String getName() {
        return name;
    }

    public void setName (String s) {
        name = s;
    }
....
}

Please point me in the right direction. Any suggested reading would
definitely be appreciated.

Thanks

doug

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message