Ol� Vinicius,
Poste o seu mapeamento de suas action no struts-config, e o mapeamento
dos seus form, para que eu possa analizar? Verifique o log gerado pelo
seu container web(Tomcat, JBoss etc), em geral eles listam a maioria
dos problemas da sua aplica��o.
Gabriel F Campolina
Analista desenvolvedor Java
Stefanini IT Solutions - BH
On Thu, 30 Sep 2004 14:33:51 -0300, Vinicius Carvalho
<[EMAIL PROTECTED]> wrote:
> Hi there! I've been using Struts for quite sometime, but haven't used
> the validator yet.
> So I followed the receipt provided by Struts in Action, but got no
> success at all.
>
> Here's what I've done
>
> Struts-config is configured for the right plugin
> My ActionForm extends ValidatorForm and has no validate() method
>
> Validator-rules.xml:
>
> <validator name="required"
> classname="org.apache.struts.validator.FieldChecks"
> method="validateRequired"
> methodParams="java.lang.Object,
> org.apache.commons.validator.ValidatorAction,
> org.apache.commons.validator.Field,
> org.apache.struts.action.ActionMessages,
> javax.servlet.http.HttpServletRequest"
> msg="validator.errors.required">
> <javascript>
> <![CDATA[
> function validateRequired(form) {
> var isValid = true;
> var focusField = null;
> var i = 0;
> var fields = new Array();
> oRequired = new required();
> for (x in oRequired) {
> var field = form[oRequired[x][0]];
>
> if (field.type == 'text' ||
> field.type == 'textarea' ||
> field.type == 'file' ||
> field.type == 'select-one' ||
> field.type == 'radio' ||
> field.type == 'password') {
>
> var value = '';
>
> // get field's value
> if (field.type == "select-one") {
> var si = field.selectedIndex;
> if (si >= 0) {
> value = field.options[si].value;
> }
> } else {
> value = field.value;
> }
>
> if (trim(value).length == 0) { {
> if (i == 0) {
> focusField = field;
> }
> fields[i++] = oRequired[x][1];
> isValid = false;
> }
> }
> }
>
> if (fields.length > 0) {
> focusField.focus();
> alert(fields.join('\n'));
> }
>
> return isValid;
> }
>
> // Trim whitespace from left and right sides of s.
> function trim(s) {
> return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
> }
>
> ]]>
> </javascript>
> </validator>
>
> validation.xml:
>
> <form name="userForm">
> <field property="nome" depends="required">
> <msg name="obrigatorio" key="validator.errors.required"/>
> <arg0 key="prompt.nome"/>
> </field> </form>
> ApplicationResources.properties
>
> validator.errors.required= O campo {0} � obrigat�rio
> prompt.nome=nome
>
> And my jsp file looks like this:
>
> <html:form action="/atualizaDadosUsuarioAction" name="userForm"
> type="br.com.auge.errors.action.form.UserForm" onsubmit="return
> validateRequired(this)">
> Nome <html:text property="nome" name="userForm"></html:text><html:errors
> /><br>
> </html:form>
> <html:javascript formName="userForm"/>
>
> Well, what is happening is that after I submit with no values at all,
> nothing happens, it forwards to the
> correct path. And also, the javascript generated isn't inside a
> <script></script> block. So it's printed
> on the page footer.
>
> Where did I miss?
>
> Thanks
>
> Vinicius
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]