• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Struts2 checkbox value

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
i am using struts2 and jsp for UI.
I have 3 checkboxes on one of my page,and want to set the bean varible coresponding to these checkboxes on page submit
what i am doin is

<s:checkbox name="abcVO.field1" fieldValue="abcVO.field1" theme="simple" value="abcVO.field1" />

where abcVO is a action classes'(bean's )member which is an value object (a object class )
containing different fields like field1 ,field2.... this field is a character field and values it can take are '1' and '0'
now the problem is i want to set value to 1 if the checkbox is checked else to 0
but it its not getting set in my bean class
,null is what i am getting
my question is what value is set (true/1/or something else) on checking of checkbox element
how to achieve what i am supposed to?

Thanks In advance
-Rohant
 
rohant paralikar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could send the value as 1 when the checkbox is selected by using the fieldValue attribute as fieldValue="1" but one problem still remains that is, when the checkbox is not checked then the value that gets set in bean/action class is null.Can I set it to 0, if not checked, just like fieldValue="1", when it is checked?
If anyone have an idea, please respond to the query

Thanks
-Rohant
[ June 21, 2008: Message edited by: rohant paralikar ]
    Bookmark Topic Watch Topic
  • New Topic