This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes struts2: setting string value to int field of a bean does not throw any exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2: setting string value to int field of a bean does not throw any exception" Watch "struts2: setting string value to int field of a bean does not throw any exception" New topic
Author

struts2: setting string value to int field of a bean does not throw any exception

vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 80
I had a jsp which has a field user age.
age: <s:textfield name="user.age" id="user.age" ></s:textfield>

in action class, i have i create user bean getter and setter.

it works fine if i enter age as integer but if i enter string for age then it does not throw any exception.

where is the problem?
Tomas Bilek
Greenhorn

Joined: Nov 17, 2011
Posts: 5
If I understand correctly the problem, use validation.

http://struts.apache.org/2.x/docs/validation.html

Tomas Bilek
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts2: setting string value to int field of a bean does not throw any exception