struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Néstor Boscán <nesto...@gmail.com>
Subject Re: S2: Not generating javascript validation
Date Sun, 22 Sep 2013 01:20:05 GMT
Hi

    <s:form name="login" method="post" action="login!login.action"
validate="true">
        <s:hidden name="request_id" value="%{#parameters.request_id}"/>
        <s:textfield name="username" key="username" size="25"
cssClass="mystyle1"/>
        <s:password name="password" key="password" size="25"
cssClass="mystyle1"/>
    </s:form>

It looks like this version of Struts 2 doesn't like the Dynamic Method
Invocation in login!login.action. If I don't use DMI it works. Older
versions of the framework worked with DMI.

Regards,

Néstor


On Sat, Sep 21, 2013 at 5:24 PM, <jlmagc@gmail.com> wrote:

> Can you provide the jsp snipset for the form?
> Sent via BlackBerry from T-Mobile
>
> -----Original Message-----
> From: Néstor Boscán <nestorjb@gmail.com>
> Date: Sat, 21 Sep 2013 16:15:23
> To: Struts Users Mailing List<user@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
> Subject: S2: Not generating javascript validation
>
> Hi
>
> I'm using the latest 2.3.15.2 version of struts 2 on weblogic 10.3.6. This
> are my files:
>
> LoginAction-validation.xml:
>
> <!DOCTYPE validators PUBLIC
>         "-//Apache Struts//XWork Validator 1.0.3//EN"
>         "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
> <validators>
>   <field name="username">
>     <field-validator type="required">
>       <message>El usuario es requerido</message>
>     </field-validator>
>   </field>
>   <field name="password">
>     <field-validator type="required">
>       <message>La contrasenia es requerida</message>
>     </field-validator>
>   </field>
> </validators>
>
> validators.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE validators PUBLIC
>         "-//Apache Struts//XWork Validator Definition 1.0//EN"
>         "http://struts.apache.org/dtds/xwork-validator-definition-1.0.dtd
> ">
> <validators>
>     <validator name="required"
>
> class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/>
>     <validator name="requiredstring"
>
> class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/>
>     <validator name="int"
>
> class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/>
>     <validator name="long"
>
> class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/>
>     <validator name="short"
>
> class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/>
>     <validator name="double"
>
> class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/>
>     <validator name="date"
>
> class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/>
>     <validator name="expression"
> class="com.opensymphony.xwork2.validator.validators.ExpressionValidator"/>
>     <validator name="fieldexpression"
>
> class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/>
>     <validator name="email"
> class="com.opensymphony.xwork2.validator.validators.EmailValidator"/>
>     <validator name="url"
> class="com.opensymphony.xwork2.validator.validators.URLValidator"/>
>     <validator name="visitor"
>
> class="com.opensymphony.xwork2.validator.validators.VisitorFieldValidator"/>
>     <validator name="conversion"
>
> class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/>
>     <validator name="stringlength"
>
> class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/>
>     <validator name="regex"
> class="com.opensymphony.xwork2.validator.validators.RegexFieldValidator"/>
>     <validator name="conditionalvisitor"
>
> class="com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator"/>
> </validators>
>
> The form tag has validate="true".
>
> When I generate the login page I get:
>
> <script type="text/javascript">
>     function validateForm_login() {
>         var getFieldValue = function(field) {
>             var type = field.type ? field.type : field[0].type;
>             if (type == 'select-one' || type == 'select-multiple') {
>                 return (field.selectedIndex == -1 ? "" :
> field.options[field.selectedIndex].value);
>             } else if (type == 'checkbox' || type == 'radio') {
>                 if (!field.length) {
>                     field = [field];
>                 }
>                 for (var i = 0; i < field.length; i++) {
>                     if (field[i].checked) {
>                         return field[i].value;
>                     }
>                 }
>                 return "";
>             }
>             return field.value;
>         }
>         form = document.getElementById("login");
>         clearErrorMessages(form);
>         clearErrorLabels(form);
>
>         var errors = false;
>         var continueValidation = true;
>
>         return !errors;
>     }
> </script>
>
> It's like the validation framework is not detecting the fields.
>
> Regards,
>
> Nestor Boscan
>
>

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