Solved

Struts validator question

Posted on 2006-10-27
2
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

The conference as a whole was very interesting, although if one has to make a choice between this one and some others, you may want to check out the others.  This conference is aimed mainly at government agencies.  So it addresses the various compli…
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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