use of javax.portlet.MutableRenderParameters in project liferay-blade-samples by liferay.
the class UserController method submitApplicant.
@ActionMapping
public void submitApplicant(@ModelAttribute("user") User user, BindingResult bindingResult, ModelMap modelMap, Locale locale, ActionResponse actionResponse, SessionStatus sessionStatus) {
_localValidatorFactoryBean.validate(user, bindingResult);
if (!bindingResult.hasErrors()) {
if (_logger.isDebugEnabled()) {
_logger.debug("firstName=" + user.getFirstName());
_logger.debug("lastName=" + user.getLastName());
}
MutableRenderParameters mutableRenderParameters = actionResponse.getRenderParameters();
mutableRenderParameters.setValue("javax.portlet.action", "success");
sessionStatus.setComplete();
} else {
bindingResult.addError(new ObjectError("user", _messageSource.getMessage("please-correct-the-following-errors", null, locale)));
}
}
use of javax.portlet.MutableRenderParameters in project liferay-faces-bridge-impl by liferay.
the class Tests method getRequestContentLengthTest.
// Test 6.144
@BridgeTest(test = "getRequestContentLengthTest")
public String getRequestContentLengthTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletRequestPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletRequestPhase == Bridge.PortletPhase.ACTION_PHASE) {
ExternalContext externalContext = facesContext.getExternalContext();
ActionRequest actionRequest = (ActionRequest) externalContext.getRequest();
ActionResponse actionResponse = (ActionResponse) externalContext.getResponse();
MutableRenderParameters renderParameters = actionResponse.getRenderParameters();
renderParameters.setValue("getRequestContentLengthTest", Boolean.valueOf(actionRequest.getContentLength() == externalContext.getRequestContentLength()).toString());
return "multiRequestTestResultRenderCheck";
} else if (portletRequestPhase == Bridge.PortletPhase.HEADER_PHASE) {
ExternalContext externalContext = facesContext.getExternalContext();
HeaderRequest headerRequest = (HeaderRequest) externalContext.getRequest();
RenderParameters renderParameters = headerRequest.getRenderParameters();
if (Boolean.valueOf(renderParameters.getValue("getRequestContentLengthTest"))) {
testBean.setTestResult(true, "externalContext.getRequestContentLength() returned the expected value");
} else {
testBean.setTestResult(false, "externalContext.getRequestContentLength() did not return the expected value");
}
testBean.setTestComplete(true);
if (testBean.getTestStatus()) {
return Constants.TEST_SUCCESS;
} else {
return Constants.TEST_FAILED;
}
}
return "";
}
use of javax.portlet.MutableRenderParameters in project liferay-faces-bridge-impl by liferay.
the class ActionURLDemoPortlet method processAction.
@Override
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException {
ActionParameters actionParameters = actionRequest.getActionParameters();
String viewState = null;
for (String actionParameterName : actionParameters.getNames()) {
// necessary to iterate through the action parameter names in order to find the view state parameter.
if (actionParameterName.contains(ResponseStateManager.VIEW_STATE_PARAM)) {
viewState = actionParameters.getValue(actionParameterName);
break;
}
}
String nonFacesPostback = actionParameters.getValue("Non-Faces-Postback");
if ((viewState == null) && ("true".equalsIgnoreCase(nonFacesPostback))) {
MutableRenderParameters mutableRenderParameters = actionResponse.getRenderParameters();
mutableRenderParameters.setValue("Non-Faces-Postback", nonFacesPostback);
String foo = actionParameters.getValue("foo");
if (foo != null) {
mutableRenderParameters.setValue("foo", foo);
}
} else {
super.processAction(actionRequest, actionResponse);
}
}
use of javax.portlet.MutableRenderParameters in project liferay-faces-bridge-impl by liferay.
the class ActionURLDemoPortlet method doView.
@Override
protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
RenderParameters renderParameters = renderRequest.getRenderParameters();
String nonFacesPostback = renderParameters.getValue("Non-Faces-Postback");
if (nonFacesPostback == null) {
super.doView(renderRequest, renderResponse);
} else {
PrintWriter writer = renderResponse.getWriter();
writer.write("<p>");
writer.write("Successfully executed ");
writer.write("<strong>non-JSF postback</strong> in ");
writer.write(ActionURLDemoPortlet.class.getName());
writer.write("</p>");
String foo = renderParameters.getValue("foo");
writer.write("<p>");
writer.write("Action Parameter:<pre>foo=" + foo + "</pre>");
writer.write("</p>");
PortletURL renderURL = renderResponse.createRenderURL();
MutableRenderParameters mutableRenderParameters = renderURL.getRenderParameters();
mutableRenderParameters.setValue("componentPrefix", "portlet");
mutableRenderParameters.setValue("componentName", "actionurl");
mutableRenderParameters.setValue("componentUseCase", "general");
writer.write("<p>");
writer.write("<a href=\"");
writer.write(renderURL.toString());
writer.write("\">");
writer.write("Return to portlet:actionURL in the Liferay Faces Showcase");
writer.write("</a>");
writer.write("</p>");
}
}
Aggregations