Creating the Custom field for the portlet
Creating the customfield in the custom portlet
1. Create the class and extend with BaseCustomAttributesDisplay.
2. Make an entry in liferay-portal.xml with tag as (custom-attribute-display) by defining the class
Thats it now the entry will be available to add the custom field in the control panel.
Go to the control Panel and click on the custom field. You can see the our portlet custom field value avaliable there.
Click on the Edit link and add the field name and select field type from the dropdown and also edit the permission to view for the user.
Now your custom field avaliable to add in the portlet.
3. To display the custom attributes in the jsp as editable keep editable as "true" if not "false" , like below
<liferay-ui:custom-attributes-available className="<%=Article.class.getName() %>">
<liferay-ui:custom-attribute-list
className="<%= Article.class.getName() %>"
classPK="<%= (article != null) ? article.getArticleId() : 0 %>"
editable="<%= true %>"
label="<%= true %>"
/>
</liferay-ui:custom-attributes-available>
4. Here Liferay is doing great job to get the expando values , by default it is setting in the servicecontext Object. so to set it we can do as
test.setExpandoBridgeAttributes(serviceContext);
5. To Get the entry
test.getExpandoBridge().getAttribute("<attribute-name>");
That's it we are done with the creating the custom field in custom portlet.
Comments
Post a Comment