我已在Liferay 7门户网站中为Organization创建了自定义字段。现在我想获得自定义字段的值并获取PrincipalException - PermissionChecker未初始化:
Long userId = (Long) req.getSession().getAttribute(WebKeys.USER_ID);
List<Organization> mylist = OrganizationLocalServiceUtil.getUserOrganizations(userId);
if (!mylist.isEmpty()) {
Organization organization = mylist.get(0);
String orgUrl = group.getFriendlyURL();
>>> ExpandoBridge expandoBridge = organization.getExpandoBridge();
System.out.println(expandoBridge.getAttribute("custom_field"));
}
例外:
Caused by: com.liferay.portal.kernel.security.auth.PrincipalException: PermissionChecker not initialized
at com.liferay.portal.kernel.service.BaseServiceImpl.getPermissionChecker(BaseServiceImpl.java:81)
at com.liferay.portlet.expando.service.impl.ExpandoValueServiceImpl.getData(ExpandoValueServiceImpl.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:163)
答案 0 :(得分:2)
收到同事的答复。现在它正在运作。 将guest字符的权限设置为true并添加此代码
protected void exportexcelmail_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataBaseConnector db = new DataBaseConnector("M");
var masterid = Request.Form["MasterID"];
try
{
db.Connect();
db.InitCommand();
db.SetSqlString(Procedures.ReportsCustomerEmail.ToString());
db.AddParameter("@aysid", masterid);
dt = db.ExecWithTable();
db.Close();
MyFunction.ExportExcel_Click(dt, "MyExcel");
}
catch (ThreadAbortException exp)
{
//THAT is OK.Page never Refresh
}
catch (SqlException exp)
{
if (db != null)
{
db.Close();
}
string script = "<script type=\"text/javascript\">alert('" + exp.Message.Replace("'", "") + "');</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);
//PAGE REFRESH HERE
}
catch (Exception exp)
{
if (db != null)
{
db.Close();
}
string script = "<script type=\"text/javascript\">alert('" + exp.Message.Replace("'", "") + "');</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);
}