Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Replace or override function on a Liferay native portlet

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 211
    Comment on it

    Liferay have several ways to modify the functionality of a native Liferay portlet and you can extend the functionality.

    Liferay provide most hooked functionality is described by using the liferay-hook.xml file located in /docroot/WEB-INF directory.

    Here are the most common methods are shown :

    Custom JSPs

    Add the following child to in liferay-hook.xml file.

    <custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
    

    Above element defines the location of custom jsp page's.
    For example you may want to rewrite view.jsp for the Document Library portlet at:

    [custom-jsp-dir]/html/portlet/document_library/view.jsp
    

    Model Listeners


    Model Listeners, In which you will have to define a portal.property file located at,

    /docroot/WEB-INF/src/portal.property

    The following is an example for the above :

    <portal-properties>portal.properties</portal-properties>
    

    If you want to listen to changes in User, for example, you would write in the property.

    value.object.listener.com.liferay.portal.model.User=com.my.example.UserListener;
    

    As following format :

    value.object.listener.[class-to-listen]=[my-listener-class]
    

    Your class should implement com.liferay.portal.model.BaseModelListener.

    Here, You can listen to events such as Add, Update, Remove etc.



    Extend\Overwrite Service

    A similar here, in liferay-hook.xml in the element add

    <service>
        <service-type>com.liferay.portal.service.UserService</service-type>
        <service-impl>my.example.service.UserServiceImpl</service-impl>
    </service>
    

    Your implementation should extend the correct wrapper class for a particular service.
    For the example above shown below:

    com.liferay.portal.service.UserServiceWrapper;
    

    You should now be able to overwrite or extend all the public methods for the UserService like updateUser(..).

    Customization of Struts Actions

    In very similar as extending services, define the elements for

    <struts-action>
        <struts-action-path>/message_boards/view</struts-action-path>
        <struts-action-impl>my.example.action.SampleViewAction</struts-action-impl>
    </struts-action>
    

    You should need to extend BaseStrutsAction class.

    com.liferay.portal.kernel.struts.BaseStrutsAction
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: