Search code examples
authenticationliferayjsp-tagsliferay-hook

Liferay Login Hook, error pop up


I need to show the errors in login hook of liferay in popup, but the sentence is only a line of code, so I don't know how implement the popup. the key line is the next:

<liferay-ui:error exception="<%= NoSuchUserException.class %>" message="This message is editable" />

This error is to showed in a label but I didn't need this.

like this example:: http://www.jose-aguilar.com/blog/wp-content/uploads/2012/07/bootstrap-modal.png


Solution

  • In case you need to show errors in dialog box,I suppose you are using

    SessionErrors.add(actionRequest, "error");
    

    to send error from action phase.You can check SeesionErrors for 'error' attribute and display your message in dialog box:

           <% if(!SessionErrors.isEmpty(renderRequest))
        {
            String error=LanguageUtil.get(pageContext, "error");
            %>
        <aui:script>
      YUI().ready(function(A) {
        YUI().use('aui-base','liferay-util-window', function(A) {
            Liferay.Util.Window.getWindow({
                title : 'Error',
                dialog: {   
                    bodyContent: '<%=error%>',
                    destroyOnHide: true,
                    cache: false,
                    modal: true,
                    height: 300,
                    width: 300
                         }
                            })
                                });
                                   });
        </aui:script>
        <%} %>