Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

[S2] Pre-populating Checkboxes

David Ogasawara

2008-06-30

Replies:

Author LoginPost Reply
Hello,

I'm new to Struts 2 and I was wondering how to pre-populate checkboxes
with values from a database (or even hard-coded values). I am iterating
through an arraylist of hashmaps (description, type_cd) to create the
checkboxes in the form. I then create a string array with the values
from a database to pre-populate, but it's not working.

* When the checkboxes are checked and the form is submitted, I am able
to capture the values (String array) properly.


JSP:
<s:iterator value="all_type_codes">
 <s:checkbox name="type_cd" fieldValue="%{type_cd}"/>
 <s:property value="description"/>
   <br>
</s:iterator>



Action Page:
public String[] getType_cd() {
  return type_cd;
}
public void setType_cd(String[] type_cd) {
  this.type_cd = type_cd;
}

// this is a test
type_cd = new String[3];
type_cd[0] = "EQ";
type_cd[1] = "SF";
type_cd[2] = "SS";



Any help would be greatly appreciated!

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.