Fórum

Avoid portal refresh on portlet action or refresh

krishna kumar, modificado 11 Anos atrás.

Avoid portal refresh on portlet action or refresh

New Member Postagens: 4 Data de Entrada: 12/03/12 Postagens Recentes
Hi all,

We have created our own custom portlet with two pages(first and next.jsp).When we are performing button action in firstpage it has to go to nextpage.it is working fine.but the problem is whenever action is being performed on first.jsp the whole portal page is getting refreshed.when the page is getting refreshed it is affecting the other portlets in the same page.

Liferay has any default setting to stop portal page refreshing

please provide solution for this.
thumbnail
Anil T, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

Expert Postagens: 313 Data de Entrada: 14/01/12 Postagens Recentes
Hi krishna,

I think you can add an ajax call to your button action in the first.jsp.So you can goto your next.jsp. If you want to refresh only your custom portlet then you can use ajax refresh.It will refresh only your portlet not portal page.
you can also refer below link

http://www.liferay.com/community/wiki/-/wiki/1071674/AJAX/maximized
Gavin Headen, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

New Member Postagens: 18 Data de Entrada: 01/06/10 Postagens Recentes
Yes, AJAX would be the way to go. We do this heavily in our custom portlets.

In first.jsp you could put something like this...
We have a huge investment into jQuery, so even though we have moved to LR6 we still are using jQuery for our custom portlets.

<div id="content">
  <button onclick="goToPage2()">Go to page 2</button>
</div>

<script type="text/javascript">
  var xyz_urls = new Object;
  xyz_urls.render = '<portlet:renderURL windowState="exclusive" />';
  xyz_urls.actionFoo = '<portlet:actionURL windowState="exclusive" name="foo" />';
  //... and so on as needed

function goToPage2() {
  jQuery.ajax({
    url:xyz_urls.render,
    data:{'page':'next.jsp',
    type:'post',
    success:function(res){jQuery('#content').html(res)}
    });
  }
</script>


On the server side in the doView of the Dispatcher you will have to look at the "page" request variable and call the JSP you desire there.

I'm sure there are many way to do it (possibly better), but this is a simple example. It's not exactly how we are handling it, but it gives you an idea of the kind of logic you would want.
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
Gavin Headen:
I'm sure there are many way to do it (possibly better).


Sure is - use Vaadin for your portlets!
Gavin Headen, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

New Member Postagens: 18 Data de Entrada: 01/06/10 Postagens Recentes
I don't think I would consider Vaadin better in this use case at all.

Yes, it may make good use of AJAX, but it's a little silly to jump into an entirely new "framework" just for the benefit of some simplified AJAX.

AJAX is just JavaScript and for most cases rather simple to implement especially if you are using a library like AUI or jQuery.

Vaadin is an more of a portlet development strategy, not simply an AJAX solution.

It may be a direction the OP is interested in, but if you are going to just throw it out there it'd be nice to see some support as to why it is a good choice?

I would be interested in seeing that.
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
Well, it was tongue-in-cheek when I posted it, but we're actually using vaadin for all of our portlet development now:

1. It is java-only coding, so we don't have to worry about jsp, tag libraries, javascript libraries, etc.
2. It handles the whole action/render stuff transparently, so it takes that whole aspect off the radar.
3. It has a 'swing-like' feel to it, so swing developers can switch over to Vaadin w/o much difficulty.
4. It's integrated into Liferay already (although the version is dated), so you're not trying to add something new into the portal.
5. Because it's based upon the GWT, most of the work is being done in the user's browser so the portlets really feel like responsive applications.
6. Also because it's based upon the GWT, it does everything with AJAX so the complexities of dealing w/ ajax for partial page updates, etc., are handled for you.

So far, I've only encountered two downsides:

1. No native Spring integration. There's ways to get to the spring context in a Vaadin application, but they all feel like hacks to me.
2. Some Vaadin components do not resize correctly within the portal page. With each release this seems to get better, but they're still not all the way there.
Gavin Headen, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

New Member Postagens: 18 Data de Entrada: 01/06/10 Postagens Recentes
Thanks for the reply. Quite informative.

In our case we have very specific (and often complex) designs for our front end that we need to follow related to branding and what not.
For that reason, I'm not sure it would even be a direction we would consider, but it is nice to know it's out there.

Kind of getting off topic now, but thanks for the info.
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
Gavin Headen:
Thanks for the reply. Quite informative.

In our case we have very specific (and often complex) designs for our front end that we need to follow related to branding and what not.
For that reason, I'm not sure it would even be a direction we would consider, but it is nice to know it's out there.

Kind of getting off topic now, but thanks for the info.


Actually Vaadin can bind it's components to an HTML file template, so you can lay out your stuff in an html template then bind the vaadin components to it. Allows you to bridge your way into Vaadin and to leverage complicated layouts for Vaadin usage.
thumbnail
Jack Bakker, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

Liferay Master Postagens: 978 Data de Entrada: 03/01/10 Postagens Recentes
Yup. Many AJAX riddles are solved/avoided/canBeIgnored by just using Vaadin. Sure, new portlet framework to learn but that is certainly less time consuming than trying to solve that already solved.
thumbnail
Jack Bakker, modificado 11 Anos atrás.

RE: Avoid portal refresh on portlet action or refresh

Liferay Master Postagens: 978 Data de Entrada: 03/01/10 Postagens Recentes
going further off supposed thread topic I would add that Vaadin challenges include

- themes/css across Liferay and Vaadin
- data-binding through service-builder built services
- adaptive layouts
- when to build one big portlet or instead use Liferay for links to multiple portlets perhaps with Vaadin-IPC

above said, yup, Vaadin very cool ; I only heard of Vaadin last May 2011 at the Virginia ECS and have since dived into it including hiring a Vaadin developer ; need to find more...