日期:2014-05-17  浏览次数:20660 次

struts1中html:multibox的使用
html:multibox 可以实现自动选中。用于替代checkbox.

  <html:multibox property="specialChooes" value="aa" />aa
  <html:multibox property="specialChooes" value="bb" />bb
  <html:multibox property="specialChooes" value="cc" />cc


public class ProductDigicamForm extends ActionForm {

private String[]  specialChooes;//
public String[] getSpecialChooes() {
return specialChooes;
}
public void setSpecialChooes(String[] specialChooes) {
this.specialChooes = specialChooes;
}
}

public ActionForward  showDigicam(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IProductService service = (IProductService) this.getBean(Constants.PRODUCT_BEAN);
ProductDigicam digicam=new ProductDigicam();
ProductDigicamForm digicamForm=(ProductDigicamForm)form;
String prodId=request.getParameter("prodId");
try {
digicam = (ProductDigicam) service.getDigicamById(new Integer(prodId));
digicamForm.setSpecialChooes(digicam.getSpecialChooes().split("-"));
} catch (Exception e) {
e.printStackTrace();
}
return mapping.findForward("digicam");
}