• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validator Form Bean instance variable types

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am using validatorActionForm. My form bean has getters/setters for the following:

// Liquidation Filter variables
private String liquidationType;
private int liquidationAmount;
private float liquidationPercent;
private byte equityDenomination;
private short fixedIncomeDenomination;
private char includeCashInLiquidationAmount = 'N';
private char vsp = 'N';
private char washRule = 'N';

I could not get the validation of liquidation amount to work with integer until I changed the data type type to String.

validation.xml
<form name="/liquidate">
<field property="liquidationAmount" depends="integer">
<arg0 key="error.liquidationAmount"/>
</field>
</form>

form bean:
private String liquidationAmount;

Do all my form bean properties have to be string to use the validator framework? Why?

Thanks,
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the problem is that if you use int and submit a bad value, Struts fails to turn it into an int before validation ever occurs.

It is as if you are assuming it is valid before checking if it is valid.
 
I'm doing laundry! Look how clean this tiny ad is:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic