Forums

Home » Liferay IDE » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Biresh Choudhury
JSP hooks issue in Eclipse IDE
August 29, 2011 4:54 AM
Answer

Biresh Choudhury

Rank: Junior Member

Posts: 29

Join Date: December 8, 2010

Recent Posts

Hi,

I am using Liferay6 with Eclipse IDE for my development environment. Have issue related to Hooks development for JSP.


My aim is to edit the shopping portlet. Have followed the below steps and still facing some problem.

1) Created a hooks project in liferay.
2) Added the line "<custom-jsp-dir>/custom_jsps</custom-jsp-dir>" inside liferay-hook.jsp
3) Copied the file name "edit_category.jsp" from liferay's root folder into META-INF/custom_jsps/html/portlet/shopping.(As it's the original path of the file inside Liferay root)

Now the problem I am facing is related to some error like variables used in the jsp are not being resolved to its type since it's not able to recognize the file init.jsp from the path <%@ include file="/html/portlet/shopping/init.jsp" %>.
My doubt is do I need to include all the files for the concerned portlet inorder to override a single file or am I missing out on some important steps like configuring something else.

Regards,
Biresh Choudhury
David H Nebinger
RE: JSP hooks issue in Eclipse IDE
August 29, 2011 10:26 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7250

Join Date: September 1, 2006

Recent Posts

