Powered By Blogger

Sunday, April 10, 2011

Passing information from the action phase to the render phase

Information can be passed from action phase to the render phase in 2 ways
1. By setting the setRenderParameter in the processAction method
2. Using the session

1. BY setRenderParameter
Within the implementaiton in the
processAction method you can invoke the setRenderParameter to add a new parameter
to the request that the render phase will be able to read:
actionResponse.setRenderParameter("parameter-name", "value");
From the render phase (in our case, the JSP), this value can be read using the
regular parameter reading method:
renderRequest.getParameter("parameter-name");

It is important to be aware that when invoking an action URL, the parameters
specified in the URL will only be readable from the action phase (that is the
processAction method). In order to pass parameter values to the render phase you
must read them from the actionRequest and then invoke the setRenderParameter
method for each parameter needed.

2. By using SessionMessages

SessionMessages.add(actionRequest, "success");

This is displayed in the jsp with the below tag

No comments:

Post a Comment