struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stanl...@gmail.com
Subject Re: Evaluate a string property containing some OGNL expression
Date Fri, 15 Feb 2008 11:59:51 GMT
Could you put the "tricky & deep" dive code in your action and use simple
OGNL expressions on your pages?  I find when web pages start looking like
myObj.someSubList(X).someSubMap[Y](Z).subObj.fieldName I am writing complex
code in the *wrong* place.  Remember what the web page is for...
presentation!

Scott

On Fri, Feb 15, 2008 at 5:51 AM, Maxx <maxxyme@gmail.com> wrote:

> Hello,
>
> As I wasn't able to find this out at the moment, I'm posting my question
> here :
>
> Would it be possible, within Struts2 tags, to evaluate a (String)
> property which contains the OGNL expression referring to an other
> property??
>
> Example :
>
>        <s:set name="testValue" value="%{12}" />
>        testValue = <s:property value="#testValue" /> // print 1
>        <s:set name="testValueName" value="%{'testValue'}" />
>        testValueName = <s:property value="#testValueName" /> // print
> testValue
>
>        testValue (via xxxName) = <s:property value="%{%{#testValueName}}"
> />
> // print nothing!!!
>
>
> Why I'm wanting this ?
> This might be tricky but because I'm getting complex OGNL expressions like
> myObj.someSubList(X).someSubMap[Y](Z).subObj.fieldName
>
> I'd like to set my OGNL "prefix" with a simple set
> <s:set name="myPrefix"
> value="%{'myObj.someSubList(X).someSubMap[Y](Z).subObj.'}" />
> and then for each property call use something like
>        %{#myPrefix + 'fieldName'}
>
> But unfortunately I'm unable to make it work at the moment.
>
> Could please someone explain me what I'm doing wrong?
>
> Thanks,
> Maxx
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message