Solved

Struts validator question

Posted on 2006-10-27
2
318 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now