Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

[S2] Problem showing errors message with xxx-validation.xml

Juanjo Cuadrado

2008-10-14

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,

I'm having problems to show a error message with validation xml file.

This is the code in my struts.xml

    <action name="addNuevaSolicitud"
          class="es.mec.adesi.ctl.actions.solicitudes.TestAction">
       <result>/pages/opciones.jsp</result>
    </action>

The action class is this:

public class TestAction {

  private String dniParticipante;

  public String execute() {
    return Action.SUCCESS;
  }

  public String getDniParticipante() {
    return dniParticipante;
  }

  public void setDniParticipante(String dniParticipante) {
    this.dniParticipante = dniParticipante;
  }
}

And the validation file (TestAction-validation.xml) is:
<validators>
  <field name="dniParticipante">
    <field-validator type="required">
       <message>DNI is required</message>
    </field-validator>
  </field>
</validators>

In the jsp I have tried show the error message:
            <div class="error"><s:actionerror /> <s:fielderror />
<s:actionmessage /></div>

But no show any message. When I add a method "validate" in the action class,
it works and, I can see the message in the jsp.

Any idea?

Thanks.
©2008 gg3721.com - Jax Systems, LLC, U.S.A.