Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Struts validator question

Posted on 2006-10-27
2
Medium Priority
?
333 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

604 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