How can I disable SennaJS/SPA in Liferay 7? - liferay

Liferay 7 uses SennaJS as its Single Page Application engine in order to load and replace certain parts of the portal page during form submission and navigation. Occasionally this feature interferes with my use case, so how can I disable it?

If you want to disable the XHR GET navigation performed by SennaJS or its handling of form submissions, you can try one of the following:
If you want to disable SPA for only certain forms or links, you can add the data-senna-off="true" attribute to those <form> or <a> tags.
If you want to disable SPA for only one portlet, you can add <single-page-application>false</single-page-application> to the <portlet> section of your liferay-portlet.xml (see the DTD for the expected order of liferay-portlet.xml elements).
If you want to disable SPA for only one OSGi module portlet, you can add "com.liferay.portlet.single-page-application=false" to your portlet metadata.
If you want to disable SPA on a portal wide basis, you can add javascript.single.page.application.enabled=false to your portal-ext.properties file.

Related

Liferay, include one web content in another web content

Let's say I have web content, which is a modal dialog. Now I want to be able to reuse this content in several other web contents. What is the easiest way to achieve this without copy modal code to each web content? JavaScript is allowed.
Web content is a modal dialog? I don't understand the usecase, thus it's hard to give proper sample code.
If you're aware of the ID of the other webcontent that you want to use, you can retrieve this content through the API, e.g. by writing structures/templates. Templates are able to access the API and render other articles. Some of the API is hidden from templates by default, but you can revert this - look for "restricted" in portal.properties
The WCM API is named after its formal name "Journal*", check the API, e.g. JournalArticleService.

How to render a portlet without rendering whole page. Liferay

I have two portlets at the same page. Portlet A does a very quick task, and Portlet B does a very slow task. Portlet B reads a parameter from A. If I make a change on A (with RenderURL), Liferay renders whole page (including slow Portlet B). How can I say Liferay to render only Portlet A and not Portlet B?
the renderURL will always point to the whole page. If you go "manual", e.g. without other framework's help, you'll need to utilize the resourceURL and refresh your portlet's content with Ajax.
Another option is to declare your slow portlet B as asynchronous ("ajaxable") and cache the output so that you don't have to constantly do expensive render operations. The ajaxable option is available in liferay-portlet.xml and is documented for that file. The RSS portlet (Liferay-OOTB) is configured like this as it might take a while until this portlet has collected all of its RSS feeds and can render. This might be a good blueprint for your required changes.

Liferay Login page JSP name

Once the Liferay Start Up page is displayed , there is a Sign-in Hyperlink , and once we click on that Sign-in Hyperlink it will take us to the Page where it will display the actual Login page.
What is the name of that JSP page (The Actual page with Email, Password and the Submit Button)?
I am using Liferay 6.1.
If you are thinking of modifying any JSP which is already there in liferay, consider modifying using hooks so that you dont have to restart liferay server since hooks are hot-deployable and easy to manage.
To learn more about hooks follow this link. http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/hoo-4
The login link call login portlet. But you can change default login page, add to portal-ext.properties auth.login.url=mypageurl.
If what you want to do in your new login page is to add new fields then using Liferay custom fields will be the way go. You can define custom fields for User and make them editable and then add the into the login.jsp file using this tag
<div class="exp-ctrl-holder">
<liferay-ui:custom-attribute
className="<%=User.class.getName()%>"
classPK="<%=0%>"
editable="<%=true%>"
label="<%=true%>"
name="FieldName" />
</div>
This edit should be done using a hook
or
if you want to add additional logic to the login action then using the Liferay Extension environment is the best solution.

Liferay 6: How to custom display Portals On Successful login

I am using Liferay 6 for development .
I have developed a Custom Login Portlet using Struts2 .
I am able to display my Custom Login page , On click of the Submit Button after validating the credentials aganist our MYSQL Databse , please tell me how can i display my 4 other Custom Portlets on entering valid credentials ??
please guide me what is the concept i should refer for this in liferay
( I am using Liferay 6 for development )
Okay, the way I would suggest you do this is by:
adding the 4 other portlets to your Custom Login page (or add a redirect on successful login, and them to the page you redirect to)
Set the permissions of your Custom Portlets to be viewable by only authenticated users. This can be done by removing Guest "View" permissions. This way a non-authenticated user or "Guest" won't see your portlets when the go to the page.
Does this answer your question?
~~ EDIT IN RESPONSE TO COMMENT ~~
Okay, so if you're using Struts, instead of redirecting to a JSP file, you want to redirect to a URL instead. So instead of /view/result.jsp it should be something like http://yoursite.com/page_with_4_portlets_on_it or just a relative URL /page_with_4_portlets_on_it (if the two pages are on the same Navigation level.
HOWEVER:
If you're new to Liferay then I would strongly suggest you use Liferay's inbuilt Portlet architecture using their MVCPortlet class. This will handle all the mappings, and workings that you have to manually write for using Struts. Then you can implement a doPost() method and do a ActionResponse.sendRedirect("/page_with_4_portlets_on_it");
Then this means that when your form action completes Liferay will redirect the user to the page you've specified.
The best place to get started with Liferay 6 portlets, the Liferay way is here.

How can I make Liferay login portlet redirect to maximized version to display validation errors?

I've got a theme which has a login portlet embedded in the header and I dont wish for validation messages to appear on this login portlet, instead I want Liferay to redirect to the maximized version of the login portlet with the validation errors.
Is there any easy way to do this through the Velocity template files?
The best workaround I can come up with is to hardcode a HTML form which posts to the login struts action which seems to show validation errors on a maximized loging portlet
Thank you
I don't believe Liferay 6.0 has the capability to overwrite portlet code using a VM. It is, however, a new feature in the upcoming 6.1 release.
But if you're tied into Liferay 6.0, you may create a hook plugin to tackle this problem.
Create a hook plugin.
In your hook.xml define:
<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>
In copy the original login.jsp from Liferay Portal to /META-INF/custom_jsps/html/portlet/login.jsp.
You'll want to modify the form action's URL to have window state maximized. You can do so by adding the windowState attribute to the tag lib that generates the URL. For Example:
<portlet:actionURL windowState="<%= LiferayWindowState.MAXIMIZED.toString() %>" />
After deploying this hook plugin, the logins should go to a maximized state unless redirected by a successful login.

Resources