我正在研究检票口。我在表格中通过Listview生成的每一行都使用了一个复选框。我想使用复选框选择删除特定行。
可以使用显示表数据的Listview生成此表。请至少告诉我如何通过选择多个复选框来获取行ID。请告诉我怎么能这样做?
package com.cerebrum.pages;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.CheckGroup;
import org.apache.wicket.markup.html.form.CheckGroupSelector;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.PropertyModel;
import com.cerebrum.common.Home;
import com.cerebrum.hibernate.Users;
import com.cerebrum.hibernate.UsersHome;
import com.cerebrum.pojo.AdminViewUserModel;
public class AdminViewUser extends Home
{
UsersHome usersHome=new UsersHome();
List<AdminViewUserModel> listCal = new ArrayList<AdminViewUserModel>();
AdminViewUserModel adminViewUserModel=new AdminViewUserModel();
public AdminViewUser()
{
super();
add(new AdminViewUserForm());
}
public class AdminViewUserForm extends Form
{
public AdminViewUserForm()
{
super("AdminViewUserForm");
setModel(new CompoundPropertyModel(adminViewUserModel));
List<Users> lstUsers=usersHome.getUserInfo();
for(Users users:lstUsers)
{
listCal.add(new AdminViewUserModel(users.getFirstName(),
users.getMiddleName(),users.getLastName(),users.getDateOfBirth(),
users.getEmailId(),users.getMobileNo(),users.getUserName(),
users.getPassword()));
}
ListView listViewCal = new ListView("listViewCal", listCal)
{
protected void populateItem(ListItem item)
{
AdminViewUserModel model=(AdminViewUserModel)item.getDefaultModelObject();
CheckBox chkBoxSelect=new CheckBox("chkBoxSelect",new PropertyModel(model, "chkBoxSelect"));
item.add(chkBoxSelect);
TextField txtFname=new TextField("txtFname",new PropertyModel(model, "txtFname"));
item.add(txtFname);
TextField txtMname=new TextField("txtMname",new PropertyModel(model, "txtMname"));
item.add(txtMname);
TextField txtLname=new TextField("txtLname",new PropertyModel(model, "txtLname"));
item.add(txtLname);
TextField txtDOB=new TextField("txtDOB",new PropertyModel(model, "txtDOB"));
item.add(txtDOB);
TextField txtEmail=new TextField("txtEmail",new PropertyModel(model, "txtEmail"));
item.add(txtEmail);
TextField txtMobileNo=new TextField("txtMobileNo",new PropertyModel(model, "txtMobileNo"));
item.add(txtMobileNo);
TextField txtUserName=new TextField("txtUserName",new PropertyModel(model, "txtUserName"));
item.add(txtUserName);
TextField txtPassword=new TextField("txtPassword",new PropertyModel(model, "txtPassword"));
item.add(txtPassword);
}
};
listViewCal.setOutputMarkupId(true);
add(listViewCal);
AjaxButton btnUpdate=new AjaxButton("btnUpdate")
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> arg1)
{
}
};
btnUpdate.setOutputMarkupId(true);
add(btnUpdate);
AjaxButton btnDelete=new AjaxButton("btnDelete")
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> arg1)
{
}
};
add(btnDelete);
}
}
}