[
https://issues.apache.org/jira/browse/TOMAHAWK-1552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13006593#comment-13006593
]
Leonardo Uribe commented on TOMAHAWK-1552:
------------------------------------------
I committed a solution for t:dataTable. The idea is follow the same idea we did
for detailStamp facet: use a "virtual" component and add it as a facet, with a
renderer that can render the detailStamp content individually.
In this case we created a facet with name "row" and a virtual component with
id="row". The effect is it is possible to reference each row with a clientId
and that means we can render the row using the standard tag f:ajax.
If multiple rows are required to be updated, you can always add the additional
rows with a code like this:
datatable.setRowIndex(targetRowIndex);
PartialViewContext pvc = FacesContext.getCurrentInstance().
getPartialViewContext();
if (!pvc.isRenderAll())
{
Collection rows = pvc.getRenderIds();
String idToAdd = datatable.getFacet("row").getClientId();
if (!rows.contains(idToAdd))
{
rows.add(idToAdd);
}
}
The advantage is this code relies on the standard ajax mechanism.
I reviewed Richfaces and Trinidad to see how they solve the problem. It is
clear there is an association between the rowIndex and a rowKey, so to solve
this both of them has an extended DataModel to deal with this logic. For
example, in trinidad case there is an interface called
org.apache.myfaces.trinidad.model.RowKeyIndex .
In theory, there is an old known problem in UIData (since JSF 1.0).
The interface javax.faces.model.DataModel looks like this:
public abstract class DataModel<E> implements Iterable<E>{
public void addDataModelListener(DataModelListener listener);
public DataModelListener[] getDataModelListeners();
public void removeDataModelListener(DataModelListener listener);
//size and ordering
abstract public int getRowCount();
abstract public int getRowIndex();
abstract public void setRowIndex(int rowIndex);
abstract public boolean isRowAvailable();
public Iterator<E> iterator();
//row data
abstract public E getRowData();
//structure behind model
abstract public Object getWrappedData();
abstract public void setWrappedData(Object data);
}
In practice, the problem is the model can change between requests, so the
rowCount/rowIndex changes too, and that causes the row state becomes
inconsistent on the component side. In tomahawk there exist a solution using
preserveDataModel attribute. But other possible alternative is make
t:dataTable or the custom component extending UIData take into consideration
this fact. How? I don't know yet. I'm still thinking about how to do it.
In theory for an specific row, the component state of that row must be
bound in some way to the state using a rowKey. In practice, that rowKey is
usually some property of the rowData, so the clientId of each component in a
row must reflect this fact, so when an action or input value is decoded,
the right state can be loaded and saved.
Now, going back to the initial problem, it is not possible for the moment
to do something similar to RichFaces ajaxKeys because there is not an
alternative solution for the previous problem yet. So, the best we can do
for now is provide the previous solution, but I'll continue investigating
what can we do in this case.
> t:dataList, t:dataTable ajax
> ----------------------------
>
> Key: TOMAHAWK-1552
> URL: https://issues.apache.org/jira/browse/TOMAHAWK-1552
> Project: MyFaces Tomahawk
> Issue Type: New Feature
> Components: Data List
> Environment: ALL
> Reporter: Dave
>
> dataList and dataTable: allow ajax reRender specified rows. Richfaces uses
> ajaxKeys to specified row indice to be reRendered for ajax request.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira