if you type it it looks like this
DDC<T>(String,IModel<T>,IModel<List<T>>,IChoiceRenderer<T>)
the first model is the one that holds the selection, the second is the one
that holds a list of available choices.
the constructor with a single model:
DDC<T>(String,IModel<List<T>>,IChoiceRenderer<T>)
is used when you use DDC in combination with a compound property model on
the form, in which case the ddc's id is used as a property expression into
form's model to determine the selection. there is a great wiki page on
models.
so try this
myForm.add(new DropDownChoice("select",new Model(),new
MyChoices(),myRenderer));
this will create a ddc with a null selection. its not practical, because to
get the selection you have to call ddc.getmodelobject(), but it will at
least get you going before you decide on what model to use.
-igor
On 5/16/07, Florian Hehlen <[EMAIL PROTECTED]> wrote:
hi,
I am new to wicket so I am not sure how simple this issue is.
I am creating DropDownChoice components. I want to a) build the the
Options from a list of Objects (not primitives) and b) want to render
the option id and value as an attribute of the object in the list. this
definitly works in the following sample code:
public class WicketSandbox extends WebPage
{
public WicketSandbox()
{
addPageTitle("Development Sandbox");
final Form myForm = new Form("form");
add(myForm);
final ChoiceRenderer myRenderer = new ChoiceRenderer("name",
"id");
myForm.add(new DropDownChoice("select",new
MyChoices(),myRenderer));
}
}
But as soon as I add an IModel to the form it seems that the
DropDownChoice looks up the choices in the form's IModel. I have tried
to use the other constructors for the DropDownChoice which require an
(String id, IModel model, IModel choices, IChoicerenderer renderer) but
I can't figure out what is the difference between the 2 IModel objects
that have to be provided. If I provide twice a ref to the same object I
get a different error:
The expression 'id' is neither an index nor is it a method for the list
class java.util.ArrayList
this is an improvement because it is accessing the right object and
retrieving the list of choices but not extracting the the objects from
the list as it does when I use (String id, IModel choices,
IChoicerenderer renderer).
In all cases if I remove the ChoiceRenderer my web page builds and
displays but I see object.toString() values in my drop-downs.
Any tips or pointers would be greatly appreciated.
Florian Hehlen
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user