Foros de discusión

Portlet with GWT

thumbnail
Jean-Michel Garcia, modificado hace 12 años.

Portlet with GWT

New Member Mensajes: 20 Fecha de incorporación: 4/08/11 Mensajes recientes
Hello everyone,

Im new to this forum, and also new to Liferay community.

I've been developing a GWT / SmartGWT application for a long time now, and I've got the requirement to include it into a Liferay Portlet.

I've successfully manage to include the application into the portlet, and running RPC as well.

But now I'm having some difficulty to understand how Liferay sizes my portlet.

I mean, I would like to know how much "free space" I have to place my portlet (So I can use 100% of the free space, and avoid having scrollbars).

I've read that Liferay, manages the width and height of the portlet (so it can accomodate all its content).

But I need to know the free height so I can set the proper height of my GWT app.

Is there any way to achieve this ?

Thanks in advance.
Cheers. emoticon
thumbnail
David H Nebinger, modificado hace 12 años.

RE: Portlet with GWT

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
There is no way to know what height & width you'd be using.

Users can change their layouts, reorder their portlets, you can maximize and minimize your portlet, etc.

Planning on available size will prove to be very difficult...
thumbnail
Jean-Michel Garcia, modificado hace 12 años.

RE: Portlet with GWT

New Member Mensajes: 20 Fecha de incorporación: 4/08/11 Mensajes recientes
So basically, I need to hardwire my GWT app width and height ?
And Liferay will manage his sizes ?

Thanks for your fast answer.
thumbnail
nicolas saubi, modificado hace 12 años.

RE: Portlet with GWT

Junior Member Mensajes: 43 Fecha de incorporación: 28/10/09 Mensajes recientes
And what about asking javascript to say your gwt the available space, and then get your gwt app to size itself with the javascript informations ?
thumbnail
Jean-Michel Garcia, modificado hace 12 años.

RE: Portlet with GWT

New Member Mensajes: 20 Fecha de incorporación: 4/08/11 Mensajes recientes
nicolas saubi:
And what about asking javascript to say your gwt the available space, and then get your gwt app to size itself with the javascript informations ?


That's what im trying to achieve. I have everything ready, but im lacking of the "available space information"
thumbnail
nicolas saubi, modificado hace 12 años.

RE: Portlet with GWT

Junior Member Mensajes: 43 Fecha de incorporación: 28/10/09 Mensajes recientes
Well if you know the layouts which will be used in your portal you can fetch for your gwt div's parents until you find the div container, and then check for its width and height with jquery or pure javascript offsetWidth and offsetHeight I think
thumbnail
Jean-Michel Garcia, modificado hace 12 años.

RE: Portlet with GWT

New Member Mensajes: 20 Fecha de incorporación: 4/08/11 Mensajes recientes
I did that, but I received the actual width and heigth used by the Portlet.
Not the free space emoticon

I got this mad idea of iterating over all the 1st level DOM div of the page and collect their height.... emoticon
thumbnail
David H Nebinger, modificado hace 12 años.

RE: Portlet with GWT

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Jean-Michel Garcia:
I got this mad idea of iterating over all the 1st level DOM div of the page and collect their height.... emoticon


I got this mad idea that this will fail...

Getting the height at the point the page is rendered will not adjust as other content is added or removed on the page. Liferay itself is powered by a lot of javascript, and the various portlets you're using on the page can also be JS-enabled for changing content.

And if you consider the other layout options (including the floating layout), other div heights may have absolutely no impact on your available 'free space'.

Besides, when rendering a page Liferay will adjust the actual positioning on a page so that the portlets flow around each other naturally.

Relying upon height & width, at least in the portal, is a bad design pattern. You really should try to come up w/ an alternative...

I must add that I've never seen any scrollbars in my portlets regardless of how tall/wide the content got. If you're seeing scrollbars, I'm willing to bet they are artifacts of GWT and not Liferay.
thumbnail
Jean-Michel Garcia, modificado hace 12 años.

RE: Portlet with GWT

New Member Mensajes: 20 Fecha de incorporación: 4/08/11 Mensajes recientes
Thank you David for all this advices.

So, the alternative you're talking about is to fix my width and height in my GWT application ?

Let me explain quickly how my GWT app is designed.

1. a HTML Div with the id "GWTDiv" is added to the page by the .jsp file
2. Within this same .jsp file, I also add my GWTapp (which is a JavaScript file) by using a HTML Script tag
3. When the JavaScript loads, it add the HTML code inside the GWTDiv

The logic I was using until today, was to fill the 100% space of the GWTDiv, so, somewhere, in my main layout is was defining :
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");

The problem is that inside the Liferay, this div has no specified sizes.

So the solution here is to set fixed sizes for my GWT application ?

Thanks in advance.
thumbnail
David H Nebinger, modificado hace 12 años.

RE: Portlet with GWT

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Fixed width is also not the way to go, either. If a user places your portlet in a narrow column layout, your fixed with settings would break the view...

Developing portlets is a different path than developing websites. Being a member of the portal means dropping fixed layouts, fixed widths, and to some extent even styling over to the portal. Your portlet is only a small component of a complete page, and you really shouldn't expect to be able to take over the page that your portlet is dropped on.

When you control the whole site (the theme, the layout, the portlets placed on a given page), you have more authority to implement these kinds of things, but you should still avoid doing it within the portlet itself. In this case you would leverage the theme, layout, and placement to dictate what kind of 'free space' is available, you wouldn't want your portlet mandating that kind of thing.

For the portlet itself, you can dictate certain expectations such as it should not be placed in the narrow column of a layout, but from the UI level you maximize consistency by allowing the portal itself handle styling and placement with your portlet just specifying the content.
thumbnail
Jean-Michel Garcia, modificado hace 12 años.

RE: Portlet with GWT

New Member Mensajes: 20 Fecha de incorporación: 4/08/11 Mensajes recientes
Hi,

So, if I'm not supposed to fix the sizes of my GWTApp, how can I manage my layout ?

I mean, what is the correct way of doing this ?

1. I can't set a fixed width and height
2. I don't know the sizes of the DIV containing my GWTapp

I'm quite lost on this,
please advise.

Thank you a lot.
thumbnail
David H Nebinger, modificado hace 12 años.

RE: Portlet with GWT

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
That's just it, you don't manage your layout, the portal does...

If you need a tabular format, then you build w/ the basic tags and be done with it.

Based upon the theme and layout that a user is using, your table can look one particular way in one theme but completely different in another.

But that's life in the portlet world; you're providing content and structural ques (in the tag layout), but that's it...

Instead of trying to force a layout, focus more on how the content flows, how it adapts to changes. Obviously if you're showing a table with, say, 10 columns, it won't ever display properly in the narrow column of a layout (there's a lot of portlets that have this problem), but it should be able to respond to maximizing and normalizing, moving from the 30/70 layout to the 50/50 layout without becoming unusable. But for all of the portlets that come OOTB with Liferay, you won't see them forcing styling information, they rely on the portal to manage styling and layout so the entire page looks consistent.
tong123123 tong123123, modificado hace 11 años.

RE: Portlet with GWT

New Member Mensajes: 23 Fecha de incorporación: 10/08/12 Mensajes recientes
I have same problem as Jean-Michel Garcia mentioned.
for gwt, at least you must set a size for rootpanel, otherwise nothing will be shown on the portal.
but using percentage, the portlet will not be shown.
So, I can't think any other alternatives except setting fixed width and fixed height for the rootpanel.