Announcement Announcement Module
Collapse
No announcement yet.
Checkboxes default values from a Set Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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 ?

    Comment

    Working...
    X