Fala Galera
Estou com um problema quando uso o Struts Validator soh que do lado servidor. Quando carrego meu jsp (que contem o html:errors/) a mensagem de erro ja fica esposta no topo da pagina sem eu ter submetido meu form. Alguém sabe me dizer aonde pode ser o problema? ja que era para exibir o erro apos a sumissão. Outra coisa, esta funcionando perfeitamente quando faço o teste do lado client com o codigo que esta comentado na pagina JSP.
segue abaixo meu validation.xml, struts-config.xml e minha pagina jsp
struts-config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<!-- ================================================ Form Bean Definitions -->
<form-beans>
<form-bean name="SecretaryForm" type="br.com.gestorpsi.controller.forms.SecretaryForm"/>
</form-beans>
<!-- ========================================= Global Exception Definitions -->
<global-exceptions>
<!-- sample exception handler
<exception
key="expired.password"
type="app.ExpiredPasswordException"
path="/changePassword.jsp"/>
end sample -->
</global-exceptions>
<!-- =========================================== Global Forward Definitions -->
<global-forwards>
<!--forward
name="mainPage"
path="/Main.do"/-->
</global-forwards>
<!-- =========================================== Action Mapping Definitions -->
<action-mappings>
<action
path="/Main"
forward="mainPage.page"/>
<action path="/secretary*"
scope="request"
name="SecretaryForm"
input="initSecretary.page"
validate = "true"
type="br.com.gestorpsi.controller.actions.secretary.{1}Action">
<forward name="listing" path="/secretaryNew.do"/>
<forward name="init" path="initSecretary.page"/>
</action>
</action-mappings>
<!-- ======================================== Message Resources Definitions -->
<message-resources parameter="MessageResources" null="false"/>
<!-- =============================================== Plug Ins Configuration -->
<!-- ======================================================= Tiles plugin -->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/config/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
<!-- =================================================== Validator plugin -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/org/apache/struts/validator/validator-rules.xml,
/WEB-INF/config/validation.xml"/>
<set-property property="stopOnFirstError"
value="true" />
</plug-in>
</struts-config>
validation.xml
formset>
<form name="SecretaryForm">
<field property="name" depends="required">
<arg position="0" key="error.field.name"/>
</field>
<field property="email" depends="required,email">
<arg position="0" key="error.field.email"/>
</field>
</form>
</formset>
pagina JSP com validação
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles" %>
<%@ taglib prefix="gp" tagdir="/WEB-INF/tags" %>
<c:if test="${! empty secretaries}">
<div>
<br>
<strong><bean:message key="secretary.list.existingsecretaries"/></strong>
<ul>
<c:forEach var="secretary" items="${secretaries}">
<li><c:out value="${secretary.name}"/> - <c:out value="${secretary.nickname}"/></li>
</c:forEach>
</ul>
</div>
</c:if>
<br>
<hr>
<html:errors/>
<html:form action="/secretarySave.do">
<!-- For Client-Side onsubmit="return validateSecretaryForm(this)" -->
<bean:message key="secretary.form.secretaryname"/>: <html:text property="name"></html:text>
<bean:message key="secretary.form.secretarynickname"/>: <html:text property="nickname"></html:text>
<bean:message key="secretary.form.secretaryemail"/>: <html:text property="email"></html:text>
<br>
<gp:address form="address"/>
<br>
<gp:phone form="phone1"/>
<br>,
<gp:phone form="phone2"/>
<br>
<gp:phone form="phone3"/>
<br>
<gp:gender property="gender"/>
<gp:maritalstatus property="maritalStatus"/>
<br>
<input type="submit" value="<bean:message key="button.save"/>">
</html:form>
<!-- For Client-Side html:javascript formName="SecretaryForm"-->
Abraços
Danilo