it thinks the model is an Item so its pulling it out and getting "ABC" then it is trying to get an id so it can see which item in the list is selected, so it uses the renderer to retrieve "id" property of the "ABC" string, thus the error since it doesnt have an id property.
either change your model to contain an item, or write a model that will convert from id to the object, kinda like the inverse of the choice renderer.
-Igor
On 3/1/06,
Scott Sauyet <[EMAIL PROTECTED]> wrote:
Oh, I'm glad to be back to Wicket. I've been off on a Struts project
for several months, and am so happy to be using simple Wicket again!
But I'm having a problem with my brain. This should be easy to figure
out, but I keep getting stuck. Maybe it's the late nights... I'm trying
to add a drop-down list, something I've done plenty often. And it ain't
working! I've got a simple test case. Code is below.
Any suggestions (including one for more coffee) would be much appreciated.
Thanks,
-- Scott
I'm getting a Wicket Runtime Exception:
======================================================================
wicket.WicketRuntimeException: Error getting id value of: ABC for
property: name
at
wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:154)
[ ... ]
Caused by: ognl.NoSuchPropertyException: java.lang.String.name
at
ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:123)
[ ... ]
======================================================================
Component Tree
======================================================================
# Path Type Model Object
1 _body wicket.markup.html.BodyOnLoadContainer
2 theForm wicket.markup.html.form.Form OGNL Exception:
_expression_='theForm'; path='0:theForm'
3 theForm:choose wicket.markup.html.form.DropDownChoice ABC
======================================================================
HTML
======================================================================
<html>
<head>
<title>Wicket Application</title>
<link rel="stylesheet" type="text/css" href=""><script type="text/_javascript_" language="_javascript_"
src=""></head>
<body>
<h1>Wicket Test Application</h1>
<p>This is a simple test of a Wicket Application.</p>
<form wicket:id="theForm">
<select wicket:id="choose">
<option value="test">Test Choice</option>
</select>
</form>
</body>
</html>
======================================================================
Java
======================================================================
package com.example.view;
import java.util.ArrayList;
import java.util.List;
import wicket.markup.html.form.ChoiceRenderer ;
import wicket.markup.html.form.DropDownChoice;
import wicket.markup.html.form.Form;
import wicket.markup.html.WebPage;
import wicket.model.CompoundPropertyModel;
public class Main extends WebPage {
public static List theList = getTheList();
public Main() {
super();
add(new InputForm("theForm", new MyModel()));
}
public static class InputForm extends Form {
public InputForm(String name, MyModel model) {
super(name, new CompoundPropertyModel(model));
add(new DropDownChoice("choose", theList, new
ChoiceRenderer("description", "name")));
}
}
private static List getTheList() {
List items = new ArrayList();
items.add(new Item("ABC", "First"));
items.add(new Item("DEF", "Second"));
items.add(new Item("XYZ", "Last"));
return items;
}
public static class MyModel {
private String choose ="ABC";
public String getChoose() {return choose;}
public void setChoose(String newChoose) {choose = newChoose;}
}
public static class Item {
public Item(String name, String description) {
this.name = name;
this.description = description;
}
public String toString() {
return description + " [" + name + "]";
}
private String name;
public String getName() {return name;}
public void setName(String newName) {name = newName;}
private String description;
public String getDescription() {return description;}
public void setDescription(String newDescription) {description
= newDescription;}
}
}======================================================================
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
