You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vladimir Zavada <za...@gmail.com> on 2009/04/08 15:12:50 UTC
DropDownChoice custom key problem
Hi,
I have a problem with DropDownChoice. I am using DropDownChoice with
ChoiceRenderer and I am getting this error:
No get method defined for class: class java.lang.String expression: key
Here is a code:
DaysSelectOption[] options = new DaysSelectOption[] {new
DaysSelectOption("&", "AND"), new DaysSelectOption("|", "OR")};
ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key");
showVal.add(new DropDownChoice("day_val", new
PropertyModel(this, "items"), Arrays.asList(options), choiceRenderer));
where class DaysSelectOption is:
private class DaysSelectOption
{
private String key;
public String getKey()
{
return key;
}
public void setKey(String key)
{
this.key = key;
}
public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
private String value;
public DaysSelectOption(String key, String value)
{
this.key = key;
this.value = value;
}
thx for asnwers
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DropDownChoice custom key problem
Posted by Vladimir Zavada <za...@gmail.com>.
Great, thank you very much it works perfectly. I did not know that
object returned by the model and the type of objects in the list *must*
be the same.
Serkan Camurcuoglu wrote / napísal(a):
> why does it say java.lang.String instead of DaysSelectOption? On
> http://cwiki.apache.org/WICKET/dropdownchoice-examples.html it says:
>
> "You give a DDC a model and a list of possible values. The type of
> object returned by the model and the type of objects in the list
> *must* be the same. If your model returns an Integer, so you *must*
> pass a list of Integers, not IntegerSelectChoice or anything else.
>
> If you want to display something different than the integer, you have
> to implement some custom code in ChoiceRenderer.getDisplayValue().
> Don't get hung up on the idea that the value returned has to be a
> property of
> the objects in your list. It can be anything, such as the
> getString("period_" + object.toString()), for example."
>
>
>
> Vladimir Zavada wrote:
>> I have changed it to public and still the same error.
>>
>> James Carman wrote / napísal(a):
>>> The class is private.
>>>
>>> 2009/4/8 Vladimir Zavada <za...@gmail.com>:
>>>
>>>> Hi,
>>>> I have a problem with DropDownChoice. I am using DropDownChoice with
>>>> ChoiceRenderer and I am getting this error:
>>>>
>>>> No get method defined for class: class java.lang.String expression:
>>>> key
>>>>
>>>>
>>>> Here is a code:
>>>>
>>>> DaysSelectOption[] options = new DaysSelectOption[] {new
>>>> DaysSelectOption("&", "AND"), new DaysSelectOption("|", "OR")};
>>>> ChoiceRenderer choiceRenderer = new ChoiceRenderer("value",
>>>> "key");
>>>> showVal.add(new DropDownChoice("day_val", new
>>>> PropertyModel(this,
>>>> "items"), Arrays.asList(options), choiceRenderer));
>>>>
>>>> where class DaysSelectOption is:
>>>> private class DaysSelectOption
>>>> {
>>>> private String key;
>>>>
>>>> public String getKey()
>>>> {
>>>> return key;
>>>> }
>>>>
>>>> public void setKey(String key)
>>>> {
>>>> this.key = key;
>>>> }
>>>>
>>>> public String getValue()
>>>> {
>>>> return value;
>>>> }
>>>>
>>>> public void setValue(String value)
>>>> {
>>>> this.value = value;
>>>> }
>>>> private String value;
>>>> public DaysSelectOption(String key, String value)
>>>> {
>>>> this.key = key;
>>>> this.value = value;
>>>> }
>>>>
>>>> thx for asnwers
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> he class is private.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DropDownChoice custom key problem
Posted by Serkan Camurcuoglu <Se...@telenity.com>.
why does it say java.lang.String instead of DaysSelectOption? On
http://cwiki.apache.org/WICKET/dropdownchoice-examples.html it says:
"You give a DDC a model and a list of possible values. The type of
object returned by the model and the type of objects in the list *must*
be the same. If your model returns an Integer, so you *must* pass a list
of Integers, not IntegerSelectChoice or anything else.
If you want to display something different than the integer, you have to
implement some custom code in ChoiceRenderer.getDisplayValue(). Don't
get hung up on the idea that the value returned has to be a property of
the objects in your list. It can be anything, such as the
getString("period_" + object.toString()), for example."
Vladimir Zavada wrote:
> I have changed it to public and still the same error.
>
> James Carman wrote / napísal(a):
>> The class is private.
>>
>> 2009/4/8 Vladimir Zavada <za...@gmail.com>:
>>
>>> Hi,
>>> I have a problem with DropDownChoice. I am using DropDownChoice with
>>> ChoiceRenderer and I am getting this error:
>>>
>>> No get method defined for class: class java.lang.String expression: key
>>>
>>>
>>> Here is a code:
>>>
>>> DaysSelectOption[] options = new DaysSelectOption[] {new
>>> DaysSelectOption("&", "AND"), new DaysSelectOption("|", "OR")};
>>> ChoiceRenderer choiceRenderer = new ChoiceRenderer("value",
>>> "key");
>>> showVal.add(new DropDownChoice("day_val", new PropertyModel(this,
>>> "items"), Arrays.asList(options), choiceRenderer));
>>>
>>> where class DaysSelectOption is:
>>> private class DaysSelectOption
>>> {
>>> private String key;
>>>
>>> public String getKey()
>>> {
>>> return key;
>>> }
>>>
>>> public void setKey(String key)
>>> {
>>> this.key = key;
>>> }
>>>
>>> public String getValue()
>>> {
>>> return value;
>>> }
>>>
>>> public void setValue(String value)
>>> {
>>> this.value = value;
>>> }
>>> private String value;
>>> public DaysSelectOption(String key, String value)
>>> {
>>> this.key = key;
>>> this.value = value;
>>> }
>>>
>>> thx for asnwers
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> he class is private.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
Re: DropDownChoice custom key problem
Posted by Vladimir Zavada <za...@gmail.com>.
I have changed it to public and still the same error.
James Carman wrote / napísal(a):
> The class is private.
>
> 2009/4/8 Vladimir Zavada <za...@gmail.com>:
>
>> Hi,
>> I have a problem with DropDownChoice. I am using DropDownChoice with
>> ChoiceRenderer and I am getting this error:
>>
>> No get method defined for class: class java.lang.String expression: key
>>
>>
>> Here is a code:
>>
>> DaysSelectOption[] options = new DaysSelectOption[] {new
>> DaysSelectOption("&", "AND"), new DaysSelectOption("|", "OR")};
>> ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key");
>> showVal.add(new DropDownChoice("day_val", new PropertyModel(this,
>> "items"), Arrays.asList(options), choiceRenderer));
>>
>> where class DaysSelectOption is:
>> private class DaysSelectOption
>> {
>> private String key;
>>
>> public String getKey()
>> {
>> return key;
>> }
>>
>> public void setKey(String key)
>> {
>> this.key = key;
>> }
>>
>> public String getValue()
>> {
>> return value;
>> }
>>
>> public void setValue(String value)
>> {
>> this.value = value;
>> }
>> private String value;
>> public DaysSelectOption(String key, String value)
>> {
>> this.key = key;
>> this.value = value;
>> }
>>
>> thx for asnwers
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> he class is private.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
Re: DropDownChoice custom key problem
Posted by James Carman <jc...@carmanconsulting.com>.
The class is private.
2009/4/8 Vladimir Zavada <za...@gmail.com>:
> Hi,
> I have a problem with DropDownChoice. I am using DropDownChoice with
> ChoiceRenderer and I am getting this error:
>
> No get method defined for class: class java.lang.String expression: key
>
>
> Here is a code:
>
> DaysSelectOption[] options = new DaysSelectOption[] {new
> DaysSelectOption("&", "AND"), new DaysSelectOption("|", "OR")};
> ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key");
> showVal.add(new DropDownChoice("day_val", new PropertyModel(this,
> "items"), Arrays.asList(options), choiceRenderer));
>
> where class DaysSelectOption is:
> private class DaysSelectOption
> {
> private String key;
>
> public String getKey()
> {
> return key;
> }
>
> public void setKey(String key)
> {
> this.key = key;
> }
>
> public String getValue()
> {
> return value;
> }
>
> public void setValue(String value)
> {
> this.value = value;
> }
> private String value;
> public DaysSelectOption(String key, String value)
> {
> this.key = key;
> this.value = value;
> }
>
> thx for asnwers
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
he class is private.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org