Common Reset button for both form and table

720 views Asked by At

I have a page with form and table created using the same View Object, is it possible to have a single reset/clear button to reset the form as well as the table?

I tried this:

public String clear_action() {
    BindingContainer bindings = GenericUtility.getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("CreateInsert");

    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
        return null;
    }

    DCBindingContainer dcBindings = GenericUtility.getDCBinding();

    DCIteratorBinding searchIter;
    searchIter = dcBindings.findIteratorBinding("RegionMasterviewcrieria1Iterator");
    searchIter.clearForRecreate();
    RichInputText dd =
        (RichInputText)FacesContext.getCurrentInstance().getViewRoot().findComponent("regPt1:regIt1");
    dd.setDisabled(false);
    return null;
}

But the problem with this is that if I click on a row (say 2nd row) in the table, the corresponding values get updated in the form. Now if I try to reset both the form and table, I will not be able to select the same row (2nd) again.

I will have to select another row and then come back to the 2nd row.

2

There are 2 answers

0
zDroid On

I just included this line of code in the clear()

      RichTable table = (RichTable)FacesContext.getCurrentInstance().getViewRoot().findComponent("pt1:t1");
          if(null!=table.getSelectedRowKeys())

table.getSelectedRowKeys().clear();

Hope this helps some one down the line...

0
Ashish Awasthi On

What is purpose of this exactly ? Have you tried using resetActionListener in button to reset form?

Ashish