留言板

Overriding Portal class through modules in liferay 7 is possible or not ?

lokesh gorrela,修改在7 年前。

Overriding Portal class through modules in liferay 7 is possible or not ?

Regular Member 帖子: 173 加入日期: 16-3-9 最近的帖子
Hi Guys,
Overriding Portal class through modules in liferay 7 is possible or not ?
If it is possible, Could you please tell the process.
Thanks
Regards
Lokesh
thumbnail
David H Nebinger,修改在7 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
Which class?
lokesh gorrela,修改在7 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

Regular Member 帖子: 173 加入日期: 16-3-9 最近的帖子
Hello David H Nebinge
Thanks for your replay

I try to override "CreateAccountMVCActionCommand.java" class from below location.
D:\liferayupdatedsetup7\portal\modules\apps\foundation\login\login-web\src\main\java\com\liferay\login\web\portlet\actio\CreateAccountMVCActionCommand.java

Thanks
Regards
Lokesh
lokesh gorrela,修改在7 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

Regular Member 帖子: 173 加入日期: 16-3-9 最近的帖子
Hello David H Nebinge

I followed below process to overriden "CreateAccountMVCActionCommand.java" class through modules in liferay 7

1)I created new module project with name (blade.custom.account)
2)After that i created new class with name(CustomCreateAccountMVCActionCommand.java) in this location
/blade.custom.account/src/main/java/com/example/portlet/CustomCreateAccountMVCActionCommand.java
see the below code
package com.example.portlet;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import com.liferay.portal.kernel.portlet.bridges.mvc.BaseMVCActionCommand;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCActionCommand;

@Component(
property = {
"javax.portlet.name=com_liferay_login_web_portlet_FastLoginPortlet",
"javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet",
"mvc.command.name=/login/create_account",
"service.ranking:Integer=100"
},
service = MVCActionCommand.class)

public class CustomCreateAccountMVCActionCommand extends BaseMVCActionCommand {
@Reference(target =
"(&(mvc.command.name=/login/create_account)(javax.portlet.name= + LoginPortletKeys.LOGIN + ”))")

protected void addUser(
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
System.out.println("Enter into addUser method");
}
@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
// TODO Auto-generated method stub
System.out.println("Enter into doProcessAction method");
}
}


3)After that i deployed this module by using gradle tool in liferay IDE
4)I get the build successful
5)copy jar file from this location "D:\liferayupdatedsetup7\OSGI\bundles\osgi\modules\blade.custom.account.jar" and placed to this location "D:\liferayupdatedsetup7\bundles\deploy"
6)After that i tested this functionality,but this class is not overriden existing class.

Could you please tell the correct process.This is greate help to me.
Thanks
Regards
Lokesh
Carlos Gonzalez,修改在7 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

New Member 帖子: 9 加入日期: 11-3-3 最近的帖子
This works fine, I tried the same with the calendar portlet and does not work, when I add the annotation @Reference stops working (does not run the code), but if I remove the annotation @reference (and mvcActionCommand variable) everything works properly.

This is my code:


@Component(
         immediate = true, property = { 
             "javax.portlet.name=com_liferay_calendar_web_portlet_CalendarPortlet",
             "mvc.command.name=updateFormCalendarBooking",
         }, 
         service = MVCActionCommand.class)
 
 public class CustomCalendarMVCActionCommand extends BaseMVCActionCommand {

    @Reference(target = "(&(mvc.command.name=updateFormCalendarBooking)"
            + "(javax.portlet.name=com_liferay_calendar_web_portlet_CalendarPortlet))")
    public void setMvcActionCommand(MVCActionCommand mvcActionCommand) {
        this.mvcActionCommand = mvcActionCommand;
    }
    public MVCActionCommand getMvcActionCommand() {
        return this.mvcActionCommand;
    }
   protected MVCActionCommand mvcActionCommand;

    @Override
    protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
             if (_log.isInfoEnabled()) {
            _log.info("Update Calendar Booking");
        }
        getMvcActionCommand().processAction(actionRequest, actionResponse);    
    }
}
thumbnail
Kailash Yadav,修改在7 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

Regular Member 帖子: 211 加入日期: 11-10-18 最近的帖子
Hello Carlos Gonzalez, did you find any solution of it. I am facing same issue.

Carlos Gonzalez:
This works fine, I tried the same with the calendar portlet and does not work, when I add the annotation @Reference stops working (does not run the code), but if I remove the annotation @reference (and mvcActionCommand variable) everything works properly.

This is my code:


@Component(
         immediate = true, property = { 
             "javax.portlet.name=com_liferay_calendar_web_portlet_CalendarPortlet",
             "mvc.command.name=updateFormCalendarBooking",
         }, 
         service = MVCActionCommand.class)
 
 public class CustomCalendarMVCActionCommand extends BaseMVCActionCommand {

    @Reference(target = "(&(mvc.command.name=updateFormCalendarBooking)"
            + "(javax.portlet.name=com_liferay_calendar_web_portlet_CalendarPortlet))")
    public void setMvcActionCommand(MVCActionCommand mvcActionCommand) {
        this.mvcActionCommand = mvcActionCommand;
    }
    public MVCActionCommand getMvcActionCommand() {
        return this.mvcActionCommand;
    }
   protected MVCActionCommand mvcActionCommand;

    @Override
    protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
             if (_log.isInfoEnabled()) {
            _log.info("Update Calendar Booking");
        }
        getMvcActionCommand().processAction(actionRequest, actionResponse);    
    }
}
luiz sergio resende ferreira,修改在7 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

New Member 帖子: 11 加入日期: 17-3-9 最近的帖子
I have the same issue

https://web.liferay.com/pt/community/forums/-/message_boards/message/88197849
Daniele Zirpoli,修改在6 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

New Member 帖子: 2 加入日期: 17-7-12 最近的帖子
Hi| I am facing same issue. Anyone find any solution of it?

Carlos Gonzalez:
This works fine, I tried the same with the calendar portlet and does not work, when I add the annotation @Reference stops working (does not run the code), but if I remove the annotation @reference (and mvcActionCommand variable) everything works properly.

This is my code:


@Component(
         immediate = true, property = { 
             "javax.portlet.name=com_liferay_calendar_web_portlet_CalendarPortlet",
             "mvc.command.name=updateFormCalendarBooking",
         }, 
         service = MVCActionCommand.class)
 
 public class CustomCalendarMVCActionCommand extends BaseMVCActionCommand {

    @Reference(target = "(&(mvc.command.name=updateFormCalendarBooking)"
            + "(javax.portlet.name=com_liferay_calendar_web_portlet_CalendarPortlet))")
    public void setMvcActionCommand(MVCActionCommand mvcActionCommand) {
        this.mvcActionCommand = mvcActionCommand;
    }
    public MVCActionCommand getMvcActionCommand() {
        return this.mvcActionCommand;
    }
   protected MVCActionCommand mvcActionCommand;

    @Override
    protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
             if (_log.isInfoEnabled()) {
            _log.info("Update Calendar Booking");
        }
        getMvcActionCommand().processAction(actionRequest, actionResponse);    
    }
}
paul shah,修改在6 年前。

RE: Overriding Portal class through modules in liferay 7 is possible or not

New Member 帖子: 4 加入日期: 17-8-24 最近的帖子
it's due to not mentioned service.integer
@Component(
immediate = true,
property = {
"javax.portlet.name=com_liferay_calendar_web_internal_portlet_CalendarPortlet",
"mvc.command.name=updateFormCalendarBooking",
"service.ranking:Integer=1800"
},
service = MVCActionCommand.class
)