Showing posts with label af:popup. Show all posts
Showing posts with label af:popup. Show all posts

15 October 2010

TROUBLESHOOTING: Reset the values of the UI components in order to get refreshed from model

Problem 
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();
   //a little mod here: Also refesh the component
   RequestContext.getCurrentInstance().addPartialTarget(uiField);

  }
   resetStaleValues(component);
}

You can also enrich  your code by including functinality to set value null with methods like:

12 October 2010

Keep Popup open even if you navigate to another page and return or set autocanel prop

Scenario:

You are in a page where you open an af:popup
In the af:popup there is a button that navigates to another TF and
when you returned from the TF you want to have the popup open as you left it

Solution

Use autoCancel=disabled
eg
  <af:popup ... autoCancel="disabled" ... >

You might also like:

Related Posts Plugin for WordPress, Blogger...