File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "double validation, help" Watch "double validation, help" New topic

double validation, help

danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185

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-value>(((claimInfo.promotionInfo.type != "SP") and (claimInfo.promotionInfo.type != "MP"))
or ((*this* != null) and (*this* > 0)))

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:
    subject: double validation, help
    It's not a secret anymore!