Monday, December 23, 2013

How to add Input Texts(or any element) dynamically within form layout?

1)      Create ADF Form layout and bind the variable to managed Bean
2)      Create method in ManagedBean to perform the action.
3)      Use following code snippet for reference to add inputboxes dynamically within form layout
        inputText = new RichInputText[newValues.length];
        if (childrenLength != 0) {
            getPnlFormLayoutForMassUpdate().getChildren().clear();
        }
        for (int i = 0; i < newValues.length; i++)

        {
            inputText[i] = new RichInputText();

            inputText[i].setLabel(newValues[i]);
            inputText[i].setId("id" + i);
            //  inputText[i].setRequired(true);
            //  inputText[i].setShowRequired(true);
            //inputText[i].setValue(newValues[i]);
          

            getPnlFormLayoutForMassUpdate().getChildren().add(inputText[i]);
            if(newValues[i].indexOf("Date")!=-1)
            {
                    RichActiveOutputText opText = new RichActiveOutputText();
                    opText.setId("otindlg");
                    opText.setValue("Example : 07-Oct-16");
                    getPnlFormLayoutForMassUpdate().getChildren().add(opText);
                }
            //refresh the container to show text field
            AdfFacesContext.getCurrentInstance().addPartialTarget(getPnlFormLayoutForMassUpdate());
            childrenLength++;


        }

No comments:

Post a Comment