First:
Read the javadoc again:
* The model object of the gorup is set to the model object of
* the selected radio component or null if none selected.
So the RadioGroup's model is the correct property model. What is incorrect is the model you set on the Radio components. The Radio component's model object is what will be put into the RadioGroup's model. Does that make sense?
Second:
I think the markupid is incorrect because you are in constructor of some component and the full path is not yet available. You need to defer the call to getMarkupId() until render time because then the component hierarchy is complete. This should be fixed in 1.3 refactor.
For now try this:
label2.add(new AttributeModifier("for", true, new AbstractRadOnlyModel() { Object getObject(Component c) { return radio2.getMarkupId(); }}));
-Igor
On 4/28/06, Michael Day <[EMAIL PROTECTED]> wrote:
Read the javadoc again:
* The model object of the gorup is set to the model object of
* the selected radio component or null if none selected.
So the RadioGroup's model is the correct property model. What is incorrect is the model you set on the Radio components. The Radio component's model object is what will be put into the RadioGroup's model. Does that make sense?
Second:
I think the markupid is incorrect because you are in constructor of some component and the full path is not yet available. You need to defer the call to getMarkupId() until render time because then the component hierarchy is complete. This should be fixed in 1.3 refactor.
For now try this:
label2.add(new AttributeModifier("for", true, new AbstractRadOnlyModel() { Object getObject(Component c) { return radio2.getMarkupId(); }}));
-Igor
On 4/28/06, Michael Day <[EMAIL PROTECTED]> wrote:
I have a couple of questions regarding RadioGroup.
I have the following code:
---------------------------------------------------------------
<span wicket:id="response">
<input wicket:id="radio1" type="radio" />
<label wicket:id="label1" class="radio">Choice 1</label>
<input wicket:id="radio2" type="radio" />
<label wicket:id="label2" class="radio">Choice 2</label>
</span>
---------------------------------------------------------------
RadioGroup group = new RadioGroup("response", new PropertyModel
(q, "response"));
add(group);
Radio radio1 = new Radio("radio1", new PropertyModel(q,
"response"));
radio1.setOutputMarkupId(true);
group.add(radio1);
Label label1 = new Label("label1", "I AGREE");
label1.add(new SimpleAttributeModifier("for",
radio1.getMarkupId()));
group.add(label1);
Radio radio2 = new Radio("radio2", new PropertyModel(q,
"response"));
radio2.setOutputMarkupId(true);
group.add(radio2);
Label label2 = new Label("label2", "I DISAGREE");
label2.add(new SimpleAttributeModifier("for",
radio2.getMarkupId()));
group.add(label2);
---------------------------------------------------------------
First, is my use of PropertyModel correct? Why do I need to specify
it for RadioGroup *and* each Radio? I think I should be able to
specify it for the RadioGroup only, but then I think wicket tries to
call q.getResponse().setRadio1() and q.getResponse().setRadio2()
instead of q.setResponse().
Second, getMarkupId() is not returning the correct value. Note that
the "for" attribute is not correct in the following output:
---------------------------------------------------------------
<input value="0:form:questions:0:question:response:radio1"
type="radio" wicket:id="radio1" checked="checked" name="questions:
0:question:response" id="order-
form_questions_0_question_response_radio1"/>
<label wicket:id="label1" class="radio" for=""
AGREE</label>
<input value="0:form:questions:0:question:response:radio2"
type="radio" wicket:id="radio2" checked="checked" name="questions:
0:question:response" id="order-
form_questions_0_question_response_radio2"/>
<label wicket:id="label2" class="radio" for="">DISAGREE</label>
---------------------------------------------------------------
Is this a bug or an error on my part?
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user