Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ziggy ©
Where do i move the changed code in the ext?
August 9, 2009 3:56 PM
Answer

Ziggy ©

Rank: Expert

Posts: 293

Join Date: June 8, 2008

Recent Posts

I am a bit confused with the way the ext environment so i hope someone here might be able to clarify a few things. I have setup liferay and it is running fine in the following directory

1
2C:\bin\liferay_home-5.2.3


I would like to modify the login portlet and have found that i need the ext environment to be able to modify it. So i followed the develoepr manual instructions and did the following

- downloaded the liferay source and extracted it to the following directory

1
2C:\ResourceRepository\internal\workarea\liferay\portal


- created a release.HP_ADMINISTRATOR.properties file in the above directoy and added the following line to it
1
2lp.ext.dir=C:/ResourceRepository/internal/workarea/liferay/portal/ext


After doing that the instructions suggested that i ran the following ant targets

1
2ant start
3ant build-ext


I did that and the lp.ext.dir was created successfull.

I then went into the lp.ext.dir and created the file app.server.HP_ADMINISTRATOR.properties and changed the application server properteis as shown here

1
2app.server.parent.dir=app.server.parent.dir=C:/bin/liferay_home-5.2.3
3app.server.tomcat.dir=C:/bin/liferay_home-5.2.3/apache-tomcat-6.0.20


Eventually i ran ant clean deploy and everything worked fine.

Since everything worked fine i thought ok i should try and make a change to the LoginAction.java which is in C:\ResourceRepository\internal\workarea\liferay\portal\portal-impl\src\com\liferay\portlet\login

This is where i am stuck. If i want to change LoginAction.java, what exactly do i do?

I tried to copy the login folder C:\ResourceRepository\internal\workarea\liferay\portal\portal-impl\src\com\liferay\portlet\ to C:\ResourceRepository\internal\workarea\liferay\portal\ext\ext-impl\src\com\ext\portlet\login. I then made a small change to LoginAction.java in C:\ResourceRepository\internal\workarea\liferay\portal\ext\ext-impl\src\com\ext\portlet\login and then ran ant clean deploy but i didnt see any change in the portlet.

I also tried the same for the web files, i.e. copied everything from C:\ResourceRepository\internal\workarea\liferay\portal\portal-impl\src\com\liferay\portlet\login to C:\ResourceRepository\internal\workarea\liferay\portal\ext\ext-web\docroot\html\portlet and run ant clean deploy and i still cant see any changes.

Im sure i am probably missing something very obvious. I guess my question is, if i want to change LoginAction.java, what do i need to do after i have set up the ext environment?
KK rajput
RE: Where do i move the changed code in the ext?
August 9, 2009 11:57 PM
Answer

KK rajput

Rank: Expert

Posts: 266

Join Date: April 10, 2008

Recent Posts

Hi Ziggy,
ext environment is just extension of portal source . So what ever file u have to change in source code u need to make same structure under ext environment . In your case if u want to customize LoginAction.java u have to make same structure under ext/ext-impl .
check your deploy path as well , it should correctly point to the server path.

Thanks
KamalKant
HTH
Minhchau Dang
RE: Where do i move the changed code in the ext?
August 10, 2009 8:39 AM
Answer

Minhchau Dang

LIFERAY STAFF

Rank: Expert

Posts: 349

Join Date: October 22, 2007

Recent Posts

I would pay close attention to where all the files are getting deployed. Chances are, there's something wrong in the configuration so there's nothing getting deployed to the proper folders in the tomcat instance that you're trying to run.

A quick way to verify this is to delete everything in the tomcat common/lib/ext folder. If you have the wrong folders, nothing will wind up in this folder after a clean deploy.

To clarify the above post, currently your custom LoginAction is located here:

ext-impl\src\com\ext\portlet\login

If you're trying to override the LoginAction completely (as opposed to adding a custom LoginPreAction or LoginPostAction), you should be putting the class here:

ext-impl\src\com\liferay\portlet\login

In other words, we're relying on the fact that ext-impl.jar will load before portal-impl.jar due to how Liferay's class loader works, so your ext-impl "com.liferay.portlet.login.LoginAction" will load before the one in portal-impl and override it.
Ziggy ©
RE: Where do i move the changed code in the ext?
August 10, 2009 10:42 AM
Answer

Ziggy ©

Rank: Expert

Posts: 293

Join Date: June 8, 2008

Recent Posts

Minhchau Dang:

To clarify the above post, currently your custom LoginAction is located here:

ext-impl\src\com\ext\portlet\login



This is very interesting because when i ran the command ant build-ext yesterday, the the ant script created this directory.

1
2ext-impl\src\com\ext\portlet\


As an example i think it created a sample portlet in there as well. i.e.

1
2ext-impl\src\com\ext\portlet\reports


So what i did is i just copied the login folder from the liferay src folder and copied it to this directory. i.e.

1
2ext-impl\src\com\ext\portlet\login


I have now moved the login folder to

1
2ext-impl\src\com\liferay\portlet\login


and it now works fine.

Now i think the question is why did the "ant build-ext" script create the ext folder between "com" and "portlet" folders and didnt include the "liferay" folder?

Does this mean that maybe i have set a property wrong when i was setting up the environment thats why it has created the ext folder after the com folder i.e. ext-impl\src\com\ext\reports folder instead of ext-impl\src\com\liferay\reports ? Where is this property likely to be?



If you're trying to override the LoginAction completely (as opposed to adding a custom LoginPreAction or LoginPostAction), you should be putting the class here:
ext-impl\src\com\liferay\portlet\login


I think i am having doubts with overriding the LoginAction now. Do you think it would be better to add a custom LoginPostAction? what i want to do is to forward the user to the public page of the community they belong to. Do you think it woult make sense to not touch LoginAction and provide a LoginPostAction? If so, is the procedure the same? i.e. just add LoginPostAction.java to ext-impl\src\com\liferay\login?


In other words, we're relying on the fact that ext-impl.jar will load before portal-impl.jar due to how Liferay's class loader works, so your ext-impl "com.liferay.portlet.login.LoginAction" will load before the one in portal-impl and override it.


I didnt quite understand the above. COuld you expand on it a bit more.

Thanks
Minhchau Dang
RE: Where do i move the changed code in the ext?
August 10, 2009 1:03 PM
Answer

Minhchau Dang

LIFERAY STAFF

Rank: Expert

Posts: 349

Join Date: October 22, 2007

Recent Posts

Ziggy .:
what i want to do is to forward the user to the public page of the community they belong to. Do you think it woult make sense to not touch LoginAction and provide a LoginPostAction?

It would make more sense, yes. I believe what you want to do is create a custom landing page action (which is one example of a LoginPostAction). A forum search turns up the following example.

Ziggy .:
I didnt quite understand the above. COuld you expand on it a bit more.

You need a basic understanding of the Java class loader, which is usually considered an "advanced topic" in Java. You can read up more about them in this article.

If that makes sense to you, an explanation of why ext-impl is used to override classes in portal-impl (and why it works) has been described previously in this forum post