Sunday, April 5, 2009

UIComponent has the function getFacetsAndChildren()


public Iterator getFacetsAndChildren() {
Iterator result;
int childCount = this.getChildCount(),
facetCount = this.getFacetCount();
// If there are neither facets nor children
if (0 == childCount && 0 == facetCount) {
result = EMPTY_ITERATOR;
}
// If there are only facets and no children
else if (0 == childCount) {
Collection unmodifiable =
Collections.unmodifiableCollection(getFacets().values());
result = unmodifiable.iterator();
}
// If there are only children and no facets
else if (0 == facetCount) {
List unmodifiable =
Collections.unmodifiableList(getChildren());
result = unmodifiable.iterator();
}
// If there are both children and facets
else {
result = new FacetsAndChildrenIterator(this);
}
return result;
}

March 10, 2009 Posted by careeritdevelopers | Uncategorized | , | No Comments

You can put a button on Template Def and do reset all inputText irrespective of pages, which implemented the same template

You can put a button on Template Def and do reset all inputText irrespective of pages, which implemented the same template.
Here you can design a Template that be applied to your entire project, from the same template you can access the all pages and its controls.
here is the sample code check it out , let me know your feedback.

private void resetValueInputItems(AdfFacesContext adfFacesContext, UIComponent component){
Map m ;

Iterator IC=component.getFacetsAndChildren();
while ( IC.hasNext() ) {
UIComponent item =IC.next();
if ( item instanceof RichInputText ) {
RichInputText input = (RichInputText)item;
if ( !input.isDisabled() ) {
System.out.println(input.getValue());
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
} else if ( item instanceof RichInputDate ) {
RichInputDate input = (RichInputDate)item;
System.out.println(”got Date”);
if ( !input.isDisabled() ) {
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
}
resetValueInputItems(adfFacesContext,item);
}

}

public void resetForm(ActionEvent actionEvent) {
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
//resetValueInputItems(adfFacesContext,vvFormBinding );

}

March 10, 2009 Posted by careeritdevelopers | Uncategorized | , , , , , | No Comments

We can access all Controls page in ADF

Using this function you can do reset all inputtext in a page without knowing them.

private void resetValueInputItems(AdfFacesContext adfFacesContext, UIComponent component){
List items = component.getChildren();
for ( UIComponent item : items ) {

resetValueInputItems(adfFacesContext,item);

if ( item instanceof RichInputText ) {
RichInputText input = (RichInputText)item;
if ( !input.isDisabled() ) {
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
} else if ( item instanceof RichInputDate ) {
RichInputDate input = (RichInputDate)item;
if ( !input.isDisabled() ) {
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
}
}
}

public void resetForm(ActionEvent actionEvent) {
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
resetValueInputItems(adfFacesContext,vvFormBinding );
testMap.put(”TEST”, “initial value”);
}

0 comments: