Fórum

UI State

Chris Turns, modificado 11 Anos atrás.

UI State

New Member Postagens: 5 Data de Entrada: 06/03/13 Postagens Recentes
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
thumbnail
Juan Gonzalez P, modificado 11 Anos atrás.

RE: UI State

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
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, modificado 11 Anos atrás.

RE: UI State

New Member Postagens: 5 Data de Entrada: 06/03/13 Postagens Recentes
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
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: UI State

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
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, modificado 11 Anos atrás.

RE: UI State

New Member Postagens: 5 Data de Entrada: 06/03/13 Postagens Recentes
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