Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass parameter to method call in Struts 2 OGNL

Tags:

java

struts2

ognl

I want to use a property as a param of an object's method.

<s:property value="orderProductId" />

returns correct value (e.g. 1)

<s:iterator value="%{order.getProductById(1).activations}">

gives me correct value too. But

<s:iterator value="%{order.getProductById(#orderProductId).activations}">

doesn't. Not sure why #orderProductId doesn't interpret correctly.

like image 714
Roy Chan Avatar asked May 31 '10 19:05

Roy Chan


People also ask

What is OGNL in Struts 2?

The Object-Graph Navigation Language (OGNL) is a powerful expression language that is used to reference and manipulate data on the ValueStack. OGNL also helps in data transfer and type conversion. The OGNL is very similar to the JSP Expression Language.

What is OGNL in Struts?

Object-Graph Navigation Language is an open-source Expression Language (EL) for Java objects. Specifically, OGNL enables the evaluation of EL expressions in Apache Struts, which is the commonly used development framework for Java-based web applications in enterprise environments.

What is ValueStack in Struts2?

A valueStack is simply a stack that contains application specific objects such as action objects and other model object. At the execution time, action is placed on the top of the stack. We can put objects in the valuestack, query it and delete it.

Which of the following is the default object of the Actioncontext?

A root is a default object in the context map and all objects it contains could be referenced without # . Framework sets this object to value stack.


1 Answers

Ah, the joy of %#$ in OGNL... This doesn't work ?

<s:iterator value="%{order.getProductById(orderProductId).activations}">
like image 127
leonbloy Avatar answered Nov 01 '22 11:11

leonbloy