Tiles Struts / EL Expressions

Im using Struts 2.2.3 with tiles 2.1.4. It works absolutely fine, but now I'm trying to use EL expressions, and I can't get it to work. In Struts2, I can use <s:property value="${getText('Dashboard.label')}"/> , and it extracts the message from the package. I'd like to use the same in defining Tiles. So far Ive added param context to web.xml

 <context-param> <param-name>org.apache.tiles.evaluator.AttributeEvaluator</param-name> <param-value>org.apache.tiles.evaluator.el.ELAttributeEvaluator</param-value> </context-param> 

Now I want to use the following expression to define:

 <put-attribute name="pane-title" expression="${getText('Dashboard.label')}" cascade="true"/> 

The problem is that when I do this, the screen is not created saying:

Function ': getText' not found

So, I guess I missed something, but I don’t know why. Any ideas?

+1
struts2 tiles
source share
1 answer

I do not believe that this will work; You are trying to evaluate an OGNL expression as a plain old JSP EL. I see a couple of potential solutions.

I will try the simplest first (although it may not suit your needs in the end): set the value in action using the getDashboardLabel function (or something else) that calls the getText call. This should allow a simple request for the ${dashboardLabel} property.

It depends on how Tiles resolves EL with respect to how the current request resolves EL: S2 uses a thin shell to push the stack of values ​​in the EL JSP.

If this does not work or does not meet your needs, I think the next approach will be to see if you can create a Tiles attribute evaluator that accesses the value stack and replaces org.apache.tiles.evaluator.el.ELAttributeEvaluator . I'm not sure how easy or difficult it is, I have to check. If you can get this to evaluate OGNL in the same way as existing Struts tags, this can be quite interesting.

Oh, you can just create a JSP function library; I'm not quite sure how this works with an EL evaluator; with JSP it's pretty easy.

0
source share

All Articles