掲示板

Override JspServlet.java class from liferay 7.0.1 GA2 portal code

7年前 に lokesh gorrela によって更新されました。

Override JspServlet.java class from liferay 7.0.1 GA2 portal code

Regular Member 投稿: 173 参加年月日: 16/03/09 最新の投稿
Hi Guys,

I have one requirement i.e, Override JspServlet.java class from liferay 7.0.1 GA2 portal code through modules. See the blow location
D:\Liferay-7-NewSetup\portal\modules\apps\static\portal-osgi-web\portal-osgi-web-servlet-jsp-compiler\src\main\java\com\liferay\portal\osgi\web\servlet\jsp\compiler/jspServlet.java
Any one knows the process about my requirement please give replay.
Thanks
Regards
Lokesh
thumbnail
7年前 に Ray Augé によって更新されました。

RE: Override JspServlet.java class from liferay 7.0.1 GA2 portal code

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
May I ask the use case for needing to extend it? I'm interested to know if there's something we missed.

Thx
7年前 に lokesh gorrela によって更新されました。

RE: Override JspServlet.java class from liferay 7.0.1 GA2 portal code

Regular Member 投稿: 173 参加年月日: 16/03/09 最新の投稿
Hello
Ray Augé

Today your staff resolved one issue i.e https://issues.liferay.com/browse/LPS-66814 after that they are provided one solution link to me https://github.com/migue/liferay-portal/pull/824

But i con't understand how to apply that solution to my portal code. Could you plz tell the process to apply that solution to my portal code.
Thanks
Regards
Lokesh
thumbnail
7年前 に Jamie Sammons によって更新されました。

RE: Override JspServlet.java class from liferay 7.0.1 GA2 portal code

Expert 投稿: 301 参加年月日: 14/09/05 最新の投稿
Hello Lokesh,

I just wrote a blog entry that hopefully addresses what you are trying to do. I even used the ticket you mentioned as an example: https://web.liferay.com/web/jamie.sammons/blog/-/blogs/osgi-module-patching-guide

-Jamie
7年前 に lokesh gorrela によって更新されました。

RE: Override JspServlet.java class from liferay 7.0.1 GA2 portal code

Regular Member 投稿: 173 参加年月日: 16/03/09 最新の投稿
Hello Jamie Sammons
Thanks for your replay

I have one more question

I need to override a "CreateAccountMVCActionCommand" class from my portal code through modules in liferay-7.0.1 GA2. Here provided process of override portal class https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/develop/tutorials/-/knowledge_base/7-0/mvc-actioncommand. I followed this way but i did not get any changes.

see the below steps:
1) I created one new module project with name (create.account)
2)I created one class with the name (CustomCreateAccountMVCActionCommand) in this location "/create.account/src/main/java/com/example/portlet/CustomCreateAccountMVCActionCommand.java"
3)I written code like this in overriden class

package com.example.portlet;

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

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

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

/**
* @author Brian Wing Shun Chan
* @author Amos Fong
* @author Daniel Sanz
* @author Sergio González
* @author Peter Fellwock
*/
@Component(
property = {
"javax.portlet.name=com_example_portlet_CreateAccountmvcportletPortlet", -> here i con't understand which portlet name mentioned
and how to give that name
"mvc.command.name=/login/create_account"
},
service = MVCActionCommand.class
)

public class CustomCreateAccountMVCActionCommand extends BaseMVCActionCommand {
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

}


}

4) I deployed that module and get build success

5)I copied create.account.jar file from this location "D:\liferayupdatedsetup7\OSGI\bundles\osgi\modules\create.account.jar" and placed in this location "D:\liferayupdatedsetup7\bundles\deploy"
6)I tested that module.

Existing class is not overriden by this class.
Here i did any mistake in this process please tell to me.Could you please tell the right process to overide a class from portal code.
Thanks
Regards
Lokesh
thumbnail
7年前 に Jamie Sammons によって更新されました。

RE: Override JspServlet.java class from liferay 7.0.1 GA2 portal code

Expert 投稿: 301 参加年月日: 14/09/05 最新の投稿
Hi Lokesh,

You may want to take a look at creating a Service Wrapper. That maybe what you are looking for. There is an example in the Blade project here: https://github.com/liferay/liferay-blade-samples/tree/master/liferay-gradle/blade.service.hook.user

Let me know if that helps or not.

-Jamie
7年前 に lokesh gorrela によって更新されました。

Overriden "CreateAccountMVCActionCommand.java" class through modules in 7

Regular Member 投稿: 173 参加年月日: 16/03/09 最新の投稿
Hi Jamie Sammons

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
7年前 に sedki jdaida によって更新されました。

RE: Overriden "CreateAccountMVCActionCommand.java" class through modules in

Junior Member 投稿: 25 参加年月日: 16/09/08 最新の投稿
Hi lokesh gorrela ;
i have the same problem i clone the project "blade.hook.jsp" and i add new package in witch i put the source code of CreateAccountMVCActionCommand.java and i make some change in this class like add instruction "system.out.println("hi ");"
and i generate the jar and putting them into folder deploy of liferay .

the problem that nothing changed and the message of "hi " is not showing in console.

-------->>>> if you find a solution help me and thanks for advance.
thumbnail
7年前 に Gaurav Jain によって更新されました。

RE: Overriden "CreateAccountMVCActionCommand.java" class through modules in

Junior Member 投稿: 85 参加年月日: 16/07/12 最新の投稿
Hi sedki jdaida,

You need to create a separate module for overriding a class. Such overriding can not be kept inside a fragment module. Because fragment just gets attached to a host. It will not override any class.

Rest are same you had asked on a this thread. Check its reply.

Regards,
Gaurav
7年前 に Brian Szucs によって更新されました。

RE: Overriden "CreateAccountMVCActionCommand.java" class through modules in

New Member 投稿: 6 参加年月日: 16/12/12 最新の投稿
Why would this NOT be in the tutorial of How to Override an MVCCommand??!!!??

This is definitely a BIG rule that is not even touched on in https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/overriding-mvc-commands

Can someone PLEASE add THIS HUGE RULE to the above page. The following is not correct;

And that, as they say, is that. Even if you don’t own the source code of an application, you can override its MVC commands just by knowing the value of two of its component properties: javax.portlet.name, and mvc.command.name.