5 Replies Latest reply: Jan 7, 2013 1:11 AM by Navin K RSS

    remove InputFile dynamically

    Habib Eslami
      Hi everybody,
      my english isn't very good.
      I use JDeveloper 11.1.1.3.0

      I create an InputFile component dynamically in a bean.
      RichInputFile if_test = new RichInputFile();
      if_test.setLabel("test");
      pgl10.getChildren().add(if_test);

      but sometimes I should remove this component .How can I remove InputFile dynamically.

      Habib
        • 1. Re: remove InputFile dynamically
          Sudipto Desmukh
          pgl10.getChildren().remove(<indexOfAddedElement>);
          should work.
          • 2. Re: remove InputFile dynamically
            Habib Eslami
            Thanks

            but how can I get <indexOfAddedElement> ?

            I do this : pgl10.getChildren().remove(pgl10.findComponent("ComponentID"));
            but it doesn't work
            • 3. Re: remove InputFile dynamically
              Timo Hahn
              The getChildren () method returns a list of UIComponent, so to remove an element from a list you have to use the index of the element in the list. Using the component ID won't work.
              You can remove the element from the list using the element itself, meaning you have the inputFile component as a reference, you can use getChildren().remove(ref_inputfile);
              Or you can iterate over the child elements to get the index of the component to remove.


              Timo
              • 4. Re: remove InputFile dynamically
                Habib Eslami
                I write follow code:

                List<UIComponent> result = (List)new ArrayList<UIComponent>();

                result = pgl10.getChildren();

                int index = result.indexOf(ComponentID);

                then to remove a component,I use two ways but none of them don't work:

                1: result.remove(index);

                2: result.remove(ComponentID);

                Habib
                • 5. Re: remove InputFile dynamically
                  Navin K
                  Hi Habib,

                  Have you tried refreshing the container of the component after removing the component ?

                  As Timo said you wont be able to remove the component using ID.

                  if you have

                  RichInputFile if_test = new RichInputFile();
                  try removing by getChildren().remove(if_test); and after that refresh the container containing that component.

                  Thanks

                  --NavinK