org.ajax4jsf.ajax.repeat.ExtendedDataModel Maven / Gradle / Ivy
/**
*
*/
package org.ajax4jsf.ajax.repeat;
import java.io.IOException;
import java.io.Serializable;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
/**
* Extesion for {@link DataModel} , for support complex data structure, like tree, spreadsheet etc
* in iterable components.
* @author shura
*
*/
public abstract class ExtendedDataModel extends DataModel {
/**
* Instead of simple int
for current state selection, this model can use any object for
* select current data. Implementation depend on model, with any restrictions :
*
* - key must be {@link Serializable}.
* - {@link Object#toString()} method must return representation compatible with {@link javax.faces.component.UIComponent#getClientId(javax.faces.context.FacesContext)},
* as far as this string will be appended to clientId of iterator component.
*
* @param key key for select current data, or null for clear selection.
*/
public abstract void setRowKey(Object key);
/**
* @return key for selected data or null
*/
public abstract Object getRowKey();
/**
* Iteration component can support save data for use at decoding/validation/update phases to avoid unnessesary calls to original models,
* for example - to avoid requests to database until all data is validated.
* @return
*/
public ExtendedDataModel getSerializableModel(Range range){
// By default, model not serializable.
return null;
}
/**
* Iterate over model by "visitor" pattern, for given range
* @param context current JSF context.
* @param visitor instance of {@link DataVisitor}, for process each row.
* @param range Implementation-specific range of data keys.
* @param argument Implementation-specific argument
* @throws IOException
*/
public abstract void walk(FacesContext context,DataVisitor visitor,Range range, Object argument) throws IOException;
/**
* Create Iterator on all row keys for given range.
* @param range - Implementation-specific range of data keys.
* @return
*/
// public abstract Iterator dataIterator(Range range);
}