From 8be9a5fc2236f0f5fb45db0b5de9d25b391b2ce8 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Mon, 18 Jun 2007 11:26:36 +0000 Subject: [PATCH] Fix for http://issues.alfresco.com/browse/AWC-1280 and UBS issue with refreshing Task list dashlets in MyAlfresco page when returning from command servlet. Added new attribute to UIRichList component "refreshOnBind" which if set true forces the component to always get new data during the render phase. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6002 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../app/servlet/ExternalAccessServlet.java | 10 ---- .../ui/common/component/data/UIRichList.java | 57 +++++++++++++++---- .../web/ui/common/tag/data/RichListTag.java | 15 +++++ source/web/WEB-INF/alfresco.tld | 6 ++ .../workflow/pooled-tasks-todo-dashlet.jsp | 2 +- .../web/jsp/workflow/tasks-active-dashlet.jsp | 2 +- .../jsp/workflow/tasks-completed-dashlet.jsp | 2 +- .../web/jsp/workflow/tasks-todo-dashlet.jsp | 2 +- 8 files changed, 70 insertions(+), 26 deletions(-) diff --git a/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java b/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java index 5fc775e242..7f60d45f54 100644 --- a/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java +++ b/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java @@ -28,14 +28,8 @@ import java.io.IOException; import java.text.MessageFormat; import java.util.StringTokenizer; -import javax.faces.FactoryFinder; import javax.faces.application.NavigationHandler; -import javax.faces.application.ViewHandler; -import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; -import javax.faces.context.FacesContextFactory; -import javax.faces.lifecycle.Lifecycle; -import javax.faces.lifecycle.LifecycleFactory; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -259,10 +253,6 @@ public class ExternalAccessServlet extends BaseServlet // perform the appropriate JSF navigation outcome NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler(); navigationHandler.handleNavigation(fc, null, outcome); - LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); - Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); - lifecycle.render(fc); - return; } else if (OUTCOME_DIALOG.equals(outcome) || OUTCOME_WIZARD.equals(outcome)) { diff --git a/source/java/org/alfresco/web/ui/common/component/data/UIRichList.java b/source/java/org/alfresco/web/ui/common/component/data/UIRichList.java index afe12eb8fe..95d92cad36 100644 --- a/source/java/org/alfresco/web/ui/common/component/data/UIRichList.java +++ b/source/java/org/alfresco/web/ui/common/component/data/UIRichList.java @@ -114,6 +114,7 @@ public class UIRichList extends UIComponentBase implements IDataContainer this.pageSize = ((Integer)values[7]).intValue(); this.initialSortColumn = (String)values[8]; this.initialSortDescending = ((Boolean)values[9]).booleanValue(); + this.refreshOnBind = ((Boolean)values[10]).booleanValue(); } /** @@ -121,18 +122,19 @@ public class UIRichList extends UIComponentBase implements IDataContainer */ public Object saveState(FacesContext context) { - Object values[] = new Object[10]; - // standard component attributes are saved by the super class - values[0] = super.saveState(context); - values[1] = Integer.valueOf(this.currentPage); - values[2] = this.sortColumn; - values[3] = (this.sortDescending ? Boolean.TRUE : Boolean.FALSE); - values[4] = this.value; - values[5] = this.dataModel; - values[6] = this.viewMode; - values[7] = Integer.valueOf(this.pageSize); - values[8] = this.initialSortColumn; - values[9] = (this.initialSortDescending ? Boolean.TRUE : Boolean.FALSE); + Object values[] = new Object[] { + // standard component attributes are saved by the super class + super.saveState(context), + Integer.valueOf(this.currentPage), + this.sortColumn, + (this.sortDescending ? Boolean.TRUE : Boolean.FALSE), + this.value, + this.dataModel, + this.viewMode, + Integer.valueOf(this.pageSize), + this.initialSortColumn, + (this.initialSortDescending ? Boolean.TRUE : Boolean.FALSE), + this.refreshOnBind}; return (values); } @@ -203,6 +205,31 @@ public class UIRichList extends UIComponentBase implements IDataContainer this.viewMode = viewMode; } + /** + * Get the refreshOnBind flag. + * + * @return the refreshOnBind + */ + public boolean getRefreshOnBind() + { + ValueBinding vb = getValueBinding("refreshOnBind"); + if (vb != null) + { + this.refreshOnBind = (Boolean)vb.getValue(getFacesContext()); + } + return this.refreshOnBind; + } + + /** + * Set the refreshOnBind flag. True to force the list to retrieve bound data on bind(). + * + * @param refreshOnBind the refreshOnBind + */ + public void setRefreshOnBind(boolean refreshOnBind) + { + this.refreshOnBind = refreshOnBind; + } + /** * Return the UI Component to be used as the "no items available" message * @@ -414,6 +441,11 @@ public class UIRichList extends UIComponentBase implements IDataContainer */ public void bind() { + if (getRefreshOnBind() == true) + { + this.value = null; + this.dataModel = null; + } int rowCount = getDataModel().size(); // if a page size is specified, then we use that int pageSize = getPageSize(); @@ -528,6 +560,7 @@ public class UIRichList extends UIComponentBase implements IDataContainer private int pageSize = -1; private String initialSortColumn = null; private boolean initialSortDescending = false; + private boolean refreshOnBind = false; // transient component state that exists during a single page refresh only private int rowIndex = -1; diff --git a/source/java/org/alfresco/web/ui/common/tag/data/RichListTag.java b/source/java/org/alfresco/web/ui/common/tag/data/RichListTag.java index 7c67272026..bc6187d13b 100644 --- a/source/java/org/alfresco/web/ui/common/tag/data/RichListTag.java +++ b/source/java/org/alfresco/web/ui/common/tag/data/RichListTag.java @@ -72,6 +72,7 @@ public class RichListTag extends BaseComponentTag this.headerStyleClass = null; this.width = null; this.pageSize = null; + this.refreshOnBind = null; } /** @@ -93,6 +94,7 @@ public class RichListTag extends BaseComponentTag setStringProperty(component, "headerStyleClass", this.headerStyleClass); setStringProperty(component, "width", this.width); setIntProperty(component, "pageSize", this.pageSize); + setBooleanProperty(component, "refreshOnBind", this.refreshOnBind); } @@ -228,11 +230,24 @@ public class RichListTag extends BaseComponentTag { this.headerStyleClass = headerStyleClass; } + + /** + * Set the refreshOnBind flag. True to force the list to retrieve bound data on bind(). + * + * @param refreshOnBind the refreshOnBind + */ + public void setRefreshOnBind(String refreshOnBind) + { + this.refreshOnBind = refreshOnBind; + } // ------------------------------------------------------------------------------ // Private data + /** the refreshOnBind */ + private String refreshOnBind; + /** the header row CSS Class */ private String headerStyleClass; diff --git a/source/web/WEB-INF/alfresco.tld b/source/web/WEB-INF/alfresco.tld index fa121887dd..01563cc745 100644 --- a/source/web/WEB-INF/alfresco.tld +++ b/source/web/WEB-INF/alfresco.tld @@ -210,6 +210,12 @@ false true + + + refreshOnBind + false + true + diff --git a/source/web/jsp/workflow/pooled-tasks-todo-dashlet.jsp b/source/web/jsp/workflow/pooled-tasks-todo-dashlet.jsp index 3586bd9d34..5ab17bd0aa 100644 --- a/source/web/jsp/workflow/pooled-tasks-todo-dashlet.jsp +++ b/source/web/jsp/workflow/pooled-tasks-todo-dashlet.jsp @@ -9,7 +9,7 @@ styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%" pageSize="10" initialSortColumn="created" initialSortDescending="true" - rendered="#{not empty WorkflowBean.pooledTasks}"> + rendered="#{not empty WorkflowBean.pooledTasks}" refreshOnBind="true"> <%-- Primary column for details view mode --%> diff --git a/source/web/jsp/workflow/tasks-active-dashlet.jsp b/source/web/jsp/workflow/tasks-active-dashlet.jsp index e6f5ba69d4..7d4c789f13 100644 --- a/source/web/jsp/workflow/tasks-active-dashlet.jsp +++ b/source/web/jsp/workflow/tasks-active-dashlet.jsp @@ -9,7 +9,7 @@ styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%" pageSize="10" initialSortColumn="created" initialSortDescending="true" - rendered="#{not empty WorkflowBean.allActiveTasks}"> + rendered="#{not empty WorkflowBean.allActiveTasks}" refreshOnBind="true"> <%-- Primary column for details view mode --%> diff --git a/source/web/jsp/workflow/tasks-completed-dashlet.jsp b/source/web/jsp/workflow/tasks-completed-dashlet.jsp index 9baac8e505..2223db2128 100644 --- a/source/web/jsp/workflow/tasks-completed-dashlet.jsp +++ b/source/web/jsp/workflow/tasks-completed-dashlet.jsp @@ -9,7 +9,7 @@ styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%" pageSize="10" initialSortColumn="bpm:completionDate" initialSortDescending="true" - rendered="#{not empty WorkflowBean.tasksCompleted}"> + rendered="#{not empty WorkflowBean.tasksCompleted}" refreshOnBind="true"> <%-- Primary column for details view mode --%> diff --git a/source/web/jsp/workflow/tasks-todo-dashlet.jsp b/source/web/jsp/workflow/tasks-todo-dashlet.jsp index 31e6efb96f..82add93d6d 100644 --- a/source/web/jsp/workflow/tasks-todo-dashlet.jsp +++ b/source/web/jsp/workflow/tasks-todo-dashlet.jsp @@ -9,7 +9,7 @@ styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%" pageSize="10" initialSortColumn="created" initialSortDescending="true" - rendered="#{not empty WorkflowBean.tasksToDo}"> + rendered="#{not empty WorkflowBean.tasksToDo}" refreshOnBind="true"> <%-- Primary column for details view mode --%>