- Pass the component (e.g PanelGroupLayout, PanelForm) to the method to reset all the input fields in it
public static void clearValueInputItems(AdfFacesContext adfFacesContext,
UIComponent component, String id) {
List<UIComponent> items = component.getChildren();
if (0 == items.size()) {
if (component instanceof RichInputText) {
RichInputText input = (RichInputText)component;
if (!input.isDisabled()) {
input.resetValue();
input.setValue("");
adfFacesContext.addPartialTarget(input);
}
} else if (component instanceof RichInputDate) {
RichInputDate input = (RichInputDate)component;
if (!input.isDisabled()) {
input.resetValue();
input.setValue("");
adfFacesContext.addPartialTarget(input);
}
} else if (component instanceof RichSelectOneChoice) {
RichSelectOneChoice rsoc = (RichSelectOneChoice)component;
rsoc.resetValue();
rsoc.setSubmittedValue("0");
adfFacesContext.addPartialTarget(rsoc);
}
} else {
for (UIComponent item : items) {
clearValueInputItems(adfFacesContext, item, id);
if (item instanceof RichInputText) {
RichInputText input = (RichInputText)item;
if (!input.isDisabled()) {
input.resetValue();
input.setValue("");
adfFacesContext.addPartialTarget(input);
}
} else if (item instanceof RichInputDate) {
RichInputDate input = (RichInputDate)item;
if (!input.isDisabled()) {
input.resetValue();
input.setValue("");
adfFacesContext.addPartialTarget(input);
}
} else if (item instanceof RichSelectOneChoice) {
RichSelectOneChoice rsoc = (RichSelectOneChoice)item;
if (!rsoc.isDisabled()) {
rsoc.resetValue();
rsoc.setValue("");
rsoc.setSubmittedValue("");
adfFacesContext.addPartialTarget(rsoc);
}
} else if (item instanceof RichTable) {
RichTable table = (RichTable)item;
if (table.isVisible()) {
table.resetStampState();
adfFacesContext.addPartialTarget(table);
}
}else if (item instanceof RichSelectBooleanCheckbox) {
RichSelectBooleanCheckbox bcheck = (RichSelectBooleanCheckbox)item;
if (!bcheck.isDisabled()) {
Object obj = bcheck.getValue();
bcheck.resetValue();
bcheck.setValue(false);
adfFacesContext.addPartialTarget(bcheck);
}
} else if (item instanceof RichSelectOneRadio) {
RichSelectOneRadio rsor = (RichSelectOneRadio)item;
if (!rsor.isDisabled()) {
Object obj = rsor.getValue();
rsor.resetValue();
if (obj != null ){
rsor.setValue(false);
}
adfFacesContext.addPartialTarget(rsor);
}
} else if (item instanceof RichSelectManyChoice) {
RichSelectManyChoice rsmc =
(RichSelectManyChoice)item;
if (!rsmc.isDisabled()) {
rsmc.resetValue();
rsmc.setValue(null);
adfFacesContext.addPartialTarget(rsmc);
}
} else if (item instanceof RichSelectManyCheckbox) {
RichSelectManyCheckbox rsmc =
(RichSelectManyCheckbox)item;
if (!rsmc.isDisabled()) {
rsmc.resetValue();
rsmc.setValue(false);
adfFacesContext.addPartialTarget(rsmc);
}
}
}
}
}
No comments:
Post a Comment