I am new t struts2. i built one page, that shows list of employees. I can seach the employes based on his name by applying filter criteria and click on find button. At the same time, i provided check box in the left side for each employee name for delete operation. for all checkboxes, i gave Integer[] attribute name which is declared in Custom Actionclass.deleteaction is working fine. But when i click Find button the action is not getting submitted. Then i changed Integer[] to String[] both functions are working fine. What will be the problem? is it something like, attributes should only be String type.
+2
A:
The cause of your problem is that the Struts2 checkbox sets a boolean property on the action class:
When you defined the checkboxes as an Integers, the framework couldn't covert the boolean to an Integer. However it was able to convert the boolean to Strings. If you check the results in your action class, you should see the String[] populated with "true" and "false".
In general Struts2 is pretty good at converting submitted form data to whatever object type you want. Check out the docs on type conversion for more info.
Pat
2010-07-16 11:59:39
Ok.Thanks for ur valuable reply.But i am setting Checkbox value as int type.Then what could be the problem?
Jothi
2010-07-17 12:11:46
Why are you setting it as type int? You need to either set the Checkbox as type boolean or type String. Struts2 can't convert a submitted checkbox to a int value.
Pat
2010-07-18 22:54:09