Horay! You are the first person to actually see and acknowledge the problem.
So far I have only recieved comments about the difference between the hash
and the non hash version - which I get. But no one has explained why in the
case of #2 OGNL returns null and not the value of the property as in #1.

Any one else know?

To quote another email:

>> <s:property value='%{contextKey+".title"}'/> is not
>> <s:property value="%{contextKey}"/
>> 
>> for 2 reasons:
>> contextKey+".title" says take entity one called contextKey which is null
>> and append string of .title
>> says '' delivers literal constant
>
> The entity contextKey is not null (this is seen by the other example which
> echoes the content) 
> unless adding an operator (+) in this case introduced a new implicit scope
> (which goes against 
> my expectations). Then perhaps in the scope of the + the contextKey entity
> is not defined - 
> consequently it returns null appended to the literal? (if thats so, then
> ognl is very odd)
>
> Or have I still not got it?
>
> Cheers
>    Caleb.




newton.dave wrote:
> 
> To continue, the first one (probably; I'm still a
> little fuzzy on OGNL sometimes) works because if a
> property isn't found in the action it will continue
> looking on the stack until it finds it or runs out.
> 
> Now, as to why #2 "doesn't work", I'm a little hazier
> on that: perhaps when OGNL has an expression tree it
> does lookup a bit differently or something?
> 
> d.
> 
> 
> --- Musachy Barroso <[EMAIL PROTECTED]> wrote:
> 
>> in OGNL there is always an object that is the
>> "root", so %{name} is
>> actually calling root.getName(). The "#" is used to
>> reference
>> something else than the root. In your views, your
>> action will be the
>> OGNL root (unless some tag pushes something to the
>> stack), to refer to
>> your property you would need #contextKey.
>> 
>> 
>> musachy
>> 
>> On Nov 8, 2007 7:13 AM, J&M <[EMAIL PROTECTED]>
>> wrote:
>> >
>> > Hi,
>> >
>> > Can any body explain the following to me, I don't
>> quite grok it. I have
>> > added a property value via my action
>> >
>> > ActionContext ctx = ActionContext.getContext();
>> > ctx.put("contextKey", "developer.page.logout");
>> >
>> > In the jsp I have the following:
>> >
>> > 1 <s:property value="%{contextKey}"/>
>> > 2 <s:property value='%{contextKey+".title"}'/>
>> > 3 <s:property value='%{#contextKey+".title"}'/>
>> > 4 <s:property value='%{"string1"+".title"}'/>
>> >
>> > This results in an output:
>> >
>> > 1 developer.page.logout
>> > 2 null.title
>> > 3 developer.page.logout.title
>> > 4 string1.title
>> >
>> > Why does 2 give me a null output and 1 not, and 3
>> give me what I want.
>> > What is the significance of the # in this case?
>> >
>> > Cheers
>> >     Caleb.
>> >
>> > --
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/OGNL-struts-property-tf4770568.html#a13664415
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to