does that code work if the component is not disabled? does LabelValue
have equals/hashcode properly implemented so the one you push with
setmodelobject will match one in the yesNoChoices collection?


-igor

On Mon, Oct 12, 2009 at 6:40 AM, Muro Copenhagen <copenha...@gmail.com> wrote:
> Hi,
>
> Any help on this issue regarding the  RadioChoice component will be
> appreciated.
>
> I'm having difficiltius showing the (previously) selected RadioChoice, and
> can not figure out what's going wrong.
>
> Here is my code:
>
> public class QuestionRightPanel extends Panel {
>    private String selectedValue;
>    private RadioChoice radioChoice;
>    ...
>    public QuestionRightPanel() {
>    ...
>    radioChoice = new RadioChoice("radioChoice", new MyModel(),
> yesNoChoices, new ChoiceRenderer("label", "value")).setSuffix("");
>    ...
>    selectedValue = getAlreadyChoosenValue();
>    if (questionAnswered) {
>        radioChoice.setVisible(true);
>        radioChoice.setEnabled(false);
>       radioChoice.setModelObject(new
> LabelValue(convertYesNo(selectedValue), selectedValue));
>    }
>
>    class MyModel extends Model {
>
>       �...@override
>        public Object getObject() {
>            return selectedValue;
>        }
>
>       �...@override
>        public void setObject(Serializable object) {
>            if (object != null) {
>                // set the yes-no value choosen.
>                selectedValue = ((LabelValue) object).getValue();
>            }
>        }
>    }
>
> As seen i don't want the user to answer the question again by disabling the
> radioChoice if the
> question already has been answered.
> By why can't i set the default selected option to be the value i desire by
> the code:
>      radioChoice.setModelObject(new LabelValue(convertYesNo(selectedValue),
> selectedValue));
>
> Hope someone has the answer...
>
> Best Regards
> Muro
>

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

Reply via email to