Custom fields of Organization in Liferay
2012-11-14 22:00
169 查看
I like this functionality in Liferay, we can customize liferay without creating Hook or Ext plugins. When I want to add Twitter field for organization to add twitter screen name, I was thinking I have to create a hook or ext plugins to do that. It would
be very frustrating. Then my coworker told me I just need to go to Control panel as a admin, and in the left navigation, go to User and Organization. Next, you'll find a custom field link. Here you can add any custom fields you like.
Suppose you add a new column named Twitter. In the database, liferay doesn't change structure of organization_ table, what it does is to add a row in expando table. Custom field affects four tables. Let's list them:
1. expandocolumn: column name twitter will be stored here
2. expandorow: I don't know the one.
3. expandotable: Here specify the column belongs to organization_.
4. expandovalue: the value of twitter filed will be stored here
The next thing is how to get value of twitter:
protected String getTwitterScreenNameByOrganization(Organization org)
throws PortalException, SystemException {
ExpandoBridge bridge = org.getExpandoBridge();
String twitterScreenName = null;
if (bridge.hasAttribute("twitter")) {
twitterScreenName = (String) ExpandoValueLocalServiceUtil.getData(
bridge.getClassName(),
ExpandoTableConstants.DEFAULT_TABLE_NAME, "twitter",
org.getPrimaryKey());
}
return twitterScreenName;
}
Here it is! When you get the organization, you'll get it. The other way in the api is really easy, just use bridge.getAttribute("twitter"), but in my case, I always get null. I don't know the reason, so just use the way.
be very frustrating. Then my coworker told me I just need to go to Control panel as a admin, and in the left navigation, go to User and Organization. Next, you'll find a custom field link. Here you can add any custom fields you like.
Suppose you add a new column named Twitter. In the database, liferay doesn't change structure of organization_ table, what it does is to add a row in expando table. Custom field affects four tables. Let's list them:
1. expandocolumn: column name twitter will be stored here
2. expandorow: I don't know the one.
3. expandotable: Here specify the column belongs to organization_.
4. expandovalue: the value of twitter filed will be stored here
The next thing is how to get value of twitter:
protected String getTwitterScreenNameByOrganization(Organization org)
throws PortalException, SystemException {
ExpandoBridge bridge = org.getExpandoBridge();
String twitterScreenName = null;
if (bridge.hasAttribute("twitter")) {
twitterScreenName = (String) ExpandoValueLocalServiceUtil.getData(
bridge.getClassName(),
ExpandoTableConstants.DEFAULT_TABLE_NAME, "twitter",
org.getPrimaryKey());
}
return twitterScreenName;
}
Here it is! When you get the organization, you'll get it. The other way in the api is really easy, just use bridge.getAttribute("twitter"), but in my case, I always get null. I don't know the reason, so just use the way.
相关文章推荐
- Dive to Liferay Organization Custom Field and logo stored in Database
- Joy of Programming: Understanding Bit-fields in C
- Display Custom Fields in a Content By Query Web Part
- The run order about Loaded event and OnApplyTemplate in custom control of Silverlight 2 beta 2
- Adding a custom method in an ADF BC Service Interface – update of a single attribute in a selected r
- VB6:关于“Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types.”的编译错误
- How to access body of Custom tags in JSP tutorial
- Custom Outcome Options of Task Form in SharePoint Designer on SharePoint 2013 Workflow
- Custom queries in Liferay (在liferay中使用传统的Query) 中文
- Display custom fields data in an HTML table
- 异常笔记(1)--Duplicate property mapping of organizationLeader found in edu.ur.ir.item.Organization
- Change language of UI using custom control in SharePoint 2010
- Custom usage of %w in Ruby
- (转)A drop-in universal solution for moving text fields out of the way of the keyboard
- Liferay get Organization by using User or get All Organizations in liferay database
- 使用autolayout在iOS7系统崩溃,提示为:*** Assertion failure in -[CustomClass layoutSublayersOfLayer:]
- A case study of implementing custom User Import module for Liferay
- Custom queries in Liferay (在liferay中使用传统的Query)
- Liferay Custom fields 的使用方法
- 95.You have a large amount of historical data in a flat file. Some analysts in your organization nee