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
This commit is contained in:
Kevin Roast
2007-06-18 11:26:36 +00:00
parent b51bc7954c
commit 8be9a5fc22
8 changed files with 70 additions and 26 deletions

View File

@@ -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))
{

View File

@@ -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];
Object values[] = new Object[] {
// 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);
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;

View File

@@ -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);
}
@@ -229,10 +231,23 @@ 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;

View File

@@ -210,6 +210,12 @@
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>refreshOnBind</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>

View File

@@ -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 --%>
<a:column id="col1" primary="true" width="200" style="padding:2px;text-align:left">

View File

@@ -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 --%>
<a:column id="col1" primary="true" width="200" style="padding:2px;text-align:left">

View File

@@ -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 --%>
<a:column id="col1" primary="true" width="200" style="padding:2px;text-align:left">

View File

@@ -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 --%>
<a:column id="col1" primary="true" width="200" style="padding:2px;text-align:left">