You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "CRANFORD, CHRIS" <Ch...@setech.com> on 2011/08/08 18:24:27 UTC

OGNL context lookup

I have a JSP page where I need to iterate over a list of strings and for
each string, I need to query the OGNL stack and get the value that
string name represents followed by adding the name/value pair to a URL.
I thought something like the following would work but it doesn't.  Can
anyone help?

<s:url id="url" action="actionCallback">
  <s:iterator value="params" var="param" status="paramStatus">
    <s:param name="top"/><s:property value="#top"/></s:param>
  </s:iterator>
</s:url>




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


Re: OGNL context lookup

Posted by Steven Yang <ke...@gmail.com>.
so what you want is dynamically finding values on top of the OGNL stack?

I am pretty sure its not possible directly through existing tags. But if
write your own method which is like
public Object getValueFromStack(String key) {
   return stack.findValue(key)
}
(havent gone to check how exactly to get the stack in Java, but I am sure
you know how)
then just do <s:property value="getValueFromStack(#param)"/>

or just put all your possible values in a map then you can do <s:property
value="someMap[#param]"/>

On Tue, Aug 9, 2011 at 12:24 AM, CRANFORD, CHRIS
<Ch...@setech.com>wrote:

> I have a JSP page where I need to iterate over a list of strings and for
> each string, I need to query the OGNL stack and get the value that
> string name represents followed by adding the name/value pair to a URL.
> I thought something like the following would work but it doesn't.  Can
> anyone help?
>
> <s:url id="url" action="actionCallback">
>  <s:iterator value="params" var="param" status="paramStatus">
>    <s:param name="top"/><s:property value="#top"/></s:param>
>  </s:iterator>
> </s:url>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>