6 Replies Latest reply on Nov 13, 2008 7:44 AM by Nicolas U.

    Clean an input text

    Nicolas U. Newbie

      Hi all.

      I have a stupid simple probleme...

      1 input text
      1 commandButton
      1 dataTable with 1 column

      Look like this:
      [img]http://pix.nofrag.com/3/4/9/6e92f2e0d54f3a25c5ba4da826f72.jpg[/img]

      i want put something in the input text, click the button and push it in the datatable.

      I have make this:


      JSF

      <h:inputText id="InputPackageNumber" value="#{pc_Index.newPacknum}"/>
      <h:commandButton value=">>">
       <a4j:support action="#{pc_Index.addPakNum}" event="onclick" reRender="InputPackageNumber,packageList" />
      </h:commandButton>
      <rich:dataTable id="packageList" value="#{pc_Index.listpackage}" var="file">
       <f:facet name="header">
       <rich:columnGroup>
       <h:column>
       <h:outputText value="File number" />
       </h:column>
       </rich:columnGroup>
       </f:facet>
       <h:column>
       <h:outputText value="#{file}" />
       </h:column>
      </rich:dataTable>
      
      


      BEAN:
      protected HtmlInputText InputPackageNumber;
      protected List<String> listpackage = null;
      protected String newPacknum;
      
      public void addPakNum() {
       String tmp = getNewPacknum();
       setNewPacknum("");
       if ((!tmp.equals("")) && (tmp !=null)) {
       addListpackage(tmp);
       }
      }
      
      public void addListpackage(String addMe) {
       List<String> listpackageTmp = null;
       listpackageTmp = getListpackage();
       listpackageTmp.add(addMe);
       setListpackage(listpackageTmp);
      }
      


      It's work not too bad but it doesn't clean the input text after be added at the list.
      How can i make this?

      thx