RE: Liferay DXP - Core JSP Customization

thumbnail
Gnaniyar Zubair, modified 5 Years ago. Liferay Master Posts: 724 Join Date: 12/19/07 Recent Posts
Liferay customization has different  ways to override the core jsps.  As per the Liferay recommendations,  they are suggesting to use these 2 options as a best practice.
  • Dynamic includes
  • Portlet filters
 - Dynamic includes options is dynamically including the content in the core jsp in the place of  pre or post of dynamic-include tag inside the jsp.  
   We cannot use this option if core jsp doesn't have this tag  and we cannot customize the entire core jsp as per our convenient.  we have a requirement to add more html attributes -  complex   validations  and advance script ..etc. 

-  Portlet filters is also doing almost same but rendering the content before rendering the jsp. 

But OSGI fragmentation host would be a best approach because it has a control of complete jsp, we can play with whatever we need to achieve. ( Developers know the pain of the client requirement emoticon  ) . 

  It has only one limitation that if any upgrade is happened from Liferay in host module, we should update  ( rework) in fragmentation jsp also.  Other than this, i dont feel any complexity on this. 

what is your view on this? 
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
AFAIK the core JSPs can still be overridden using a JSP bag implementation.

The two recommendations from Liferay stem from the basic understanding of how fragile JSP overrides can be when applying minor (i.e. 7.1 GA1 to 7.1 GA2) or major (i.e. 7.1 to 7.2) upgrades.

Each overridden JSP has to be reviewed to ensure that changes made by the Liferay version get echoed into the overrides, otherwise you break functionality, introduce bugs, etc.

So the Liferay guidance is meant to help curb developers away from the fragile JSP override approach towards a more "upgrade friendly" one.
thumbnail
Gnaniyar Zubair, modified 5 Years ago. Liferay Master Posts: 724 Join Date: 12/19/07 Recent Posts
Yes  , can be overridden through JSP bag implementation also  which is a bad practice as per Liferay recommendation. But here  we need to check the  empty  "-ext.jsp" of core jsps then only we can override.

BTW, Dynamic Tags and Portlet filters approaches are  definitely a upgrade friendly, But not a developer / client friendly. 

For example, there is a requirement to add the Google RE-Captcha  / OTP  implementation for the Login page of liferay which has more client side validation and complex business logic..etc, which we need to customize core login.jsp from com.liferay.login.web bundle. 

Do you think above best approaches (Dynamic tags / portlet filter ) will be sufficient for this requirement other than considering only upgrade friendly?
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
The answer to the question really depends upon what you think you are getting...

If you see Liferay (the thing) as a platform, not a product, you will likely see these options as too limiting. As a platform for building custom solutions, it may be necessary to explicitly override, extend or remove pieces to implement the vision.

Liferay (the company), however, is not selling or giving a way a platform, they are selling and giving away a product. And just like any other product, there's a "void warrantee if opened" concept, but this message has not always been broadcast or received correctly every time.

Therein lies the rub - if you treat Liferay (the thing) as a platform, you are inherently taking on the responsibilities of the voided warrantee concept.  It's why Liferay support will not help with any custom code, especially customizations. Support will often try to reproduce issues in a Vanilla Liferay instance to try to determine if a reported problem is a Product issue or a Customization issue; Product issues they can help with, but Customization issues they can't.

That's why their recommendations exist. They provide approved ways for you to extend and customize the product without violating the "void warrantee if opened" clause, to stay within the boundaries for supportability.

And just like any product that has the same kind of clause such as your cell phone, they document approved ways to customize and use the product, but they certainly aren't going to tell you how to open the cover and make changes to the internals and violate the "warrantee" in the process. These kinds of options may be covered in personal or external documentation (probably some of my blogs fall into this area), but they will not make it into the product documentation.
thumbnail
Gnaniyar Zubair, modified 5 Years ago. Liferay Master Posts: 724 Join Date: 12/19/07 Recent Posts
Thanks for your time for this detailed explanation.  You have a valid point from Liferay Platform. I have a valid point from customer platform.  Though Liferay upgrades many things in further versions, customer doesn't need them until they require that functionality / new upgrade features. 
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Gnaniyar Zubair:

Thanks for your time for this detailed explanation.  You have a valid point from Liferay Platform. I have a valid point from customer platform.  Though Liferay upgrades many things in further versions, customer doesn't need them until they require that functionality / new upgrade features. 
If you add security updates to that list, that'll make it more obvious that you want to optimize for ease of maintenance, not for ease of getting things done once and forever without looking into the future much.
One option, if you really modify JSPs is to introduce custom "dynamic includes" (because Liferay itself only has very few of them built in). They're easy to locate in your edited JSP, thus should be relatively easy to port forward. Then implement the dynamic include in a proper plugin. This is easier to maintain than adding dozens of lines to a JSP file and doing 3-way-merges on every update.