Solved

Struts validator question

Posted on 2006-10-27
2
314 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
Comment Utility
Is   validate="true" in struts config <action > tags ?
0
 
LVL 10

Accepted Solution

by:
jaggernat earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

14 Experts available now in Live!

Get 1:1 Help Now