struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Néstor Boscán <nestor.bos...@tcs.com.ve>
Subject Re: S2: NullPointerException at AnnotationActionValidatorManager.lo adFile
Date Sat, 21 Sep 2013 16:47:55 GMT
With the DTD solved the NullPointerException problem but I'm still not
getting the javascript code that validates per field. My files are:

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 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>

Is like he's not detecting the fields


On Fri, Sep 20, 2013 at 9:49 PM, JOSE L MARTINEZ-AVIAL <jlmagc@gmail.com>wrote:

> It could be related to the DTD:
>
>
> http://stackoverflow.com/questions/17144563/struts2-annotation-valiation-nullpointer-exception
>
>
> 2013/9/20 JOSE L MARTINEZ-AVIAL <jlmagc@gmail.com>
>
> > I assume you have an xml file to set the definitions, right? could you
> > share it?
> >
> >
> > 2013/9/20 Néstor Boscán <nestorjb@gmail.com>
> >
> >> I've been trying to make Struts 2 JavaScript Validation work on WebLogic
> >> 10.3.6. I first used 2.3.8 version and then the latest 2.3.15.2
> version. I
> >> still get the same error:
> >>
> >> java.lang.NullPointerException
> >>         at
> >> com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.lo
> >> adFile(AnnotationActionValidatorManager.java:391)
> >>         at
> >> com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.bu
> >> ildAliasValidatorConfigs(AnnotationActionValidatorManager.java:271)
> >>
> >> Any ideas?
> >>
> >
> >
>

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