前提:
1. Liferay portal 7
2. Liferay IDE 3.0.1
Liferay现有的工具中提供了很多修改portal的模板,以满足开发者的各种自定义需求。
修改的原理是利用Module小模块嵌到原来的代码中去,只是相当于打了一个补丁,并不会修改portal的源码,所以说是一种安全简单的方法。
步骤:
1. 新建一个Liferay Mudule Fragment Project(在选择HOST OSGi Bundle时选择com.liferay.login.web-version.jar,选择Override File Path点击Liferay蓝色的小图标选择META-INF/resources/login.jsp)
2.Click finish. 然后修改相应的jsp文件,改成你想要的界面,我只是做了一些小修改,看代码:
<%--
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%> <%@ include file="/init.jsp" %>
<p>Hello Joye</p> <c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>"> <%
String signedInAs = HtmlUtil.escape(user.getFullName());
if (themeDisplay.isShowMyAccountIcon() && (themeDisplay.getURLMyAccount() != null)) {
String myAccountURL = String.valueOf(themeDisplay.getURLMyAccount());
signedInAs = "<a class=\"signed-in\" href=\"" + HtmlUtil.escape(myAccountURL) + "\">" + signedInAs + "</a>";
}
%> <liferay-ui:message arguments="<%= signedInAs %>" key="you-are-signed-in-as-x" translateArguments="<%= false %>" />
</c:when>
<c:otherwise> <%
String redirect = ParamUtil.getString(request, "redirect");
String login = LoginUtil.getLogin(request, "login", company);
String password = StringPool.BLANK;
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
if (Validator.isNull(authType)) {
authType = company.getAuthType();
}
%> <portlet:actionURL name="/login/login" secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL" /> <aui:form action="<%= loginURL %>" autocomplete='<%= PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off" %>' cssClass="sign-in-form" method="post" name="fm" onSubmit="event.preventDefault();">
<aui:input name="saveLastPath" type="hidden" value="<%= false %>" />
<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
<aui:input name="doActionAfterLogin" type="hidden" value="<%= portletName.equals(PortletKeys.FAST_LOGIN) ? true : false %>" /> <c:choose>
<c:when test='<%= SessionMessages.contains(request, "userAdded") %>'> <%
String userEmailAddress = (String)SessionMessages.get(request, "userAdded");
String userPassword = (String)SessionMessages.get(request, "userAddedPassword");
%> <div class="alert alert-success">
<c:choose>
<c:when test="<%= company.isStrangersVerify() || Validator.isNull(userPassword) %>">
<liferay-ui:message key="thank-you-for-creating-an-account" /> <c:if test="<%= company.isStrangersVerify() %>">
<liferay-ui:message arguments="<%= userEmailAddress %>" key="your-email-verification-code-has-been-sent-to-x" translateArguments="<%= false %>" />
</c:if>
</c:when>
<c:otherwise>
<liferay-ui:message arguments="<%= userPassword %>" key="thank-you-for-creating-an-account.-your-password-is-x" translateArguments="<%= false %>" />
</c:otherwise>
</c:choose> <c:if test="<%= PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.ADMIN_EMAIL_USER_ADDED_ENABLED) %>">
<liferay-ui:message arguments="<%= userEmailAddress %>" key="your-password-has-been-sent-to-x" translateArguments="<%= false %>" />
</c:if>
</div>
</c:when>
<c:when test='<%= SessionMessages.contains(request, "userPending") %>'> <%
String userEmailAddress = (String)SessionMessages.get(request, "userPending");
%> <div class="alert alert-success">
<liferay-ui:message arguments="<%= userEmailAddress %>" key="thank-you-for-creating-an-account.-you-will-be-notified-via-email-at-x-when-your-account-has-been-approved" translateArguments="<%= false %>" />
</div>
</c:when>
</c:choose> <liferay-ui:error exception="<%= AuthException.class %>" message="authentication-failed" />
<liferay-ui:error exception="<%= CompanyMaxUsersException.class %>" message="unable-to-log-in-because-the-maximum-number-of-users-has-been-reached" />
<liferay-ui:error exception="<%= CookieNotSupportedException.class %>" message="authentication-failed-please-enable-browser-cookies" />
<liferay-ui:error exception="<%= NoSuchUserException.class %>" message="authentication-failed" />
<liferay-ui:error exception="<%= PasswordExpiredException.class %>" message="your-password-has-expired" />
<liferay-ui:error exception="<%= UserEmailAddressException.MustNotBeNull.class %>" message="please-enter-an-email-address" />
<liferay-ui:error exception="<%= UserLockoutException.LDAPLockout.class %>" message="this-account-is-locked" /> <liferay-ui:error exception="<%= UserLockoutException.PasswordPolicyLockout.class %>"> <%
UserLockoutException.PasswordPolicyLockout ule = (UserLockoutException.PasswordPolicyLockout)errorException;
%> <liferay-ui:message arguments="<%= ule.user.getUnlockDate() %>" key="this-account-is-locked-until-x" translateArguments="<%= false %>" />
</liferay-ui:error> <liferay-ui:error exception="<%= UserPasswordException.class %>" message="authentication-failed" />
<liferay-ui:error exception="<%= UserScreenNameException.MustNotBeNull.class %>" message="the-screen-name-cannot-be-blank" /> <aui:fieldset> <%
String loginLabel = null;
if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
loginLabel = "email-address";
}
else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
loginLabel = "screen-name";
}
else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
loginLabel = "id";
}
%> <aui:input autoFocus="<%= windowState.equals(LiferayWindowState.EXCLUSIVE) || windowState.equals(WindowState.MAXIMIZED) %>" cssClass="clearable" label="<%= loginLabel %>" name="login" showRequiredLabel="<%= false %>" type="text" value="<%= login %>">
<aui:validator name="required" />
</aui:input> <aui:input name="password" showRequiredLabel="<%= false %>" type="password" value="<%= password %>">
<aui:validator name="required" />
</aui:input> <span id="<portlet:namespace />passwordCapsLockSpan" style="display: none;"><liferay-ui:message key="caps-lock-is-on" /></span> <c:if test="<%= company.isAutoLogin() && !PropsValues.SESSION_DISABLED %>">
<aui:input checked="<%= rememberMe %>" name="forgetMe" type="checkbox" />
</c:if>
</aui:fieldset> <aui:button-row>
<aui:button type="submit" value="Join in the virtual world" />
</aui:button-row>
</aui:form> <liferay-util:include page="/navigation.jsp" servletContext="<%= application %>" /> <aui:script sandbox="<%= true %>">
var form = AUI.$(document.<portlet:namespace />fm); form.on(
'submit',
function(event) {
var redirect = form.fm('redirect'); if (redirect) {
var redirectVal = redirect.val(); redirect.val(redirectVal + window.location.hash);
} submitForm(form);
}
); form.fm('password').on(
'keypress',
function(event) {
Liferay.Util.showCapsLock(event, '<portlet:namespace />passwordCapsLockSpan');
}
);
</aui:script>
</c:otherwise>
</c:choose>
3.部署到Lifeay Portal上就可以看到你想要的效果啦,下面是效果图:
完工啦,以后会陆续更新其他模板的使用,发现有好多模板呀,咦,还有一些我也不会用,还好,我们组里有一群大神,哈哈