Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent the default value '0' from being shown in Struts2 textfield tag

I have a form with several textfields. When I populate it with data, there are some integer textfields which is showing '0', which is the default value for integer. I want the textfield to be blank than a zero.

<s:textfield id="txtPhone" name="phone"/>

Please help.

like image 955
Hasif Subair Avatar asked Nov 28 '25 04:11

Hasif Subair


1 Answers

You need to use Integer class and not int for that. int will always be initialized to 0. S2 OGNL and type convertor will take care of type conversion for you.

For Integer default will be null and it will solve your issue.

like image 154
Umesh Awasthi Avatar answered Nov 30 '25 16:11

Umesh Awasthi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!