掲示板
SessionMessages
Hi there,
Need to customize login portlet in Liferay 5.2.3 working with the extension environment
One of the things I need to do is to display a session message or an error message like this ones:
For the error message (the red ones) I did it like this and it is working fine:
in processAction method of the Action:
if (condition) {
throw new MarketingCustomAttributeAlreadyAssignedException();
}
and in the correspondant jsp:
<liferay-ui:error exception="<%= MarketingCustomAttributeAlreadyAssignedException.class %>" message="marketing.error.custom-attribute-already-asigned" />
and that is working fine
But for the green ones what I tried after look at the source code is this but does not work:
in processAction method of the Action:
SessionMessages.add(actionRequest, "mensaje-de-prueba");
in the correspondant jsp:
<c:if test='<%= SessionMessages.contains(request, "test-message-01") %>'>
<span class="portlet-msg-info">
<liferay-ui:message key="test-message-01" />
</span>
</c:if>
in Language-ext.properties:
test-message-1=Hello
But nothing is displayed
Any help? Or another way to do it?
thanks in advance
Need to customize login portlet in Liferay 5.2.3 working with the extension environment
One of the things I need to do is to display a session message or an error message like this ones:
For the error message (the red ones) I did it like this and it is working fine:
in processAction method of the Action:
if (condition) {
throw new MarketingCustomAttributeAlreadyAssignedException();
}
and in the correspondant jsp:
<liferay-ui:error exception="<%= MarketingCustomAttributeAlreadyAssignedException.class %>" message="marketing.error.custom-attribute-already-asigned" />
and that is working fine
But for the green ones what I tried after look at the source code is this but does not work:
in processAction method of the Action:
SessionMessages.add(actionRequest, "mensaje-de-prueba");
in the correspondant jsp:
<c:if test='<%= SessionMessages.contains(request, "test-message-01") %>'>
<span class="portlet-msg-info">
<liferay-ui:message key="test-message-01" />
</span>
</c:if>
in Language-ext.properties:
test-message-1=Hello
But nothing is displayed
Any help? Or another way to do it?
thanks in advance
liferay developer:
in processAction method of the Action:
SessionMessages.add(actionRequest, "mensaje-de-prueba");
in the correspondant jsp:
<c:if test='<%= SessionMessages.contains(request, "test-message-01") %>'>
<span class="portlet-msg-info">
<liferay-ui:message key="test-message-01" />
</span>
</c:if>
those should be the same.
Thanks but that was not the problem. Yes of course the key should be the same, that was just a copy paste error when copy here but that is not the reason.
Anyway I found the reason that is:
SessionMessages.add(actionRequest, "test-message-01");
It shoud not be actionRequest but the request from HttpServletRequest Class that it can be obtained from actionRequest like this:
HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(
actionRequest);
And then doing this:
SessionMessages.add(servletRequest, "test-message-01");
is working fine
but thanks
Anyway I found the reason that is:
SessionMessages.add(actionRequest, "test-message-01");
It shoud not be actionRequest but the request from HttpServletRequest Class that it can be obtained from actionRequest like this:
HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(
actionRequest);
And then doing this:
SessionMessages.add(servletRequest, "test-message-01");
is working fine
but thanks
i was able to use actionRequest to set the Session Message.
(disregard my previous post about private-request-attribute since that wouldn't help).
I'll let you know when i find the solution so you don't need to touch the HttpServletRequest directly.
(disregard my previous post about private-request-attribute since that wouldn't help).
I'll let you know when i find the solution so you don't need to touch the HttpServletRequest directly.
Hi there I am trying to set session messages from a portlet in vaadin. I am having no problem setting and getting the message, however I do not have any jsp so I am not sure how to make the liferay UI display the messages on request. Is there a way to tell liferay to display the sessionmessages in the ui from java and not jsp?
Thanks
Thanks
10年前 に David H Nebinger によって更新されました。
RE: SessionMessages
Liferay Legend 投稿: 14917 参加年月日: 06/09/02 最新の投稿
Hey, Riley, the Vaadin portlet you create is totally responsible for the UI. Liferay will not inject elements into your UI, so you're going to have to take care of this yourself. That said, you can add the Liferay styles to labels to get them to render in the green, yellow, and red colors.
Darn, I was fearing that to be the answer. It seems strange that there is no API call that can trigger showing the Liferay messages.
Thanks for the quick response David!
Thanks for the quick response David!
10年前 に David H Nebinger によって更新されました。
RE: SessionMessages
Liferay Legend 投稿: 14917 参加年月日: 06/09/02 最新の投稿
Well, it's implemented using the Liferay tag library. You need to manually insert them into your JSP pages, too. There's nothing automatic about it...
If you were doing JSF, ZK, or any other framework you'd be left to rendering it manually, too...
If you were doing JSF, ZK, or any other framework you'd be left to rendering it manually, too...