We have a af:popup that its value should be cleared its time it was raised.
The fields of the popup were based on transient attributes of SQL Based VO.
For that reason each time the popup was raise the VO was executed (to take its initial values)
The problem was that in hte popup the values were not cleared.
Solution
I came across this excellent post
http://adfbits.blogspot.com/2008/11/sticky-popup-values.html
Using the following method after executing the SQL based VO (below is the function a bit modifying):
public void resetStaleValues(UIComponent rootComponent){
Iterator iter = rootComponent.getFacetsAndChildren();
while (iter.hasNext()) {
UIComponent component = iter.next();
if (component instanceof UIXEditableValue) {
UIXEditableValue uiField = (UIXEditableValue)component;
uiField.resetValue();
Iterator iter = rootComponent.getFacetsAndChildren();
while (iter.hasNext()) {
UIComponent component = iter.next();
if (component instanceof UIXEditableValue) {
UIXEditableValue uiField = (UIXEditableValue)component;
uiField.resetValue();
//a little mod here: Also refesh the component
RequestContext.getCurrentInstance().addPartialTarget(uiField);
}
resetStaleValues(component);
}
}
resetStaleValues(component);
}
You can also enrich your code by including functinality to set value null with methods like:
- http://myfaces.apache.org/trinidad/trinidad-api/apidocs/org/apache/myfaces/trinidad/component/UIXCollection.html#resetStampState%28%29
- http://myfaces.apache.org/core12/myfaces-api/apidocs/javax/faces/component/EditableValueHolder.html#setLocalValueSet%28boolean%29
- http://myfaces.apache.org/core12/myfaces-api/apidocs/javax/faces/component/EditableValueHolder.html#setSubmittedValue%28java.lang.Object%29
- http://myfaces.apache.org/core12/myfaces-api/apidocs/javax/faces/component/EditableValueHolder.html#setValid%28boolean%29
- http://myfaces.apache.org/core12/myfaces-api/apidocs/javax/faces/component/ValueHolder.html#setValue%28java.lang.Object%29
No comments:
Post a Comment