Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
krishna kumar
Avoid portal refresh on portlet action or refresh
May 2, 2012 4:46 AM
Answer

krishna kumar

Rank: New Member

Posts: 4

Join Date: March 11, 2012

Recent Posts

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.
Anil T
RE: Avoid portal refresh on portlet action or refresh
May 4, 2012 10:03 AM
Answer

Anil T

Rank: Expert

Posts: 292

Join Date: January 14, 2012

Recent Posts

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
RE: Avoid portal refresh on portlet action or refresh
May 4, 2012 11:30 AM
Answer

Gavin Headen

Rank: New Member

Posts: 18

Join Date: June 1, 2010

Recent Posts

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.

 1<div id="content">
 2  <button onclick="goToPage2()">Go to page 2</button>
 3</div>
 4
 5<script type="text/javascript">
 6  var xyz_urls = new Object;
 7  xyz_urls.render = '<portlet:renderURL windowState="exclusive" />';
 8  xyz_urls.actionFoo = '<portlet:actionURL windowState="exclusive" name="foo" />';
 9  //... and so on as needed
10
11function goToPage2() {
12  jQuery.ajax({
13    url:xyz_urls.render,
14    data:{'page':'next.jsp',
15    type:'post',
16    success:function(res){jQuery('#content').html(res)}
17    });
18  }
19</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.
David H Nebinger
RE: Avoid portal refresh on portlet action or refresh
May 4, 2012 11:36 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11113

Join Date: September 1, 2006

Recent Posts

Gavin Headen:
I'm sure there are many way to do it (possibly better).


Sure is - use Vaadin for your portlets!
Gavin Headen
RE: Avoid portal refresh on portlet action or refresh
May 4, 2012 11:56 AM
Answer

Gavin Headen

Rank: New Member

Posts: 18

Join Date: June 1, 2010

Recent Posts

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.
David H Nebinger
RE: Avoid portal refresh on portlet action or refresh
May 4, 2012 2:17 PM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11113

Join Date: September 1, 2006

Recent Posts

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
RE: Avoid portal refresh on portlet action or refresh
May 4, 2012 8:25 PM
Answer

Gavin Headen

Rank: New Member

Posts: 18

Join Date: June 1, 2010

Recent Posts

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.
David H Nebinger
RE: Avoid portal refresh on portlet action or refresh
May 5, 2012 9:25 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11113

Join Date: September 1, 2006

Recent Posts

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.
Jack Bakker
RE: Avoid portal refresh on portlet action or refresh
May 5, 2012 9:01 PM
Answer

Jack Bakker

Rank: Liferay Master

Posts: 840

Join Date: January 3, 2010

Recent Posts

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.
Jack Bakker
RE: Avoid portal refresh on portlet action or refresh
May 5, 2012 9:26 PM
Answer

Jack Bakker

Rank: Liferay Master

Posts: 840

Join Date: January 3, 2010

Recent Posts

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...