You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Patrick Davids <pa...@nubologic.com> on 2014/11/06 17:03:02 UTC
PropertyModel / PropertyResolver / Map or List access
Hi all,
the javadoc of PropertyResolver says, map or list access is possible via
keys or index.
Accessing an map via key is no problem, but I dont get it working for
lists and index.
for instance:
MyPage extends Page{
private IModel<List<Anything>> list;
public MyPage(IModel<List<Anything>> list){
super();
this.list = list;
add(new Label("mylabel", new PropertyModel(MyPage.this,
"list[1].anyProperty")));
}
}
ends up in a Exception like this:
Last cause: No get method defined for class: class MyPage$1 expression: 1
I also made a try with "list.1.anyProperty".
Not working...
Any ideas?
best regards
Patrick
Re: PropertyModel / PropertyResolver / Map or List access
Posted by Paul Bors <pa...@bors.ws>.
Create a quick-start, open a Jira ticket and provide a push request fixing
it :)
On Thu, Nov 6, 2014 at 11:38 AM, Patrick Davids <
patrick.davids@nubologic.com> wrote:
> Hi Paul,
> v6.17.0.
>
> Maybe, I made a too reduced example.
> My property navigates further... its more like this:
> "list[1].anyProperty[key]"
>
> Is such a combination allowed?
>
> Patrick
>
> Am 06.11.2014 17:24, schrieb Paul Bors:
> > I think that should have worked as per:
> > http://wicket.apache.org/guide/guide/modelsforms.html#modelsforms_2
> >
> > Label label = new Label("firstChildName", new PropertyModel(person,
> > "children.0.name"));
> >
> > What version of Wicket are you using?
> >
> >
> >
> > On Thu, Nov 6, 2014 at 11:03 AM, Patrick Davids <
> > patrick.davids@nubologic.com> wrote:
> >
> >> Hi all,
> >>
> >> the javadoc of PropertyResolver says, map or list access is possible via
> >> keys or index.
> >> Accessing an map via key is no problem, but I dont get it working for
> >> lists and index.
> >>
> >> for instance:
> >>
> >> MyPage extends Page{
> >>
> >> private IModel<List<Anything>> list;
> >>
> >> public MyPage(IModel<List<Anything>> list){
> >> super();
> >> this.list = list;
> >>
> >> add(new Label("mylabel", new PropertyModel(MyPage.this,
> >> "list[1].anyProperty")));
> >>
> >> }
> >>
> >> }
> >>
> >> ends up in a Exception like this:
> >> Last cause: No get method defined for class: class MyPage$1 expression:
> 1
> >>
> >> I also made a try with "list.1.anyProperty".
> >> Not working...
> >>
> >> Any ideas?
> >>
> >> best regards
> >> Patrick
> >
>
Re: PropertyModel / PropertyResolver / Map or List access
Posted by Patrick Davids <pa...@nubologic.com>.
Hi Paul,
v6.17.0.
Maybe, I made a too reduced example.
My property navigates further... its more like this:
"list[1].anyProperty[key]"
Is such a combination allowed?
Patrick
Am 06.11.2014 17:24, schrieb Paul Bors:
> I think that should have worked as per:
> http://wicket.apache.org/guide/guide/modelsforms.html#modelsforms_2
>
> Label label = new Label("firstChildName", new PropertyModel(person,
> "children.0.name"));
>
> What version of Wicket are you using?
>
>
>
> On Thu, Nov 6, 2014 at 11:03 AM, Patrick Davids <
> patrick.davids@nubologic.com> wrote:
>
>> Hi all,
>>
>> the javadoc of PropertyResolver says, map or list access is possible via
>> keys or index.
>> Accessing an map via key is no problem, but I dont get it working for
>> lists and index.
>>
>> for instance:
>>
>> MyPage extends Page{
>>
>> private IModel<List<Anything>> list;
>>
>> public MyPage(IModel<List<Anything>> list){
>> super();
>> this.list = list;
>>
>> add(new Label("mylabel", new PropertyModel(MyPage.this,
>> "list[1].anyProperty")));
>>
>> }
>>
>> }
>>
>> ends up in a Exception like this:
>> Last cause: No get method defined for class: class MyPage$1 expression: 1
>>
>> I also made a try with "list.1.anyProperty".
>> Not working...
>>
>> Any ideas?
>>
>> best regards
>> Patrick
>
Re: PropertyModel / PropertyResolver / Map or List access
Posted by Paul Bors <pa...@bors.ws>.
I think that should have worked as per:
http://wicket.apache.org/guide/guide/modelsforms.html#modelsforms_2
Label label = new Label("firstChildName", new PropertyModel(person,
"children.0.name"));
What version of Wicket are you using?
On Thu, Nov 6, 2014 at 11:03 AM, Patrick Davids <
patrick.davids@nubologic.com> wrote:
> Hi all,
>
> the javadoc of PropertyResolver says, map or list access is possible via
> keys or index.
> Accessing an map via key is no problem, but I dont get it working for
> lists and index.
>
> for instance:
>
> MyPage extends Page{
>
> private IModel<List<Anything>> list;
>
> public MyPage(IModel<List<Anything>> list){
> super();
> this.list = list;
>
> add(new Label("mylabel", new PropertyModel(MyPage.this,
> "list[1].anyProperty")));
>
> }
>
> }
>
> ends up in a Exception like this:
> Last cause: No get method defined for class: class MyPage$1 expression: 1
>
> I also made a try with "list.1.anyProperty".
> Not working...
>
> Any ideas?
>
> best regards
> Patrick
Re: [SOLVED] Re: PropertyModel / PropertyResolver / Map or List
access
Posted by Boris Goldowsky <bg...@cast.org>.
I would recommend against using .object inside a PropertyModel, at least
if your application makes use of detachable models. When a component uses
the property model in your example,
new PropertyModel(MyPage.this, "list.object[1].anyProperty")
The model returned by MyPage.getList() will be attached, but when the
PropertyModel is later detached, the upstream getList() model will NOT be
detached, possibly leading to session size blowing up or serialization
errors.
It won¹t necessarily cause a problem in your case, but beware.
Boris
On 11/7/14, 3:39 AM, "Patrick Davids" <pa...@nubologic.com> wrote:
>Hi Sven, Hi Paul,
>thanx, now its working.
>
>I thought the PropertyModel/PropertyResolver will unpack the
>model-object itself, so there is no need to adress getObject by ".object".
>Maybe a small note in javadoc could help others not running into this
>issue.
>
>So...
>All ways (mentioned in javadoc) are working, tested:
>(@Sven: I think you had some typos in your mail, so I will repeat my
>working tests)
>
>new PropertyModel(MyPage.this, "list.object[1].anyProperty")
>new PropertyModel(MyPage.this, "list.object.1.anyProperty")
>
>new PropertyModel(list, "[1].anyProperty")
>new PropertyModel(list, "1.anyProperty")
>
>as well, navigation further, such an expression is working, too.
>new PropertyModel(list, "1.anyProperty[any-string-key]")
>
>
>Thanx for help... best regards
>Patrick
>P.s.
>Short question for string-key-access on maps.
>The syntax is quite equal to associative arrays in javascript.
>I like the way it is in wicket, no need paying attention for additional
>quotation marks, and its ok for me, but shouldnt it also support
>new PropertyModel(list, "1.anyProperty['any-string-key']")?
>
>
>
>Am 06.11.2014 21:01, schrieb Sven Meier:
>> Hi,
>>
>> you're telling PropertyModel to look up property "list" from MyPage, but
>> "list" is not a list, it's a model, models don't have a property "1".
>>
>> Use this instead:
>>
>> new Label("myLabel", new PropertyModel(list, "[1],anyProperty"))
>>
>> ... or:
>>
>> new Label("myLabel", new PropertyModel(MyPage.this,
>> "list.object.[1].anyProperty"))
>>
>> Regards
>> Sven
>>
>>
>>
>> On 11/06/2014 05:03 PM, Patrick Davids wrote:
>>> Hi all,
>>>
>>> the javadoc of PropertyResolver says, map or list access is possible
>>>via
>>> keys or index.
>>> Accessing an map via key is no problem, but I dont get it working for
>>> lists and index.
>>>
>>> for instance:
>>>
>>> MyPage extends Page{
>>>
>>> private IModel<List<Anything>> list;
>>>
>>> public MyPage(IModel<List<Anything>> list){
>>> super();
>>> this.list = list;
>>>
>>> add(new Label("mylabel", new PropertyModel(MyPage.this,
>>> "list[1].anyProperty")));
>>>
>>> }
>>>
>>> }
>>>
>>> ends up in a Exception like this:
>>> Last cause: No get method defined for class: class MyPage$1
>>>expression: 1
>>>
>>> I also made a try with "list.1.anyProperty".
>>> Not working...
>>>
>>> Any ideas?
>>>
>>> best regards
>>> Patrick
>>> ---------------------------------------------------------------------
>>> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: [SOLVED] Re: PropertyModel / PropertyResolver / Map or List access
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
On Fri, Nov 7, 2014 at 10:39 AM, Patrick Davids <
patrick.davids@nubologic.com> wrote:
> Hi Sven, Hi Paul,
> thanx, now its working.
>
> I thought the PropertyModel/PropertyResolver will unpack the
> model-object itself, so there is no need to adress getObject by ".object".
> Maybe a small note in javadoc could help others not running into this
> issue.
>
Updated with
https://git-wip-us.apache.org/repos/asf?p=wicket.git;a=commit;h=410441f9
>
> So...
> All ways (mentioned in javadoc) are working, tested:
> (@Sven: I think you had some typos in your mail, so I will repeat my
> working tests)
>
> new PropertyModel(MyPage.this, "list.object[1].anyProperty")
> new PropertyModel(MyPage.this, "list.object.1.anyProperty")
>
> new PropertyModel(list, "[1].anyProperty")
> new PropertyModel(list, "1.anyProperty")
>
> as well, navigation further, such an expression is working, too.
> new PropertyModel(list, "1.anyProperty[any-string-key]")
>
>
> Thanx for help... best regards
> Patrick
> P.s.
> Short question for string-key-access on maps.
> The syntax is quite equal to associative arrays in javascript.
> I like the way it is in wicket, no need paying attention for additional
> quotation marks, and its ok for me, but shouldnt it also support
> new PropertyModel(list, "1.anyProperty['any-string-key']")?
>
I'd prefer to keep it simpler as now.
>
>
>
> Am 06.11.2014 21:01, schrieb Sven Meier:
> > Hi,
> >
> > you're telling PropertyModel to look up property "list" from MyPage, but
> > "list" is not a list, it's a model, models don't have a property "1".
> >
> > Use this instead:
> >
> > new Label("myLabel", new PropertyModel(list, "[1],anyProperty"))
> >
> > ... or:
> >
> > new Label("myLabel", new PropertyModel(MyPage.this,
> > "list.object.[1].anyProperty"))
> >
> > Regards
> > Sven
> >
> >
> >
> > On 11/06/2014 05:03 PM, Patrick Davids wrote:
> >> Hi all,
> >>
> >> the javadoc of PropertyResolver says, map or list access is possible via
> >> keys or index.
> >> Accessing an map via key is no problem, but I dont get it working for
> >> lists and index.
> >>
> >> for instance:
> >>
> >> MyPage extends Page{
> >>
> >> private IModel<List<Anything>> list;
> >>
> >> public MyPage(IModel<List<Anything>> list){
> >> super();
> >> this.list = list;
> >>
> >> add(new Label("mylabel", new PropertyModel(MyPage.this,
> >> "list[1].anyProperty")));
> >>
> >> }
> >>
> >> }
> >>
> >> ends up in a Exception like this:
> >> Last cause: No get method defined for class: class MyPage$1 expression:
> 1
> >>
> >> I also made a try with "list.1.anyProperty".
> >> Not working...
> >>
> >> Any ideas?
> >>
> >> best regards
> >> Patrick
> >> ---------------------------------------------------------------------
> >> 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
> >
>
[SOLVED] Re: PropertyModel / PropertyResolver / Map or List access
Posted by Patrick Davids <pa...@nubologic.com>.
Hi Sven, Hi Paul,
thanx, now its working.
I thought the PropertyModel/PropertyResolver will unpack the
model-object itself, so there is no need to adress getObject by ".object".
Maybe a small note in javadoc could help others not running into this issue.
So...
All ways (mentioned in javadoc) are working, tested:
(@Sven: I think you had some typos in your mail, so I will repeat my
working tests)
new PropertyModel(MyPage.this, "list.object[1].anyProperty")
new PropertyModel(MyPage.this, "list.object.1.anyProperty")
new PropertyModel(list, "[1].anyProperty")
new PropertyModel(list, "1.anyProperty")
as well, navigation further, such an expression is working, too.
new PropertyModel(list, "1.anyProperty[any-string-key]")
Thanx for help... best regards
Patrick
P.s.
Short question for string-key-access on maps.
The syntax is quite equal to associative arrays in javascript.
I like the way it is in wicket, no need paying attention for additional
quotation marks, and its ok for me, but shouldnt it also support
new PropertyModel(list, "1.anyProperty['any-string-key']")?
Am 06.11.2014 21:01, schrieb Sven Meier:
> Hi,
>
> you're telling PropertyModel to look up property "list" from MyPage, but
> "list" is not a list, it's a model, models don't have a property "1".
>
> Use this instead:
>
> new Label("myLabel", new PropertyModel(list, "[1],anyProperty"))
>
> ... or:
>
> new Label("myLabel", new PropertyModel(MyPage.this,
> "list.object.[1].anyProperty"))
>
> Regards
> Sven
>
>
>
> On 11/06/2014 05:03 PM, Patrick Davids wrote:
>> Hi all,
>>
>> the javadoc of PropertyResolver says, map or list access is possible via
>> keys or index.
>> Accessing an map via key is no problem, but I dont get it working for
>> lists and index.
>>
>> for instance:
>>
>> MyPage extends Page{
>>
>> private IModel<List<Anything>> list;
>>
>> public MyPage(IModel<List<Anything>> list){
>> super();
>> this.list = list;
>>
>> add(new Label("mylabel", new PropertyModel(MyPage.this,
>> "list[1].anyProperty")));
>>
>> }
>>
>> }
>>
>> ends up in a Exception like this:
>> Last cause: No get method defined for class: class MyPage$1 expression: 1
>>
>> I also made a try with "list.1.anyProperty".
>> Not working...
>>
>> Any ideas?
>>
>> best regards
>> Patrick
>> ---------------------------------------------------------------------
>> 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: PropertyModel / PropertyResolver / Map or List access
Posted by Sven Meier <sv...@meiers.net>.
Hi,
you're telling PropertyModel to look up property "list" from MyPage, but
"list" is not a list, it's a model, models don't have a property "1".
Use this instead:
new Label("myLabel", new PropertyModel(list, "[1],anyProperty"))
... or:
new Label("myLabel", new PropertyModel(MyPage.this,
"list.object.[1].anyProperty"))
Regards
Sven
On 11/06/2014 05:03 PM, Patrick Davids wrote:
> Hi all,
>
> the javadoc of PropertyResolver says, map or list access is possible via
> keys or index.
> Accessing an map via key is no problem, but I dont get it working for
> lists and index.
>
> for instance:
>
> MyPage extends Page{
>
> private IModel<List<Anything>> list;
>
> public MyPage(IModel<List<Anything>> list){
> super();
> this.list = list;
>
> add(new Label("mylabel", new PropertyModel(MyPage.this,
> "list[1].anyProperty")));
>
> }
>
> }
>
> ends up in a Exception like this:
> Last cause: No get method defined for class: class MyPage$1 expression: 1
>
> I also made a try with "list.1.anyProperty".
> Not working...
>
> Any ideas?
>
> best regards
> Patrick
> ---------------------------------------------------------------------
> 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