Search code examples
liferayliferay-6

Session Management in Liferay


How come I customize the session in Liferay?Sample codes are welcome as it will help more,I am pretty new to Liferay? To be more specific, i'll explain what i've done. Using Custom JSPs Hooks , i have overridden the $PORTAL_ROOT_HOME/html/portlet/login login.jsp and created my own jsp page and also overridden the LoginAction class.My login.jsp page looks like:

<aui:form action="" method="post">
        <table>
            <tr>
                <td>Username :</td>
                <td><input name="login" size=15 type="text" /></td>
            </tr>
            <tr>
                <td>Password :</td>
                <td><input name="password" size=15 type="password" /></td>
            </tr>
        </table>
        <aui:button type="submit" value="sign-in"/>
</aui:form>

Now please tell upon clicking on the submit button , how can i get the login values in LoginAction.java and hence set the values to session. This is what i mean by customizing.


Solution

  • You should have copied the origonal login.jsp file from the start. By the looks of your codesnipsets you forgot to set the action to your loginAction. This can be done the following way:

    <portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL">
                <portlet:param name="saveLastPath" value="0" />
                <portlet:param name="struts_action" value="/login/login" />
                <portlet:param name="doActionAfterLogin" value="<%= portletName.equals(PortletKeys.FAST_LOGIN) ? Boolean.TRUE.toString() : Boolean.FALSE.toString() %>" />
            </portlet:actionURL>
    
    <aui:form action="<%= loginURL %>" method="post">
            <table>
                <tr>
                    <td>Username :</td>
                    <td><aui:input name="login" size=15 type="text" /></td>
                </tr>
                <tr>
                    <td>Password :</td>
                    <td><aui:input name="password" size=15 type="password" /></td>
                </tr>
            </table>
            <aui:button type="submit" value="sign-in"/>
    </aui:form>
    

    Please note that it is better to copy the orginal $PORTAL_ROOT_HOME/html/portlet/login/ login.jsp to your hook. Then make the modifications if any needed.

    Your Hook will break / remove allot of existing functionality if the provided snipset is all you have.

    To receive the parameters from the action you can use Pauls answer.