You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jan Stette <ja...@gmail.com> on 2008/11/04 20:52:09 UTC

Question about property expressions

Hi all,

if I have a class like this:

class SomeClass {
   String getValue(String key);
}

...is there a way I can use a property expression to get values out of this
class?  E.g. using an expression like "value[myKey]".
In other words, something very similar to if the class looked like this:

class SomeClass {
   Map<String, String> getValues();
}

(of course, the expression would be "values[myKey]" in this case)

Unfortunately, in this instance the class isn't one that I can change.  So,
is the former example possible with the property expressions that come with
Wicket?  If not, what is the easiest way to extend these to do what I want -
overriding AbstractPropertyModel.getObject()?

Regards,
Jan

Re: Question about property expressions

Posted by Jan Stette <ja...@gmail.com>.
OK, thanks for the info.

Jan


2008/11/5 Igor Vaynberg <ig...@gmail.com>

> the mechanism for looking up expressions is not extensible, because it
> isnt meant to be extended. so you have to write your own model from
> scratch using something like mvel/ognl to access the property. both of
> those support method calls afaik.
>
> -igor
>
> On Wed, Nov 5, 2008 at 1:56 AM, Jan Stette <ja...@gmail.com> wrote:
> > 2008/11/5 Igor Vaynberg <ig...@gmail.com>
> >
> >> On Tue, Nov 4, 2008 at 5:54 PM, Jan Stette <ja...@gmail.com>
> wrote:
> >> > Sure.  To explain a bit more why I'm asking: I have a table component
> >> that's
> >> > configured using property expressions as to what's shown in each
> column.
> >> > The types of objects to be shown in the table are not known in
> advance,
> >> > hence having a hard coded model for a specific type of class isn't
> really
> >> > desirable.  Given this, do you think it would make sense to provide an
> >> > extended property model, so that it could cope with the type of
> example
> >> of
> >> > objects I showed below?
> >>
> >> no i do not. we keep our property expression language simple on
> >> purpose - we prefer java over strings. what you should do is have
> >> these objects implement an itnerface that has String getValue(String
> >> key) defined - that is how java works. if you cant do that then you
> >> can always yourself write something that uses reflection.
> >>
> >> -igor
> >>
> >>
> > Sorry, I don't think I'm making myself clear.  I was asking if I could
> > provide an extended property model, not for it to be provided in Wicket!
> > :-)  As I asked in my original question, what is the right place to hook
> > this in, is it by overriding AbstractPropertyModel.getObject()?  I had a
> > look at http://cwiki.apache.org/WICKET/property-expression-language.html
> ,
> > but that page seems out of date.
> >
> > Regards,
> > Jan
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Question about property expressions

Posted by Igor Vaynberg <ig...@gmail.com>.
the mechanism for looking up expressions is not extensible, because it
isnt meant to be extended. so you have to write your own model from
scratch using something like mvel/ognl to access the property. both of
those support method calls afaik.

-igor

On Wed, Nov 5, 2008 at 1:56 AM, Jan Stette <ja...@gmail.com> wrote:
> 2008/11/5 Igor Vaynberg <ig...@gmail.com>
>
>> On Tue, Nov 4, 2008 at 5:54 PM, Jan Stette <ja...@gmail.com> wrote:
>> > Sure.  To explain a bit more why I'm asking: I have a table component
>> that's
>> > configured using property expressions as to what's shown in each column.
>> > The types of objects to be shown in the table are not known in advance,
>> > hence having a hard coded model for a specific type of class isn't really
>> > desirable.  Given this, do you think it would make sense to provide an
>> > extended property model, so that it could cope with the type of example
>> of
>> > objects I showed below?
>>
>> no i do not. we keep our property expression language simple on
>> purpose - we prefer java over strings. what you should do is have
>> these objects implement an itnerface that has String getValue(String
>> key) defined - that is how java works. if you cant do that then you
>> can always yourself write something that uses reflection.
>>
>> -igor
>>
>>
> Sorry, I don't think I'm making myself clear.  I was asking if I could
> provide an extended property model, not for it to be provided in Wicket!
> :-)  As I asked in my original question, what is the right place to hook
> this in, is it by overriding AbstractPropertyModel.getObject()?  I had a
> look at http://cwiki.apache.org/WICKET/property-expression-language.html,
> but that page seems out of date.
>
> Regards,
> Jan
>

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


Re: Question about property expressions

Posted by Jan Stette <ja...@gmail.com>.
2008/11/5 Igor Vaynberg <ig...@gmail.com>

> On Tue, Nov 4, 2008 at 5:54 PM, Jan Stette <ja...@gmail.com> wrote:
> > Sure.  To explain a bit more why I'm asking: I have a table component
> that's
> > configured using property expressions as to what's shown in each column.
> > The types of objects to be shown in the table are not known in advance,
> > hence having a hard coded model for a specific type of class isn't really
> > desirable.  Given this, do you think it would make sense to provide an
> > extended property model, so that it could cope with the type of example
> of
> > objects I showed below?
>
> no i do not. we keep our property expression language simple on
> purpose - we prefer java over strings. what you should do is have
> these objects implement an itnerface that has String getValue(String
> key) defined - that is how java works. if you cant do that then you
> can always yourself write something that uses reflection.
>
> -igor
>
>
Sorry, I don't think I'm making myself clear.  I was asking if I could
provide an extended property model, not for it to be provided in Wicket!
:-)  As I asked in my original question, what is the right place to hook
this in, is it by overriding AbstractPropertyModel.getObject()?  I had a
look at http://cwiki.apache.org/WICKET/property-expression-language.html,
but that page seems out of date.

