Thanks for you fast answer Christophe !

Here is the new code for my radioGroup :

<t:radiogroup t:id="suggestionRG" value="selectedSuggestion"
encoder="suggestionEncoder">
   <t:loop source="suggestions" value="suggestionLoopValue"
encoder="suggestionEncoder">
        <t:radio t:id="radio" value="suggestionLoopValue"/>  
        <t:label for="radio">${suggestionLoopValue.label}</t:label>  
   </t:loop>
</t:radiogroup>


It works!
Many thanks.



cordenier christophe wrote:
> 
> Oups, it's the radiogroup that need it :)
> 
> 2009/12/28 cordenier christophe <christophe.corden...@gmail.com>
> 
>> Hi
>>
>> I think you have to specify the encoder on the form element too.
>>
>> 2009/12/28 antb59 <ant...@gmail.com>
>>
>>
>>> Hello,
>>>
>>> I'm trying to make a tapestry component that looks like a poll.
>>> This component will contain a question, a list of suggestions, and a
>>> button
>>> to vote.
>>> I didn't want to use Ajax at first, and the click on the vote button
>>> will
>>> reload the whole page for example.
>>>
>>> The question and the list of suggestions were load from my database, and
>>> I
>>> have no problem to display them correctly on my form.
>>> If no radio button is selected, I can click on the vote button, it
>>> works.
>>> The problem occurs when I'm trying to submit the form and when a radio
>>> button is selected.
>>>
>>> Here is the code of my .tml file :
>>>
>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
>>> <t:container xmlns:t="
>>> http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
>>> xmlns:p="tapestry:parameter">
>>>        <t:form t:id="survey_form">
>>>                <h4>${formSurvey.category.label}</h4>
>>>                <h5>${formSurvey.startDate}</h5>
>>>                <p id="surveyLabel">${formSurvey.label}</p>
>>>
>>>                <t:radiogroup t:id="suggestionRG"
>>> value="selectedSuggestion">
>>>                        <t:loop source="suggestions"
>>> value="suggestionLoopValue"
>>> encoder="suggestionEncoder">
>>>                                <t:radio t:id="radio"
>>> value="suggestionLoopValue"/>
>>>                                <t:label
>>> for="radio">${suggestionLoopValue.label}</t:label>
>>>                        </t:loop>
>>>                </t:radiogroup>
>>>
>>>                <t:submit id="surveyVote" t:id="vote"
>>> image="context:images/vote_button.gif" />
>>>        </t:form>
>>> </t:container>
>>>
>>>
>>>
>>> And here is the code of my java file :
>>>
>>> @SuppressWarnings("unused")
>>> public class Survey {
>>>
>>>        @Parameter(required=true)
>>>        private int surveyId;
>>>
>>>        @Property
>>>        @Persist("SESSION")
>>>        private com.titans.surveys.model.Survey formSurvey;
>>>
>>>        @Inject
>>>        private ISurveyManager mSurveyManager;
>>>
>>>        @Persist
>>>        @Property
>>>        private Suggestion selectedSuggestion;
>>>
>>>        @Property
>>>        private Suggestion suggestionLoopValue;
>>>
>>>        @Property
>>>    @Persist
>>>    private List<Suggestion> suggestions;
>>>
>>>        @Property
>>>        private ValueEncoder<Suggestion> suggestionEncoder = new
>>> ValueEncoder<Suggestion> () {
>>>                public String toClient (Suggestion pSuggestion) {
>>>                        return (String.valueOf (suggestions.indexOf
>>> (pSuggestion)));
>>>                }
>>>                public Suggestion toValue (String pId) {
>>>                        return (suggestions.get (Integer.parseInt
>>> (pId)));
>>>                }
>>>    };
>>>
>>>
>>>        public void beginRender() {
>>>                this.formSurvey = mSurveyManager.findById(surveyId);
>>>                if (this.formSurvey == null) {
>>>                        sLogger.error("Unable to retrieve survey with id
>>> =
>>> " + surveyId);
>>>                }
>>>                else {
>>>                        if ((this.suggestions == null)
>>> ||this.suggestions.isEmpty())
>>>                                this.suggestions = new
>>> ArrayList<Suggestion>(formSurvey.getSuggestions());
>>>                }
>>>        }
>>>
>>> }
>>>
>>>
>>> Here is the ComponentEventException throwed :
>>>
>>> Could not find a coercion from type java.lang.String to type
>>> com.titans.surveys.model.Suggestion. Available coercions: Double -->
>>> Float,
>>> Float --> Double, Long --> Boolean, Long --> Byte, Long --> Double, Long
>>> -->
>>> Integer, Long --> Short, Number --> Long, Object --> Object[], Object
>>> -->
>>> String, Object --> java.util.List, Object[] --> java.util.List, String
>>> -->
>>> Boolean, String --> Double, String --> Long, String --> java.io.File,
>>> String
>>> --> java.math.BigDecimal, String --> java.math.BigInteger, String -->
>>> java.text.DateFormat, String --> java.util.regex.Pattern, String -->
>>> org.apache.tapestry5.Renderable, String -->
>>> org.apache.tapestry5.SelectModel, String -->
>>> org.apache.tapestry5.corelib.LoopFormState, String -->
>>> org.apache.tapestry5.corelib.data.BlankOption, String -->
>>> org.apache.tapestry5.corelib.data.GridPagerPosition, String -->
>>> org.apache.tapestry5.corelib.data.InsertPosition, String -->
>>> org.apache.tapestry5.ioc.Resource, String -->
>>> org.apache.tapestry5.ioc.util.TimeInterval, boolean[] -->
>>> java.util.List,
>>> byte[] --> java.util.List, char[] --> java.util.List, double[] -->
>>> java.util.List, float[] --> java.util.List, int[] --> java.util.List,
>>> java.math.BigDecimal --> Double, java.util.Collection --> Boolean,
>>> java.util.Collection --> Object[], java.util.Collection -->
>>> org.apache.tapestry5.grid.GridDataSource, java.util.List -->
>>> org.apache.tapestry5.SelectModel, java.util.Map -->
>>> org.apache.tapestry5.SelectModel, long[] --> java.util.List, null -->
>>> Boolean, null --> org.apache.tapestry5.grid.GridDataSource,
>>> org.apache.tapestry5.ComponentResources -->
>>> org.apache.tapestry5.PropertyOverrides,
>>> org.apache.tapestry5.PrimaryKeyEncoder -->
>>> org.apache.tapestry5.ValueEncoder, org.apache.tapestry5.Renderable -->
>>> org.apache.tapestry5.Block, org.apache.tapestry5.Renderable -->
>>> org.apache.tapestry5.runtime.RenderCommand,
>>> org.apache.tapestry5.ioc.util.TimeInterval --> Long,
>>> org.apache.tapestry5.runtime.ComponentResourcesAware -->
>>> org.apache.tapestry5.ComponentResources, short[] --> java.util.List
>>>
>>>
>>>
>>> Could someone know what I'm doing wrong ?
>>>
>>> regards,
>>> Antoine.
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Loop%2C-RadioGroup-and-Coercion-tp26944581p26944581.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
>>>
>>>
>>
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Loop%2C-RadioGroup-and-Coercion-tp26944581p26944825.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