Hi, Biresh, I'm sure you'll hear from the Liferay IDE guy (he's really great about monitoring and responding to IDE issues), but I can confirm that this is sometimes an issue. For the most part I end up ignoring these kinds of errors since I know the code is working in the canned Liferay, it should work deployed w/o mods. Then I just take extra care during editing to make sure I don't introduce errors on my own.

It's definitely a pain, and there's probably a better way to get around this, I just haven't tried to track it down yet emoticon
Dave Weitzel
RE: JSP hooks issue in Eclipse IDE
August 29, 2011 6:18 PM
Answer

Dave Weitzel

Rank: Regular Member

Posts: 186

Join Date: November 18, 2009

Recent Posts

no you don't need to include th e"included" pages such as init.jsp unless you are likely to be adding common classes in your mods on more than one page in that portlet (ecommerce in this case).

when it gets deployed the new jsp actually gets put into the live webapps/ROOT/docroot/html/portlet/ecommerce with the old file getting renamed with a .portlet.jsp so all the other files are still there in their same related places - such as init.jsp.

If there are other errors in your jsp they will become apparent in the console log if your test server is running from eclipse as well.
Dave
Gregory Amerson
RE: JSP hooks issue in Eclipse IDE
August 29, 2011 11:05 PM
Answer

Gregory Amerson

LIFERAY STAFF

Rank: Liferay Master

Posts: 935

Join Date: February 16, 2010

Recent Posts

Thanks David and Dave for responding, I really appreciate you guys jumping in to help other IDE users.

As they said you can safely ignore the errors in the JSP. They are showing up because the Eclipse JSP validator does not know how to find the required contextual JSP files to make that particular JSP build without errors. I have an enhancement ticket for modifying the Eclipse JSP model to fix this situation but I have not implemented it yet because I believe the performance/memory trade off is not worth developer's time.

The quick solution is to modify the JSP validator's exclusion filters to tell it not to validate any custom_jsp files. I'll post back to this forum with a link to a page that describes the process of how to do that, but I need to create that page first emoticon.
Biresh Choudhury
RE: JSP hooks issue in Eclipse IDE
August 29, 2011 11:09 PM
Answer

Biresh Choudhury

Rank: Junior Member

Posts: 29

Join Date: December 8, 2010

Recent Posts

Thanks David, Dave and Gregory for response.

Will try and implement the alternate solution mentioned above.

Regards,
Biresh
Gregory Amerson
RE: JSP hooks issue in Eclipse IDE
August 29, 2011 11:59 PM
Answer

Gregory Amerson

LIFERAY STAFF

Rank: Liferay Master

Posts: 935

Join Date: February 16, 2010

Recent Posts

Here is the new section on the Liferay IDE wiki where I posted the how-to for disabling the JSP syntax validation for just specifically the custom_jsps folder.

http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+IDE+Developing+Liferay+Hooks
Biresh Choudhury
RE: JSP hooks issue in Eclipse IDE
August 30, 2011 2:52 AM
Answer

Biresh Choudhury

Rank: Junior Member

Posts: 29

Join Date: December 8, 2010

Recent Posts

Thanks Gregory for the solution.

I followed steps mentioned in that link as below:
* Right click the hook project, go to Properties
* Select Validation page
* Check the box "Enable project specific settings"
* In the row "JSP Syntax Validator" click the "..." button
* In the dialog click the "Add exclude group" button
* Select the "Exclude group" node and click the "Add Rule..." button
* Select the filter type, "Folder or File name"
* Click Browse for folder and select the folder that stores the custom jsps
* Click Finish, then OK, then OK
* Right click the custom_jsps folder and select "Validate"


But still facing the error as of now:
"Fragment "/html/portlet/shopping/init.jsp" was not found at expected path {Project Name}/docroot/html/portlet/shopping/init.jsp".

It has been turn around for removing almost 90% of the errors coming earlier but this is one issue I am not able to resolve since there is a include statement as <%@ include file="/html/portlet/shopping/init.jsp" %> inside the file name edit_category.jsp which is causing the problem.

Regards,
Biresh
Biresh Choudhury
RE: JSP hooks issue in Eclipse IDE
August 30, 2011 5:01 AM
Answer

Biresh Choudhury

Rank: Junior Member

Posts: 29

Join Date: December 8, 2010

Recent Posts

It's working now.
Was trying to select the folder path instead of the file to be excluded.

Regards,
Biresh
Gregory Amerson
RE: JSP hooks issue in Eclipse IDE
September 1, 2011 5:51 PM
Answer

Gregory Amerson

LIFERAY STAFF

Rank: Liferay Master

Posts: 935

Join Date: February 16, 2010

Recent Posts

Glad you got it working. In the latest version of the IDE (1.3.1) there is a option on the wizard for custom_jsps in hooks that will disable jsp validation for the entire custom_jsps folder. So hopefully in the future for new hook projects that customize JSPs you wont have to worry about re-setting that preference.
David H Nebinger
RE: JSP hooks issue in Eclipse IDE
September 1, 2011 7:23 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7250

Join Date: September 1, 2006

Recent Posts

You know, we only do this as a shortcut to remove invalid errors from the JSPs, but I figure most of us would rather have the ability to define an alternate home for the JSPs. So I can say "Hey, treat everything in this custom_jsp folder as though the actual root was $CATALINA_HOME/webapps/ROOT/html" or some such thing.

Obviously we don't want false errors showing up in Eclipse, but what we'd really like is to be able to verify the JSPs so we catch actual errors...
Gregory Amerson
RE: JSP hooks issue in Eclipse IDE
September 1, 2011 11:31 PM
Answer

Gregory Amerson

LIFERAY STAFF

Rank: Liferay Master

Posts: 935

Join Date: February 16, 2010

Recent Posts

Your exactly right David, actually have the JSP fully realized would be Ideal. I've done some research and there is a way to configure an Eclipse project so that it will "understand" more of the hook JSPs context. But this comes with a tremendous performance penalty. Basically you have to compile nearly every one of the portal JSPs just to full "validate" or "realize" the single hook JSP. Fully compiling the portal JSP source takes a very, very long time, especially if its the first time. Not only time but gobbs of memory. I'm pretty convinced that even if we could get this working right, most users would disable it because of the performance penalty.

I'll keep looking and investigating ways to make this work but for now I recommend full disabling of validation.
David H Nebinger
RE: JSP hooks issue in Eclipse IDE
September 2, 2011 5:09 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7250

Join Date: September 1, 2006

Recent Posts

I don't know about totally disabling; I'd probably only enable when I was going to be making significant changes to the JSP where I didn't want to just trust that me or one of my developers just did it all right...
Łukasz Pogorzelski
RE: JSP hooks issue in Eclipse IDE
July 9, 2012 1:11 AM
Answer

Łukasz Pogorzelski

Rank: New Member

Posts: 6

Join Date: April 12, 2012

Recent Posts

I know that last answer was almost a year ago, but maybe my solution will help someone.

I realized that in following way:
1. I copied jsp which I would like to edit to my hook.
2. If that jsp include another jsp which I wanted to edit, then in the first one I changed include tag URI from context-relative path (starts with /) to page relative path.
3. If my hooked file includes jsp that I don't want to edit, then I simply copy it to folder structure, which is identical to liferay.
4. Additionally I created web.xml and configured required taglibs. Conteiner ignores the same taglibs.

Advantages:
- full JSP validation,
- edited and not edited JSP files are isolated (different folders).

Drawbacks:
- because additional files (not edited) were copied to the hook, these files will not be updated if Liferay Team change them,
- similar to the above, copied taglibs can become obsolete.

In the future may be considered to change build process to exclude folders with additional (not edited) jsps and taglibs.