Regards,
Jan

Re: Question about property expressions

Posted by Igor Vaynberg <ig...@gmail.com>.
On Tue, Nov 4, 2008 at 5:54 PM, Jan Stette <ja...@gmail.com> wrote:
> Sure.  To explain a bit more why I'm asking: I have a table component that's
> configured using property expressions as to what's shown in each column.
> The types of objects to be shown in the table are not known in advance,
> hence having a hard coded model for a specific type of class isn't really
> desirable.  Given this, do you think it would make sense to provide an
> extended property model, so that it could cope with the type of example of
> objects I showed below?

no i do not. we keep our property expression language simple on
purpose - we prefer java over strings. what you should do is have
these objects implement an itnerface that has String getValue(String
key) defined - that is how java works. if you cant do that then you
can always yourself write something that uses reflection.

-igor


>
> Thanks,
> Jan
>
>
> 2008/11/4 Igor Vaynberg <ig...@gmail.com>
>
>> no you cannot use propertymodel, but you can easily write your own
>> model that calls the method directly.
>>
>> -igor
>>
>> On Tue, Nov 4, 2008 at 12:52 PM, Jan Stette <ja...@gmail.com> wrote:
>> > Hi all,
>> >
>> > if I have a class like this:
>> >
>> > class SomeClass {
>> >   String getValue(String key);
>> > }
>> >
>> > ...is there a way I can use a property expression to get values out of
>> this
>> > class?  E.g. using an expression like "value[myKey]".
>> > In other words, something very similar to if the class looked like this:
>> >
>> > class SomeClass {
>> >   Map<String, String> getValues();
>> > }
>> >
>> > (of course, the expression would be "values[myKey]" in this case)
>> >
>> > Unfortunately, in this instance the class isn't one that I can change.
>>  So,
>> > is the former example possible with the property expressions that come
>> with
>> > Wicket?  If not, what is the easiest way to extend these to do what I
>> want -
>> > overriding AbstractPropertyModel.getObject()?
>> >
>> > Regards,
>> > Jan
>> >
>>
>> ---------------------------------------------------------------------
>> 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: Question about property expressions

Posted by Jan Stette <ja...@gmail.com>.
Sure.  To explain a bit more why I'm asking: I have a table component that's
configured using property expressions as to what's shown in each column.
The types of objects to be shown in the table are not known in advance,
hence having a hard coded model for a specific type of class isn't really
desirable.  Given this, do you think it would make sense to provide an
extended property model, so that it could cope with the type of example of
objects I showed below?

Thanks,
Jan


2008/11/4 Igor Vaynberg <ig...@gmail.com>

> no you cannot use propertymodel, but you can easily write your own
> model that calls the method directly.
>
> -igor
>
> On Tue, Nov 4, 2008 at 12:52 PM, Jan Stette <ja...@gmail.com> wrote:
> > Hi all,
> >
> > if I have a class like this:
> >
> > class SomeClass {
> >   String getValue(String key);
> > }
> >
> > ...is there a way I can use a property expression to get values out of
> this
> > class?  E.g. using an expression like "value[myKey]".
> > In other words, something very similar to if the class looked like this:
> >
> > class SomeClass {
> >   Map<String, String> getValues();
> > }
> >
> > (of course, the expression would be "values[myKey]" in this case)
> >
> > Unfortunately, in this instance the class isn't one that I can change.
>  So,
> > is the former example possible with the property expressions that come
> with
> > Wicket?  If not, what is the easiest way to extend these to do what I
> want -
> > overriding AbstractPropertyModel.getObject()?
> >
> > Regards,
> > Jan
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Question about property expressions

Posted by Igor Vaynberg <ig...@gmail.com>.
no you cannot use propertymodel, but you can easily write your own
model that calls the method directly.

-igor

On Tue, Nov 4, 2008 at 12:52 PM, Jan Stette <ja...@gmail.com> wrote:
> Hi all,
>
> if I have a class like this:
>
> class SomeClass {
>   String getValue(String key);
> }
>
> ...is there a way I can use a property expression to get values out of this
> class?  E.g. using an expression like "value[myKey]".
> In other words, something very similar to if the class looked like this:
>
> class SomeClass {
>   Map<String, String> getValues();
> }
>
> (of course, the expression would be "values[myKey]" in this case)
>
> Unfortunately, in this instance the class isn't one that I can change.  So,
> is the former example possible with the property expressions that come with
> Wicket?  If not, what is the easiest way to extend these to do what I want -
> overriding AbstractPropertyModel.getObject()?
>
> Regards,
> Jan
>

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