my code is
request.setAttribute( "test", (new userarray()).getUsers() );
my fieldValue="%{test.checked} is not working properly as when i click on submit the checkboxes which i select ....their values do not get set...and in the user array
public class userarray extends ActionSupport{
private ArrayList users=new ArrayList();
public userarray()
{
users.add(new User("1", "1", 1));
users.add(new User("2", "2", 2));
users.add(new User("3", "3", 3));
users.add(new User("4", "4", 4));
}
public ArrayList<User> getUsers() {
return users;
}
public void setUsers(ArrayList<User> users) {
this.users = users;
}
public String execute() throws Exception {
System.out.println("in datagrid");
return SUCCESS;
}
public String add() throws Exception
{
//System.out.println("in AjaxServerSide ");
System.out.println("in submit action");
for(int i=0;i<users.size();i++)
{
if(users.get(i).getChecked())
{
System.out.println("id chescked..: "+users.get(i).getId());
}
}
return SUCCESS;
}
public class User {
private String name="";
private String password="";
private int id=0;
private boolean checked;
public boolean getChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public User(String name,String pass,int id)
{
this.name = name;
this.password = pass;
this.id=id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}