what wicket version are you using because if i look at 290 of AbstractChoice it is nothing.
On 4/12/06, Vincent Jenks <[EMAIL PROTECTED]> wrote:
OK, I did this exactly how you showed me here...and I'm still getting the error.
Here's my model:
IModel dropDownModel = new Model()
{
protected Object load()
{
return new
ArrayList<String>(StringValues.getUSAStates().keySet()); //via proxy
}
};
Here's my dropdown:
add(new DropDownChoice("billingState", dropDownModel, new IChoiceRenderer()
{
public String getDisplayValue(Object object)
{
return StringValues.getUSAStates().get(object);
}
public String getIdValue(Object object, int index)
{
return object.toString();
}
}));
Here's the exception:
13:00:19,000 ERROR [RequestCycle] Unexpected runtime exception [page =
[Page class = com.myapp.ui.AddressInfo, id = 3]]
java.lang.NullPointerException
at wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:290)
at wicket.Component.renderComponent (Component.java:1888)
at wicket.markup.html.WebMarkupContainer.onRender(WebMarkupContainer.java:77)
at wicket.Component.render(Component.java:1163)
at wicket.MarkupContainer.renderNext(MarkupContainer.java :1136)
at wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:811)
at wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:753)
at wicket.Component.renderComponent (Component.java:1888)
at wicket.markup.html.WebMarkupContainer.onRender(WebMarkupContainer.java:77)
at wicket.markup.html.form.Form.onRender(Form.java:517)
at wicket.Component.render(Component.java :1163)
at wicket.markup.html.BodyOnLoadContainer.resolve(BodyOnLoadContainer.java:106)
at wicket.MarkupContainer.renderNext(MarkupContainer.java:1159)
at wicket.MarkupContainer.renderComponentTagBody (MarkupContainer.java:811)
at wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:753)
at wicket.Component.renderComponent(Component.java:1888)
at wicket.markup.html.WebMarkupContainer.onRender (WebMarkupContainer.java:77)
at wicket.Component.render(Component.java:1163)
at wicket.MarkupContainer.autoAdd(MarkupContainer.java:170)
at wicket.markup.html.BodyOnLoadResolver.resolve(BodyOnLoadResolver.java :60)
at wicket.MarkupContainer.renderNext(MarkupContainer.java:1146)
at wicket.MarkupContainer.renderAll(MarkupContainer.java:779)
at wicket.Page.onRender(Page.java:788)
at wicket.Component.render (Component.java:1163)
at wicket.Page.doRender(Page.java:251)
at wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:276)
at wicket.RequestCycle.respond(RequestCycle.java:934)
at wicket.RequestCycle.request(RequestCycle.java:411)
at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:208)
at wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:234)
..........
It's definitely the dropdown that is the culprit...when I remove it
from the page the
page renders just fine.
Any ideas?
On 4/10/06, Johan Compagner < [EMAIL PROTECTED]> wrote:
> ok then youre dropdown is wrong.
>
> IModel dropDownModel = new Model()
> {
> public Object getObject(final Component component)
> {
> return new
> ArrayList(StringValues.getUSAStates().keySet()); //via proxy
> }
> };
>
>
> add(new DropDownChoice("billingState", dropDownModel, new IChoiceRenderer()
> {
> public String getDisplayValue(Object object)
> {
>
> return StringValues.getUSAStates().get(object);
>
>
> }
>
> public String getIdValue(Object object, int index)
> {
> return object.toString();
> }
> }));
>
> I haven't seen many usecases for that because most of the time
> You have a List of States so getUSAStates doesn't return a map but directly
> a list.
> With State objects that has properties like: a key "AL" and as name
> "Alabama".
>
> That is the most used usecase i know of.
>
> johan
>
>
>
> On 4/11/06, Vincent Jenks <[EMAIL PROTECTED] > wrote:
> >
> > I'm sorry, I don't think I quite understand.
> >
> > I have dropDownModel which looks like this:
> >
> >
> > IModel dropDownModel = new Model()
> > {
> > protected Object load()
> > {
> >
> > return StringValues.getUSAStates(); //via proxy
> > }
> > };
> >
> > StringValues.getUSAStates() looks something like this:
> >
> > public static Map<String, String> getUSAStates()
> > {
> > Map<String, String> states = new HashMap<String, String>();
> > states.put("AL", "Alabama");
> > states.put("AK", "Alaska");
> > states.put("AZ", "Arizona");
> > states.put("AR", "Arkansas");
> > states.put("CA", "California");
> > ......
> >
> > Where "CA" is the key and "California" is the value...which is exactly how
> I'd like to see it in the select dropdown.
> >
> > Are you saying that I should split the keys and values into two different
> lists and look them up that way?
> >
> > It would be extremely useful, in my opinion, if Wicket had support for
> these types of objects internally, given the frequency of which they're
> used. It would be very intuitive if I could supply key/value Map objects
> into what is essentially a list of key/value pairs.
> >
> > Thanks again...
> >
> >
> >
> > On 4/10/06, Johan Compagner < [EMAIL PROTECTED]> wrote:
> > >
> > > give the choice renderen the complete hashmap
> > >
> > > And give the dropdown a model with the keys of that hashmap as a list.
> > >
> > > so if StringValues.getUSAStates (); are th ids in the hashmap then that
> should go ok.
> > >
> > > but youre choicerender is wrong:
> > >
> > >
> > > add(new DropDownChoice("billingState", dropDownModel, new
> IChoiceRenderer()
> > > {
> > > public String getDisplayValue(Object object)
> > > {
> > >
> > > return idValueHashmap.get(object);
> > >
> > > }
> > >
> > > public String getIdValue(Object object, int index)
> > > {
> > > return object.toString();
> > > }
> > > }));
> > >
> > >
> > >
> > > On 4/11/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
> > > >
> > > > Is there an example of this somewhere? I'm struggling to get this
> working where I have a HashMap<String, String>...the first String is the ID
> and the second String is the value.
> > > >
> > > > I have this:
> > > > IModel dropDownModel = new Model()
> > > > {
> > > > protected Object load()
> > > > {
> > > > return StringValues.getUSAStates();
> > > > }
> > > > };
> > > >
> > > > add(new DropDownChoice("billingState", dropDownModel, new
> IChoiceRenderer()
> > > > {
> > > > public String getDisplayValue(Object object)
> > > > {
> > > > return object.toString();
> > > > }
> > > >
> > > > public String getIdValue(Object object, int index)
> > > > {
> > > > return object.toString();
> > > > }
> > > > }));
> > > >
> > > > I *just* wanted to see the page render...I know the values aren't
> right...but anything would have been acceptable. I keep getting a very
> unhelpful NullPointerException that I'm not even sure has anything to do w/
> the dropdowns...but I assume it does since the rest of the form is very
> straightforward TextField components.
> > > >
> > > > I don't see where this is being done in wicket-examples....I'm using
> 1.1.1
> > > >
> > > > Thanks!
> > > >
> > > >
> > > >
> > > > On 4/1/06, Johan Compagner < [EMAIL PROTECTED]> wrote:
> > > >
> > > > >
> > > > > there is no map support for this.
> > > > >
> > > > > What you could do is give the map to the ChoiceRenderer impl
> > > > > and give the keys of the map as a list to the Choice.
> > > > >
> > > > >
> > > > > johan
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On 3/31/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > I'm trying to get a Map of data so I can have the key be the value
> of the dropdown options and the value of the Map item be the value of the
> option in the dropdown. Problem is, it doesn't look like DropDownChoice
> will accept a Map...unless I'm doing it wrong?
> > > > > >
> > > > > > Is a Map the best way to go? I was maybe considering using a
> single List collection and splitting a single string to get the two
> values....but that's pretty fugly too.
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
-------------------------------------------------------
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?cmdlnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
