This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes double validation, help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "double validation, help" Watch "double validation, help" New topic
Author

double validation, help

danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
Hi,

I have to double field to validate. This field only exists when the promotion type is 'SP' or 'MP'. So I cannot use "double" function to validate it.

However, *this* >0 seems not to work for double. Any comment is welcome.

<field property="claimInfo.payoutInfo.amount" depends="validwhen">
<arg0 key="ClaimInfo.PayoutInfo.Amount"/>
<var>
<var-name>test</var-name>
<var-value>(((claimInfo.promotionInfo.type != "SP") and (claimInfo.promotionInfo.type != "MP"))
or ((*this* != null) and (*this* > 0)))
</var-value>
</var>
</field>


Dan
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I don't believe "validwhen" works for anything but simple existence tests.

In order to do what you want, you can either:
  • Write your own custom validation rule or
  • use te validate() method of your action form for just this one rule while still using the validation framework for the other rules


  • Merrill
    Consultant, Sima Solutions
    danny liu
    Ranch Hand

    Joined: Jan 22, 2004
    Posts: 185
    after some investigations, I found out this is a bug of "validwhen". A custom validation needs to be attached.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: double validation, help
     
    Similar Threads
    validator requiredIf checking two conds
    Validate multiple fields base on a requiredif
    struts validation
    Validation only greaterThan
    doubt in using validwhen