I have a class Message.java
with two variables of same type Location.java
called origin
and destination
Message.java
public class Message{
private Location origin;
private Location destination;
//Getters and setters correctly defined
}
Location.java
public class Location{
private String address;
}
MessageAction.java
public class MessageAction {
private Message message;
//Getters and setters correctly defined
}
I want to reuse code, so I have created a common JSP and pass the name of these variables by parameter. (Of course, the code is more complex, this is only a basic example, so it really helps me to reuse code)
message.jsp
<s:push value="message">
<s:include value="/jsp/location.jsp">
<s:param name="variableName" value="'origin'" />
</s:include>
<s:include value="/jsp/location.jsp">
<s:param name="variableName" value="'destination'" />
</s:include>
</push>
Here comes the problem, I don't know how to show the value of %{variableName}.address
. I have tried several combinations and googled a while but I haven't found anything.
location.jsp
<s:set name="variableName">${param.variableName}</s:set>
<s:property value="%{%{variableName}.address}" />
If I write directly the names of the variables, I receive their value correctly, so the Action is setting them correctly.
<s:property value="origin.address" />
<s:property value="destination.address" />