[英]How to get Liferay user email address in JavaScript?
I can able to get themeDisplay object in JavaScript. 我可以在JavaScript中获取themeDisplay对象。
Refereed : https://web.liferay.com/web/pankaj.kathiriya/blog/-/blogs/usage-of-liferay-js-object 推荐人: https : //web.liferay.com/web/pankaj.kathiriya/blog/-/blogs/usage-of-liferay-js-object
$( document ).ready(function() {
var userid=Liferay.ThemeDisplay.getUserId;
alert(userid);
});
How to get User email Address
? 如何获得
User email Address
?
Liferay JS utility's Liferay.ThemeDisplay
or just themeDisplay
does not implicitly contain user's email address. Liferay JS实用程序的
Liferay.ThemeDisplay
或仅themeDisplay
不隐式包含用户的电子邮件地址。 It just exposes userId
and userName
while it doesn't have any getUser
or User
object in it. 它只公开
userId
和userName
而其中没有任何getUser
或User
对象。
However, you can achieve that by overridding \\html\\common\\themes\\top_js.jspf
using JSP hook. 但是,您可以通过使用JSP挂钩覆盖
\\html\\common\\themes\\top_js.jspf
来实现。 All you need to do is to add following lines below getUserName: function() {
: 您需要做的就是在
getUserName: function() {
下面添加以下行getUserName: function() {
:
getUserEmailAddress: function() {
<c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>">
return "<%= UnicodeFormatter.toString(user.getEmailAddress()) %>";
</c:when>
<c:otherwise>
return "";
</c:otherwise>
</c:choose>
},
Then you will be able to get user's email address by either Liferay.ThemeDisplay.getUserEmailAddress();
然后,您将可以通过
Liferay.ThemeDisplay.getUserEmailAddress();
获取用户的电子邮件地址Liferay.ThemeDisplay.getUserEmailAddress();
or themeDisplay.getUserEmailAddress();
或
themeDisplay.getUserEmailAddress();
或 . 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.