Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Chris T
UI State
March 6, 2013 1:06 AM
Answer

Chris T

Rank: New Member

Posts: 5

Join Date: March 6, 2013

Recent Posts

Folks,

The company I work for is about to embark on creating a suite of feature rich web applications deployed within Liferay. Assuming each page represents an application, how do you maintain UI state when navigating between pages (i.e. full page refreshes)?

Obviously I can cache data on the server within the session, but what about things such as the current scroll position or any text that has been entered in any inputs? I don't want to fire off AJAX requests as a result of each user action for performance reasons. I thought cookies could be an option, but I would need to manually write onChange routines for each input field in the page which would be time consuming and error prone.

Is there a standard for doing this, or perhaps an already developed library? Am I asking too much?

I'm new to portlet development, so forgive me is this is a silly question. I've done some Googling and searching within the forum, but I've not found any concrete answers.

Thanks,

Chris
Juan Gonzalez
RE: UI State
March 6, 2013 1:45 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2849

Join Date: October 28, 2008

Recent Posts

Guess you want JSF portlets, and @ViewScope beans. You can even use conversation beans, but I am not sure if this is available as JSF portlet in Liferay.
Chris T
RE: UI State
March 6, 2013 2:07 AM
Answer

Chris T

Rank: New Member

Posts: 5

Join Date: March 6, 2013

Recent Posts

Thanks for your quick response.

@ViewScope beans won't work for what we're going as we're navigating to a different page, then pack to the original. e.g. We have a page representing a forum and a page representing a calendar and the end user is navigating between both.

I've not used conversation beans before, but from a quick read, it doesn't sound as though it'll do what we need. The following link says it's for things like a Wizard where there is a definite start and end. We're developing multiple applications inside of a portal which will be extended in the future and there is no definite start and end points.

http://javaevangelist.blogspot.co.uk/2012/07/jsf-tip-of-day-viewscoped-and.html

Chris
Neil Griffin
RE: UI State
March 6, 2013 9:03 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2350

Join Date: July 26, 2005

Recent Posts

For "current scroll position", I would recommend that you persistently store data in PortletPreferences with the user submits a form, or via Ajax. That will survive full page navigations and redirects.

For or "any text that has been entered in any inputs", that sounds to me like model data that should be saved to the database?
Chris T
RE: UI State
March 6, 2013 1:31 PM
Answer

Chris T

Rank: New Member

Posts: 5

Join Date: March 6, 2013

Recent Posts

We currently have a home grown 'portal' which just loads each application into an iframe and toggles whether they are visible without any full page reloads. So, if you're in application A and are currently doing some sort of data entry, switching to application B will not lose any state in application A (i.e. like a normal desktop application). All text, selected items, scroll positions of grids etc will remain as they were. This is the sort of thing I'm trying to re-create using portlets within Liferay.

I was hoping I wouldn't have to grab the state of each field/component on a page manually, but by the sounds of it I will. Current thinking is that I'll just do this onbeforeunload and store it in a cookie - I can but give it a go!

Thanks for your responses though guys.

Chris