I have searchKey
as a variable in action class and model-driven bean object.
public class PaymentGateWayAction extends ActionSupport implements ModelDriven<PaymentResponseDTO> {
private String searchKey;
private PaymentResponseDTO paymentResponseDTO = new PaymentResponseDTO();
// ...
}
searchKey
is also a variable in PaymentResponseDTO
.
I need to access searchKey
from the action class and modeldriven bean based on some conditions. Having varible with same name is bad. But The above one is already developed. If I do any modification in Java file, I need to do many modifications which are difficult.
Now I need to access the action class variable. I tried to access the variable from action class in the follwing way:
<s:hidden id="searchKey" name="searchKey" value="%{searchKey}"/>
But it is returning null values.
I have below code also:
this.setSearchKey("somevarible");
Please suggest where the wrong is going on
struts.xml
<action name="atomResponse" class="com.PaymentGateWayAction" method="atomPaymentResponse">
<result name="success" type="tiles">paymentGateWayResponse</result>
<result name="failure" type="tiles">paymentGateWayResponseError</result>
</action>
tiles xml
<definition name="paymentGateWayResponse" extends="b2cHome">
<put-attribute name="body" value="agent_b2c/b2c_paymentGateWayResponse.jsp" />
</definition>
In b2c_paymentGatewayResponse.jsp
the hidden field code is present.
searchKey
both as a variable in your action class and model-driven bean. Do you have getters and setters for thesearchKey
variable. – Uchenna NwanyanwusearchKey
as a variable in your action class and also in your model driven bean. – Uchenna NwanyanwuModelDriven
. – Uchenna Nwanyanwu