I've noticed that sometimes liferay loads the content of a portlet using ajax. For example, we've done some heavy duty web content templates and sometimes I can see a loading spinner while rendering the page.
I know about ajaxable and render-weight properties in liferay-portlet.xml, but... how does liferay know whether to render a portlet content using ajax or not? and second question, is it any way to disable this feature for asset publisher and web content display portlets without changing liferay's internal liferay-portlet.xml?
By default ajaxable is set to true.
In order to modify this you can try updating the render-weight and ajaxable attributes using the class PortletPreferences.
Read more here: https://www.liferay.com/community/forums/-/message_boards/message/11904281
Related
I have a problem with refreshing a single Liferay portlet. I wrote a bit of javascript code to refresh a single Liferay portlet every 120s:
function refreshPortlet() {
Liferay.Portlet.refresh("SOME_KEY")
};
setInterval("refreshPortlet()", 120000);
It works fine and the portlet refreshes, but the problem is that content of the portlet does not. I tried to clear the cache of the portlet with WebCachePoolUtil:
function refreshPortlet() {
WebCachePoolUtil.remove("SOME_KEY");
Liferay.Portlet.refresh("SOME_KEY")
};
setInterval("refreshPortlet()", 120000);
But now the function does not execute at all. Any hints?
Thanks in advance,
Stjepko
WebCachePoolUtil is a Java class, thus not available on the JS side. The reason the method is not executing is that it's running into the unavailability of that class.
If you want to execute browser-side code like you did, you'd need to identify where caching is done - e.g. on the browser or on the server. Observe your Developer Tool's network tab and inspect what's going across the wire.
Depending on the portlet that you're trying to refresh - specifically if it's a custom portlet - I'd recommend to implement Ajax explicitly and refresh either from a REST API or through the portlet's serveResource method.
I'm developping a jqm application with spring mobile in the back-end.
Whenever I hit the browser refresh button on my mobile phone the page is completely devastated afterwards. Browsers back-button works properly.
The data are still available due prg pattern (flashAttributes in Spring) after refresh. Only the view is malformed.
Any ideas how to solve this problem?
From jQuery Mobile docs :
The simplest approach when building a jQuery Mobile site is to reference the same set of stylesheets and scripts in the head of every page. If you need to load in specific scripts or styles for a particular page, we recommend binding logic to the pageinit event (details below) to run necessary code when a specific page is created (which can be determined by its id attribute, or a number of other ways). Following this approach will ensure that the code executes if the page is loaded directly or is pulled in and shown via Ajax
So what happens is - in jQuery Mobile, the scripts and styles defined in the head are loaded only once. So, in normal conditions, it works fine, as all the pages will use the scripts loaded from the first page.
But. When you refresh a page in-between, it triggers a page-reload instead of the ajax navigation model thatjqm uses. So all the scripts and styles loaded from the first page will not be included from here on out.
What you need to do is "reference the same set of stylesheets and scripts in the head of every page", so that even if you hit refresh in the middle, the scripts and styles that had been loaded from the head of the first page are loaded again.
I recommend you read the docs from the above link fully to gain a better understanding.
I want to create a modal dialog wizard using spring web flow and dojo.
I searched for embedding the flow in a dialog using embedded mode. But I found very few examples related to this. In these examples, they used JSF dialogs and tiles framework to partially render a form.
Can we do this without using JSF and tiles framework but using jsp and dojo?
Can anyone help me to create a wizard embedded in a dojo dialog using spring web flow?
I wouldn't depend on the dojo framework I believe is no longer supported with webflow. Moreover, webflow wasn't really designed (without hacks) to be embedded inside modal dialogs. It was designed as a simple "flow" navigation from html page to page.
To achieve what you want you'll have to use jquery (or some javascript library) to interact with the current flow via ajax calls to predefined transitions/fragments and manually via javascript take the response html fragments returned by webflow contents and change the contents of your modal dialog box. You could argue this is a "hack" but this is how I achieved what you desire using webflow.
A user asked a similar question a few months ago and i provided a thorough answer explaining how to use webflow + ajax + transitions in dialog boxes.
How to include a pop-up dialog box in subflow
I'm looking for a NodeJS MVC framework that allows rendering partial views on client side using Ajax (without whole page refreshing).
As far as I know, you can declare partial views on server with almost any Framework (Express, Sails...), but this will lead to refresh the whole page even if there's only a small portion of your page that really changes. This problem doesn't exist with a SPA Framework (this one would just load the partial html file in a container via ajax).
I believe Microsoft ASP.NET MVC was able to handle this case, by comparing the previous version of the page with the new requested page, and just returning the portion of the page that really changed. This may be time and CPU-consuming but it just works.
Is any Node MVC Framework managing a similar thing today ? Or is it mandatory to use an SPA Framework when a reactive user interface is required (without any whole page refresh) ?
Thanks in advance !
sails.js! It supports partials as you requested. You don't need to refresh the page, if you send ajax-request or handle the stuff via websockets dynamically.
I want to upload a file using the < s:file > tag, but Struts2 doesn't support Ajax for this functionality, as far as I know. I tried to do it using the Struts2 jquery plugin but it overwrites some jquery functions that i need an can't change right now (like .dialog()).
Is there an alternative way to do it?
There are many jquery based plugins for this purpose.
I am using this library. Its the most simple and elegant plugin, minimal requirements and lots of options.
Here are some other plugins which I considered(my preference was a plugin which doesnt use flash)
This one shows thumbnail before uploading and also overall progress
This one shows remaining time, uploading speed and remaining size
This is how I do it (I'm not using JQuery):
I hide an iframe inside my page. I give it an id (iframe for example) and a name (the same than the id).
I set the attribute "target" on my form to the id of the hidden iframe (then, the response from the server is loaded inside the iframe.
I register an event handler on the iframe to react on the onload event. The handler analyse the response from the server. Alternatively, I sometime just return javascript code from the server in a <script> tag. This code performs action on the client upon success or failure of the intended action.
If you like the idea, you may want to read this article or this one: