File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using checkBoxlist in struts2

 
antonio rega
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have a question about how to use checkBoxlist in struts2:
it's possible populate a checkBoxlist reading value and checking box from database table.
Es: i have a table named Abilitazioni with this value :
idProfilo idFunzione Abilitato
1 1 YES
1 2 YES
1 3 NO
I'dlike to show the first and the second value in the checkboxlist checked, but I'don't know how to.

Thanks
Antonio
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the action property (loaded from the DB) as the "name" attribute argument (or "key", depending on how you're using the tag).
 
antonio rega
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Use the action property (loaded from the DB) as the "name" attribute argument (or "key", depending on how you're using the tag).


thanks for replay
I'm new with struts2.....
my tag is like this : <s:checkboxlist name="Abilitazioni" label="Abilitazioni" list="FunzioniAbil" listKey="id" listValue="description"/>
where listKey="id" id is value true o false but the checkboxlist item aren't checked....
What's wrong?

antonio

 
Lucas Grijander
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to convert your Abilitazioni value from YES to true and from NO to false
 
antonio rega
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucas Grijander wrote:you have to convert your Abilitazioni value from YES to true and from NO to false


I've already done but it doesn't work anyway....
where can I find an example to understand how works ?

thanks
 
Anbarasu Aladiyan
Ranch Hand
Posts: 182
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi antonio rega,

I think in this scenario, we can use checkbox tags.
like



In the above code name of the field will be same for all the checkboxes/rows, fieldValue will be the id(UNIQUE) . And in action class you can use checkbox field as array type.

that is like


and its setter and getter methods.

In action checkboxField1 array will have the fieldValues of ONLY selected check boxes.
--
A.A.Anbarasu
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic