[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • Last Modified:

List in JSP, with Struts

I make a JSP page, with 2 columns: one is a list of checkbox, one is a list of name. And one button DELETE, like this:
[ ]  A
[ ]  B
[ ]  C
[ ]  D
DELETE
I wanna do this: "I will multi-select the checkbox, and click button DELETE. It will delete the Name that i chosen". So, the question is:

I use the Struts (with ActionForm, Action...) with TOMCAT. If i write the ActionForm like this:
String A
String B
String C
String D
It was ok. But If I wanna write the ActionForm like this:
String checkbox[]
so, how can I map the JSP page with the ActionForm? (map the list of checkbox with list of string). What must i do with the file Struts-config.xml???

If anybody have the source-code, pls submit here and explain for me (if u can)
Thanks alot. I really need to solve this problem. Really
Thanks all.
0
nhagiaubungbu
Asked:
nhagiaubungbu
  • 3
  • 2
1 Solution
 
nhagiaubungbuAuthor Commented:
Thanks, COBOLdinosaur
0
 
suprapto45Commented:
Hi nhagiaubungbu,

In your form, you can have an array to store what are the values in your checkbox.

I will send you some sample :).

Regards
Dave
0
 
suprapto45Commented:
Hi nhagiaubungbu,

First, you should have your checkboxes a kind of
<input type="checkbox" name="submitted" value="test1">&nbsp; Test1
<input type="checkbox" name="submitted" value="test2">&nbsp; Test2

Then in your Struts form, you should have
private String[] submitted;

as well as the getter and setter.

Finally, in your Struts action, you should have
String[] submitted = null;
submitted = yourForm.getSubmitted();

I hope that helps.

Regards
Dave
0
 
nhagiaubungbuAuthor Commented:
hi suprapto45

I will try your code later. But i think it will work :)
Thanks alot.

Regards
BungBu
0
 
suprapto45Commented:
Hi BungBu,

Glad I could help. Just let me know if you still have problem.

Regards
Dave
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now