DropDownChoiceに問題があります。アイテムを事前に選択する必要がありますが、見つけたすべてのチュートリアルと例では、プリミティブ型のリストのみを検討します。
オブジェクトのリストがあります。
class myObject {
private String name;
private String surname;
[setter and getter]
}
他のクラスでは
List<MyObject> myList = some_data_retrieve();
MyObject defaultValue = some_simple_data_retrieve();
次のコンストラクターを使用してDropDownChoiceimをビルドするには:
final DropDownChoice<T> ddc = new DropDownChoice<T>(id, data, new ChoiceRenderer<T>(choiceRendererExpression, choiceRendererIdExpression));
この上:
final DropDownChoice<myObject> ddc = new DropDownChoice<myObject>("wicket_id", myList, new ChoiceRenderer<myObject>("name", "surname"));
今。すべてのチュートリアル/例で、モデルで別のコンストラクターを使用します。例えば:
private static final List<String> SEARCH_ENGINES = Arrays.asList(new String[] {
"Google", "Bing", "Baidu" });
private String selected = "Google";
DropDownChoice<String> listSites = new DropDownChoice<String>(
"sites", new PropertyModel<String>(this, "selected"), SEARCH_ENGINES);
私はその種の呼び出しをエミュレートするためにこのようなことを試みました:
final DropDownChoice<myObject> ddc = new DropDownChoice<myObject>("wicket_id", new PropertyModel<myObject>(this,"defaultValue"),myList, new ChoiceRenderer<myObject>("name", "surname"));
しかし、私が得たのはエラーです:
No get method defined for class: package$WicketPage expression: defaultValue
どうか、私を理解するのを手伝ってください。
ありがとう