You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Björn-Peter Tietjens <bj...@web.de> on 2008/11/06 10:39:20 UTC

get method defined for class

Hi all,
i keep getting tis strange error:*
WicketMessage: No get method defined for class: class java.lang.String 
expression: id**
Root cause:**
org.apache.wicket.WicketRuntimeException: No get method defined for 
class: class java.lang.String expression: id***

when executing this line:
*add(new DropDownChoice("ddArtikel", new PropertyModel(artikel, "name"), 
artikelList, new ChoiceRenderer("name", "id")));

*in my class Artikel the "id" property is of type long, when i chang it 
to String then it works...

how do i need to do that to make it work as "long"?

Thanx for your help.
Cheers Björn

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get method defined for class

Posted by Björn-Peter Tietjens <bj...@web.de>.
yep, thats what the problem was...

new PropertyModel(artikel, "name")

  indeed was of Type String changing that to Type "Artikel" made it work.
Thanx very much
;-)



Michael Sparer schrieb:
> nope that's not true, they don't expect Strings
>
> correct me if i'm wrong, but i think the problem most likely lies here:
>
> add(new DropDownChoice("ddArtikel", new PropertyModel(artikel, "name"),
> artikelList, new ChoiceRenderer("name", "id"))); 
>
> --> the choicerenderer looks for the path "id" on the model object, which is
> a string in your case (new PropertyModel(artikel, "name")), use e.g. new
> Model(artikel)
>
>
>
> Jurrie Overgoor-3 wrote:
>   
>> Björn-Peter Tietjens wrote:
>>     
>>> Hi all,
>>> i keep getting tis strange error:*
>>> WicketMessage: No get method defined for class: class java.lang.String 
>>> expression: id**
>>> Root cause:**
>>> org.apache.wicket.WicketRuntimeException: No get method defined for 
>>> class: class java.lang.String expression: id***
>>>
>>> when executing this line:
>>> *add(new DropDownChoice("ddArtikel", new PropertyModel(artikel, 
>>> "name"), artikelList, new ChoiceRenderer("name", "id")));
>>>
>>> *in my class Artikel the "id" property is of type long, when i chang 
>>> it to String then it works...
>>>
>>> how do i need to do that to make it work as "long"?
>>>       
>> I think that PropertyModels (and models in general) expect string return 
>> values for the POJO's getXXX() methods.
>>
>> You can try to override the getIdValue() method. Something like this:
>>
>>     ChoiceRenderer c = new ChoiceRenderer("name", "id") {
>>         public String getIdValue(Object object, int index) {
>>             return "" + (long)object;
>>         }
>>     };
>>
>> Note that this code is untested, and intended as explanation.
>>
>> -- 
>> With kind regards,
>> Jurrie Overgoor
>> 2go-mobile b.v.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>     
>
>
> -----
> Michael Sparer
> http://talk-on-tech.blogspot.com
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get method defined for class

Posted by Michael Sparer <mi...@gmx.at>.
nope that's not true, they don't expect Strings

correct me if i'm wrong, but i think the problem most likely lies here:

add(new DropDownChoice("ddArtikel", new PropertyModel(artikel, "name"),
artikelList, new ChoiceRenderer("name", "id"))); 

--> the choicerenderer looks for the path "id" on the model object, which is
a string in your case (new PropertyModel(artikel, "name")), use e.g. new
Model(artikel)



Jurrie Overgoor-3 wrote:
> 
> Björn-Peter Tietjens wrote:
>> Hi all,
>> i keep getting tis strange error:*
>> WicketMessage: No get method defined for class: class java.lang.String 
>> expression: id**
>> Root cause:**
>> org.apache.wicket.WicketRuntimeException: No get method defined for 
>> class: class java.lang.String expression: id***
>>
>> when executing this line:
>> *add(new DropDownChoice("ddArtikel", new PropertyModel(artikel, 
>> "name"), artikelList, new ChoiceRenderer("name", "id")));
>>
>> *in my class Artikel the "id" property is of type long, when i chang 
>> it to String then it works...
>>
>> how do i need to do that to make it work as "long"?
> 
> I think that PropertyModels (and models in general) expect string return 
> values for the POJO's getXXX() methods.
> 
> You can try to override the getIdValue() method. Something like this:
> 
>     ChoiceRenderer c = new ChoiceRenderer("name", "id") {
>         public String getIdValue(Object object, int index) {
>             return "" + (long)object;
>         }
>     };
> 
> Note that this code is untested, and intended as explanation.
> 
> -- 
> With kind regards,
> Jurrie Overgoor
> 2go-mobile b.v.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


-----
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: http://www.nabble.com/get-method-defined-for-class-tp20357843p20358584.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: get method defined for class

Posted by Jurrie Overgoor <ju...@2go-mobile.nl>.
Björn-Peter Tietjens wrote:
> Hi all,
> i keep getting tis strange error:*
> WicketMessage: No get method defined for class: class java.lang.String 
> expression: id**
> Root cause:**
> org.apache.wicket.WicketRuntimeException: No get method defined for 
> class: class java.lang.String expression: id***
>
> when executing this line:
> *add(new DropDownChoice("ddArtikel", new PropertyModel(artikel, 
> "name"), artikelList, new ChoiceRenderer("name", "id")));
>
> *in my class Artikel the "id" property is of type long, when i chang 
> it to String then it works...
>
> how do i need to do that to make it work as "long"?

I think that PropertyModels (and models in general) expect string return 
values for the POJO's getXXX() methods.

You can try to override the getIdValue() method. Something like this:

    ChoiceRenderer c = new ChoiceRenderer("name", "id") {
        public String getIdValue(Object object, int index) {
            return "" + (long)object;
        }
    };

Note that this code is untested, and intended as explanation.

-- 
With kind regards,
Jurrie Overgoor
2go-mobile b.v.