>When Wicket calls my onSelectionChanged(), the argument is the display
string, not the id value.
Your RadioChoice is working on string choices so it will hand you the
selected string.
I'd suggest to let your RadioChoice work with ints or preferably
directly on the Milepost objects:
final RadioChoice<Milepost> choice = new RadioChoice<Milepost>(...);
Sven
On 04/25/2012 03:00 PM, Richard W. Adams wrote:
My understanding of this class must be faulty. When Wicket calls my
onSelectionChanged(), the argument is the display string, not the id
value. For example, I'm expecting a milepost value like "123.456", but
instead I get "End (123.456)" (the display value). Here's the code. can
anyone see what I'm doing wrong?
private RadioChoice<String> createMilepostChoice(final String id, final
TrackModel track) {
final Milepost startMP = track.getStartMP();
final Milepost endMP = track.getEndMP ();
final List<String> choices = Arrays.asList(new
String[]{format(START, startMP), format(END, endMP), OTHER});
final ChoiceRenderer<String> renderer = new
ChoiceRenderer<String>() {
private static final long serialVersionUID = 1L;
@Override public Object getDisplayValue(final String model) {
return model;
}
@Override public String getIdValue(final String model, final int
index) {
String value;
switch (index) {
case 0:
value = startMP.toString();
break;
case 1 :
value = endMP.toString();
break;
default :
value = "";
}
return value;
}
};
final RadioChoice<String> choice = new RadioChoice<String>(id,
choices, renderer) {
private static final long serialVersionUID = 1L;
@Override protected void onSelectionChanged(final Object
new selection) {
final String selection = (String)newSelection;
if (track == primaryTrack) {
primaryMpChoice = selection;
} else {
secondaryMpChoice = selection;
}
}
@Override protected boolean
wantOnSelectionChangedNotifications() {
return true;
}
};
return choice;
}
**
This email and any attachments may contain information that is confidential
and/or privileged for the sole use of the intended recipient. Any use, review,
disclosure, copying, distribution or reliance by others, and any forwarding of
this email or its contents, without the express permission of the sender is
strictly prohibited by law. If you are not the intended recipient, please
contact the sender immediately, delete the e-mail and destroy all copies.
**
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org