Hello,

I'm trying to display a radio list that allows me to get the selected object
when the form is submitted.
Each object is represented by a radio button and a label in this list.

The problem is that I get this exception:
*Could not find a coercion from type java.lang.String to type
com.company.be.BoBPetrol.model.database.BillableItemDTOId.*

I've found a 
http://tapestry.1045711.n5.nabble.com/Loop-RadioGroup-and-Coercion-td2422576.html
piece of solution  (with the encoder, where I get the right object!) but it
doesn't work neither.

Here is the code of the .tml file :

                    <t:radiogroup value="selectedItem" encoder="itemEncoder">  
                    <ul class="billableItemsList">
                             <t:loop source="billableItems" value="itemValue">  
            
                              <li>
                                       <t:radio t:id="radio" value="itemValue"
encoder="itemEncoder"/>  
                                       <t:label 
for="radio">${itemValue.commText} -
${itemValue.chargeindicator} - ${itemValue.cost}&#8364;</t:label>  
                              </li>
                    </t:loop>  
                    </ul>
                    </t:radiogroup>  

And here the .java file:

        @Persist
        @Property
        private List<BillableItemDTOId> billableItems;
        
        ...

        @Property
        private BillableItemDTOId itemValue;
        
        @Property
        @Persist
        private BillableItemDTOId selectedItem;
        
        @Property
        private ValueEncoder<BillableItemDTOId> itemEncoder = new
ValueEncoder<BillableItemDTOId>() {
                public String toClient(BillableItemDTOId item) {
                        System.out.println("toClient");
                        return (String.valueOf(billableItems.indexOf(item)));
                }

                public BillableItemDTOId toValue(String pId) {
                        System.out.println("toValue");

                        BillableItemDTOId billableItemDTOId =
billableItems.get(Integer.parseInt(pId));
                        System.out.println(billableItemDTOId.getCommText());
                        return billableItemDTOId;
                }
        };

Could someone help me ?

Regards,

Fab

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/RadioGroup-loop-coercion-problem-tp5130975p5130975.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to