Results 1 to 2 of 2

Thread: Checkboxes default values from a Set

  1. #1
    Join Date
    Mar 2011
    Location
    Belgium
    Posts
    13

    Default Checkboxes default values from a Set

    Dear,

    I'm facing a little problem.
    I have a bean "Report" which has a Set<LinkReportProduct> called "linkReportProducts" .
    Here is the structure of a LinkReportProduct :
    Code:
    public class LinkReportProduct implements java.io.Serializable {
    	private long lrepprodId;
    	private Report report;
    	private Product product;
    ..}
    The referenceData method of my Controller initialize a list of products.
    Part of my Jsp :
    Code:
    Produits concernés :
    		<form:checkboxes items="${prodList}" path="linkReportProducts" itemLabel="prodName" itemValue="prodId"/>
    My checkboxes are displayed correctly, when i push submit, the Set<LinkReportProduct> linkReportProducts is correctly populated using this method in the initBinder :
    Code:
    binder.registerCustomEditor(Set.class, "linkReportProducts",new CustomCollectionEditor(Set.class){
    			@Override
    			protected Object convertElement(Object element){
    				long id=NumberUtils.parseNumber((String)element,Long.class).longValue();
    				prodManager.loadClass(Product.class);
    				Product prod = prodManager.getObjById(id);
                                                       // Not really needed to load products from the DB, but whatever.. Not the problem I guess :)
    				LinkReportProduct lreprod = new LinkReportProduct();
    				lreprod.setProduct(prod);
    				lreprod.setReport(rap);
    				return lreprod;
    			}
    		});
    Everything looks fine, excepted that when i come back to my jsp, the previously choosen values are not selected.
    Neither the equals method of Product nor the equals method of LinkReportProduct are called.
    It works for every other fields (input text, select, .., but not multiple values)

    Could you tell me what am I doing wrong ?
    Thanks.

  2. #2
    Join Date
    Mar 2011
    Location
    Belgium
    Posts
    13

    Default

    Now that i overrided the equals and hashcode method of my bean, it works when I select on item.. when i come back to the page, this item is selected.

    However, if i choose more than one item, it doesn't work, none are selected when i come back there..

    Still no help possible ?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •