coding_idiot
coding_idiot

Reputation: 13734

How to use s:set as param to s:push making static method call in Struts 2

I tried :

<s:set name="ordersymbol" value="EURUSD" var="ordersymbol"/>
    <s:push value="@dao.positions@positionsO(%{#ordersymbol})">

<s:set name="ordersymbol" value="EURUSD" var="ordersymbol"/>
    <s:push value="@dao.positions@positionsO(#ordersymbol)">

<s:set name="ordersymbol" value="EURUSD" var="ordersymbol"/>
    <s:push value="@dao.positions@positionsO(ordersymbol)">

<s:set name="ordersymbol" value="EURUSD" var="ordersymbol"/>
    <s:push value="@dao.positions@positionsO(%{ordersymbol})">

Neither of the above four worked, the method always get null parameter.

Although if I try

<s:push value="@dao.positions@positionsO('EURUSD')">

it works fine.

Upvotes: 0

Views: 841

Answers (4)

Roman C
Roman C

Reputation: 1

Try

<s:push value="%{@dao.positions@positionsO(#ordersymbol)}">

something similar but taking an expression at whole and evaluate it.

Upvotes: 0

dmansfield
dmansfield

Reputation: 1128

I realize it's an old question... But:

The reason in doesn't work is that "value is an object." The correct <s:set/> would be:

<s:set var="ordersymbol" value="'EURUSD'" />

and the correct <s:push/> is the second one.

Upvotes: 1

Andrea Ligios
Andrea Ligios

Reputation: 50261

Have you tried with

<s:set name="ordersymbol" value="EURUSD" var="ordersymbol"/>
    <s:push value="@dao.positions@positionsO('%{#ordersymbol}')">

?

Upvotes: 1

coding_idiot
coding_idiot

Reputation: 13734

I figured out an alternative by the way.

<s:set value="@dao.positions@positionsO('EURUSD')" var="symbol1"/>
    <s:push value="#symbol1">

In case of using an iterator

<s:iterator value="#{'EURUSD':'EURUSD','GBPUSD':'GBPUSD'}>
<s:set value="@dao.positions@positionsO(value)" var="symbol1"/>
    <s:push value="#symbol1">...</s:push>
</s:iterator>

But I still have to figure out a way, incase I use a list in iterator, instead of a map as above.

Upvotes: 0

Related Questions