Fórum

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

lokesh gorrela, modificado 7 Anos atrás.

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

Regular Member Postagens: 173 Data de Entrada: 09/03/16 Postagens Recentes
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, modificado 7 Anos atrás.

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

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Which class?
lokesh gorrela, modificado 7 Anos atrás.

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

Regular Member Postagens: 173 Data de Entrada: 09/03/16 Postagens Recentes
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, modificado 7 Anos atrás.

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

Regular Member Postagens: 173 Data de Entrada: 09/03/16 Postagens Recentes
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, modificado 7 Anos atrás.

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

New Member Postagens: 9 Data de Entrada: 03/03/11 Postagens Recentes
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, modificado 7 Anos atrás.

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

Regular Member Postagens: 211 Data de Entrada: 18/10/11 Postagens Recentes
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, modificado 7 Anos atrás.

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

New Member Postagens: 11 Data de Entrada: 09/03/17 Postagens Recentes
I have the same issue

https://web.liferay.com/pt/community/forums/-/message_boards/message/88197849
Daniele Zirpoli, modificado 6 Anos atrás.

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

New Member Postagens: 2 Data de Entrada: 12/07/17 Postagens Recentes
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, modificado 6 Anos atrás.

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

New Member Postagens: 4 Data de Entrada: 24/08/17 Postagens Recentes
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
)