Win a copy of Terraform in Action this week in the Cloud forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Using checkBoxlist in struts2

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic