Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pushpinder Singh
Need help to extend Asset Publisher to add custom fields in display setting
January 17, 2011 5:45 PM
Answer

Pushpinder Singh

Rank: Junior Member

Posts: 81

Join Date: July 21, 2010

Recent Posts

Hi All,
I need to extend existing asset publisher to add custom fields in display_settings.jspf and than extend abstract.jsp base on those field values.
Now I wonder how values from these new fields in extended display_settings.jspf will be passed to abstract.jsp. Is it stored somewhere in preference or passed as request parameter or request attribute. Do I need to extended any struct action class?

I will be using ext-plugin to extended changes.
I am using liferay 6.x.

Any help or hint will be really appreciated.
Pushpinder Singh
RE: Need help to extend Asset Publisher to add custom fields in display set
January 24, 2011 4:34 PM
Answer

Pushpinder Singh

Rank: Junior Member

Posts: 81

Join Date: July 21, 2010

Recent Posts

Hi All,
You have to do following steps to add custom fields in display setting for asset publisher:

1. Add you custom field in display_settings.jspf
2. Update /html/portlet/asset_publisher/init.jsp to get value for your custom fields.
3. Update your choice of display jsp file in folder /html/portlet/asset_publisher/ to handle custom fields.
4. Create your coustom Configuration action class ConfigurationActionImpl.java which handle your custom fields also.
5. Add following entry in liferay-portlet-ext.xml

<portlet>
<portlet-name>101</portlet-name>
<icon>/html/icons/asset_publisher.png</icon>
<struts-path>asset_publisher</struts-path>
<configuration-action-class>my.org.portlet.assetpublisher.action.ConfigurationActionImpl</configuration-action-class>
<indexer-class>com.liferay.portlet.assetpublisher.util.AssetIndexer</indexer-class>
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>asset_publisher</friendly-url-mapping>
<friendly-url-routes>com/liferay/portlet/assetpublisher/asset-publisher-friendly-url-routes.xml</friendly-url-routes>
<use-default-template>false</use-default-template>
<layout-cacheable>true</layout-cacheable>
<instanceable>true</instanceable>
<scopeable>false</scopeable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>25</render-weight>
<header-portlet-css>/html/portlet/asset_publisher/css/main.jsp</header-portlet-css>
<css-class-wrapper>portlet-asset-publisher</css-class-wrapper>
</portlet>
Boris Yurkevich
RE: Need help to extend Asset Publisher to add custom fields in display set
October 8, 2012 2:16 AM
Answer

Boris Yurkevich

Rank: New Member

Posts: 8

Join Date: April 20, 2012

Recent Posts

Pushpinder Singh,

Thank you very much for your instructions. If you can provide any references I'll be gratefull.
I have same task and I'm already stuck even on first step of your list.

1.
I'm not sure how it works. How do I add my custom filed in dislay_settings.jspf. All I have is a name of my custom field.

All code in display_settings.jspf is realted to Asset publisher's configuration pop-up window. Folowing instructions from step 2 I was already able to display my custom fields in Available List under Show Metadata header.

2.
Changed init.jsp from:
1String allMetadataFields = "create-date,modified-date,publish-date,expiration-date,priority,author,view-count,categories,tags";

To
1String allMetadataFields = "create-date,modified-date,publish-date,expiration-date,priority,author,view-count,categories,tags,realdate";


1"realdate"
is my custom field name

3.
This step is not neccessery to display your custom-field.

4.
What logic to implement here? Such as I just need display my custom field in date format.
I can see you refereing this Java file in XML from the next fifth step.

5.
It is important do not forget to wrap all XML above inside <liferay-portlet-app> node or you will get this error during ant compiling

 1
 211:19:24,161 ERROR [MainServlet:244] java.lang.ClassNotFoundException: my.org.portlet.assetpublisher.action.ConfigurationActionImpl
 3java.lang.ClassNotFoundException: my.org.portlet.assetpublisher.action.ConfigurationActionImpl
 4        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
 5        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
 6        at com.liferay.portlet.PortletBagFactory.newInstance(PortletBagFactory.java:593)
 7        at com.liferay.portlet.PortletBagFactory.newInstance(PortletBagFactory.java:581)
 8        at com.liferay.portlet.PortletBagFactory.newConfigurationAction(PortletBagFactory.java:482)
 9        at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:126)
10        at com.liferay.portal.servlet.MainServlet.initPortlets(MainServlet.java:864)
11        at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:241)
12        at javax.servlet.GenericServlet.init(GenericServlet.java:212)


Then in my ext project which looks now like this


I was able to see my custom field in Asset Publisher configuration pop-up window and when created new portlet.

I can't see my custom field next to Assets Publisher's metadata such as Authors, Category and so on.

Also Look At This Thread
Retrieving Custom Field (Expando Value) Associated With Web Content...