Solved

Struts validator question

Posted on 2006-10-27
2
327 Views
Last Modified: 2010-08-05
I'm trying to debug a form that uses a struts validator.  Its not working, I can't tell why.  
I'm not even sure that the validator is firing.  

Is therea printout, echo command, or something I can add to my validator.xml file that will tell me that I'm actually calling the validator?

    <form name="customersForm">
      <field property="customersSO.companyName" depends="ifparentpresent,">
        <arg0 key="customers.companyName.displayName"/>
      </field>
      <field property="customerDetailsCustomerFO.companyName" depends="ifparentpresent,required,maxlength,">
        <arg0 key="customerDetails.companyName.displayName"/>
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
        <var>
          <var-name>maxlength</var-name>
          <var-value>50</var-value>
        </var>
      </field>
      <field property="customerDetailsCustomerFO.products" depends="ifparentpresent,maxlength,">
        <arg0 key="customerDetails.products.displayName"/>
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
        <var>
          <var-name>maxlength</var-name>
          <var-value>500</var-value>
        </var>
      </field>
      <field property="customerDetailsCustomerFO.notes" depends="ifparentpresent,maxlength,">
        <arg0 key="customerDetails.notes.displayName"/>
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
        <var>
          <var-name>maxlength</var-name>
          <var-value>500</var-value>
        </var>
      </field>
      <field property="customerDetailsCustomerFO.contract" depends="ifparentpresent,maxlength,">
        <arg0 key="customerDetails.contract.displayName"/>
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
        <var>
          <var-name>maxlength</var-name>
          <var-value>1000</var-value>
        </var>
      </field>
      <field property="customerDetailsCustomerFO.version" depends="ifparentpresent,long">
        <arg0 key="version.displayName"/>
      </field>
      <field property="scheduledAssessmentsSO.dateFrom" depends="ifparentpresent,date,">
        <arg0 key="scheduledAssessments.date.displayName"/>
        <var>
          <var-name>datePatternStrict</var-name>
          <var-value>${defaultDatePatternStrict}</var-value>
        </var>
      </field>
      <field property="scheduledAssessmentsSO.dateTo" depends="ifparentpresent,date,">
        <arg0 key="scheduledAssessments.date.displayName"/>
        <var>
          <var-name>datePatternStrict</var-name>
          <var-value>${defaultDatePatternStrict}</var-value>
        </var>
      </field>
      <field property="accountDetailsAccountFO.balance" depends="ifparentpresent,float,">
        <arg0 key="accountDetails.balance.displayName"/>
      </field>
      <field property="accountDetailsAccountFO.lastBillingDate" depends="ifparentpresent,date,">
        <arg0 key="accountDetails.lastBillingDate.displayName"/>
        <var>
          <var-name>datePatternStrict</var-name>
          <var-value>${defaultDatePatternStrict}</var-value>
        </var>
      </field>
      <field property="accountDetailsAccountFO.version" depends="ifparentpresent,long">
        <arg0 key="version.displayName"/>
      </field>
      <field property="personnelSO.last" depends="ifparentpresent,">
        <arg0 key="personnel.last.displayName"/>
      </field>
      <field property="personnelSO.first" depends="ifparentpresent,">
        <arg0 key="personnel.first.displayName"/>
      </field>
    </form>
0
Comment
Question by:tmonteit
  • 2
2 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 17822494
Is   validate="true" in struts config <action > tags ?
0
 
LVL 10

Accepted Solution

by:
jaggernat earned 500 total points
ID: 17822556
may be validate.xml is getting called but error messages are not getting displayed. make sure ApplicationResources.properties file contains
errors.required = {0} field is required.<br />
errors.maxlength = {0} cannot be greater than {1}characters.<br />
errors.minlength = {0} cannot be less than {1} characters.<br />
...

Also i see you have a custom rule "fparentpresent". Have you added this rule in validator-rules.xml file  like this
<validator name="fparentpresent" classname="package.YourcustomValidatorClass" method="methodname in YourcustomValidatorClass" methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       javax.servlet.http.HttpServletRequest" msg="errorMessage.in.ApplicationResources.propertiesfile"></validator>
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
session bean client machine 9 63
EJB MDB example 4 87
How to find missing packages when using Netbeans IDE 8.1 ? 19 59
Why my table column Id is not passed to java object? 4 44
If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question