Hi Walter,
I think this is the general approach needed for input components in
tables (untested):
int n = 0;
dataTable.setRowIndex(n);
while (dataTable.isRowAvailable()) {
// here apply the resetValues code for each component in the table
dataTable.setRowIndex(++n);
}
dataTable.setRowIndex(-1);
As an alternative, I think for myfaces that this single line will clear
*everything* from the components while still leaving the "value" EL
expression valid:
dataTable.setValue(null)
However that approach may not be portable to other JSF implementations.
Regards,
Simon
Walter Mourão schrieb:
The resetValues method is working fine with editable values, but I
could not figure out a way to make it work with tables...
Hints ?
Walter Mourão
http://waltermourao.com.br
http://arcadian.com.br
http://oriens.com.br
On Sun, Sep 21, 2008 at 9:34 AM, Walter Mourão
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
Thanks Volker, but if I return an outcome != null the PPR does not
work.
The solution I found so far was the creation of a resetValues
method which resets the values of the editable components:
...
private void resetValues(UIComponent uic){
if(uic instanceof UIXEditableValue){
((UIXEditableValue)uic).resetValue();
}
for(UIComponent component: uic.getChildren()){
resetValues(component);
}
}
/**
* Method that is backed to a submit button of a form.
*/
public String send()
{
final FacesContext facesContext=FacesContext.getCurrentInstance();
UIViewRoot viewRoot=facesContext.getViewRoot();
resetValues(viewRoot);
...
It is (apparently) working fine, incuding when using PPR. In know
it works only with Trinidad components and later I will take a
look at the UIXEditableValue.reset method to extend the solution
to all JSF components. Despite the fact the resetValues method
must be executed in each action handler (I will think about
later), does anybody see a problem in this approach ?
Cheers,