You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Derek Brown <ze...@yahoo.com> on 2005/03/11 03:40:38 UTC

Access Map values in OGNL

Hello,

Could anyone please show me an example of how I can
access a value of a map property in ognl?

If I do:

map.put("propNameA", "propValueA"}
map.put("propNameB", "propValueB"}

How can I get this in OGNL, I tried a few things to no
avail.

Thanks


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Access Map values in OGNL

Posted by Marcus Brito <mb...@gmail.com>.
> > map.put("propNameA", "propValueA"}
> > map.put("propNameB", "propValueB"}
> >
> > How can I get this in OGNL, I tried a few things to no
> > avail.
> 
> Try: map.propNameA


Or map["propNameA"] if "propNameA" isn't actually a valid property
name (something with dashes, commas, or anything else that would not
make up a valid identifier).

OGNL language guide should be linked from the Tapestry documentation,
really. A day doesn't goes by without someone asking something about
OGNL syntax:

http://www.ognl.org/2.6.7/Documentation/html/LanguageGuide/index.html

-- MB

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Access Map values in OGNL

Posted by Kent Tong <ke...@cpttm.org.mo>.
Derek Brown <zegloman <at> yahoo.com> writes:

> map.put("propNameA", "propValueA"}
> map.put("propNameB", "propValueB"}
> 
> How can I get this in OGNL, I tried a few things to no
> avail.

Try: map.propNameA



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Access Map values in OGNL

Posted by Danny Mandel <dm...@tolweb.org>.
Assuming you have a getter for your map property, you could do something 
like this:

(assuming that the map property is called map)

<span jwcid="@Insert" value="ognl:map.get('propNameA')"/>

Would print out 'propValueA' -- using your example values.

In general you can call any method on any object from ognl by using the 
full method name and parentheses.

Hope that helps,
Danny

Derek Brown wrote:

>Hello,
>
>Could anyone please show me an example of how I can
>access a value of a map property in ognl?
>
>If I do:
>
>map.put("propNameA", "propValueA"}
>map.put("propNameB", "propValueB"}
>
>How can I get this in OGNL, I tried a few things to no
>avail.
>
>Thanks
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Yahoo! Small Business - Try our new resources site!
>http://smallbusiness.yahoo.com/resources/ 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Access Map values in OGNL

Posted by Paul Ferraro <pm...@columbia.edu>.
You can use the OGNL index notation for referencing map values by key.
e.g.
map['propNameA']

Paul

Derek Brown wrote:

>Hello,
>
>Could anyone please show me an example of how I can
>access a value of a map property in ognl?
>
>If I do:
>
>map.put("propNameA", "propValueA"}
>map.put("propNameB", "propValueB"}
>
>How can I get this in OGNL, I tried a few things to no
>avail.
>
>Thanks
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Yahoo! Small Business - Try our new resources site!
>http://smallbusiness.yahoo.com/resources/ 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org