maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <aok...@bellsouth.net>
Subject Re: dynamic property access
Date Sat, 30 Oct 2004 09:13:24 GMT
Alex Karasulu wrote:

> Ben Anderson wrote:
>
>> Hi,
>> I want to dynamically set which property I access.  Is this possible? 
>> Obviously the below code won't work, but you get the idea.  I thought
>> maybe that the <j:expr> tag might help, but it doesn't seem to do
>> anything.
>>
>>    <j:set var="color" value="red"/>
>>    <j:set var="colorKey" value="color"/>
>>    <ant:echo>
>>        ${${colorKey}}
>>    </ant:echo>
>> Any ideas?
>>
>>  
>>
> Maybe if I'm right hehe - try this and if it makes things work:
>
> <j:set var="colorKey" value="${context.getVariable(color)}"/>
>
> or rather this would return "red":
>
> <ant:echo>
>     ${context.getVariable(colorKey)}
> </ant:echo>
>
> You could chain these calls too in the JEXL expression too if you had 
> multiple levels of indirection.
>
> Well guess it does not fit exactly this example which you point out 
> further down in this thread.  However I'm thinking what you want to do 
> is dynamically assemble a key value by resolving anther key.  I do 
> this for properties that associate values of an object like so:

>
> a.b.c.name=someobj
> a.b.c.class=CLI
> a.b.c.package=org.apache.maven
> a.b.c.interfaces=.....

You know I totally messed this up here are the correct property keys i 
was refering to above:

a.b.c.name=someobj
a.b.c.class.somebody=CLI
a.b.c.package.somebody=org.apache.maven
a.b.c.interfaces.somebody=.....

>
> I assemble these keys and look up their respective values using this 
> technique.
>
> Cheers,
> Alex
>
>> Thanks,
>> Ben
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>  
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


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


Mime
View raw message