5 Replies Latest reply on Feb 8, 2015 9:57 AM by masummymesingh

    JSF2.2 Mojarra problem of wildfly 8

    masummymesingh

        I have to do save and reset my two component . After click save button it reload

        two component .

        is it possible screen reset without reload those two components ?

        Q1. why combox reload  after click save button ?

       

       

        ============xhtml ======================

       

      <h:form prependId="false" id="vb">

                  <h:selectOneMenu id="cmblanid" value="#{customerBean.myid}">

                      <f:selectItem itemValue="#{null}" itemLabel="please select"/>

                      <f:selectItems value="#{customerBean.langues}" var="itm" itemLabel="#{itm.name}" itemValue="#{itm.id}"/>

                  </h:selectOneMenu>

       

                  <br>           

                  </br>

                  <h:inputText  id="txtname" value="#{customerBean.appName}">

                      <f:validateLength maximum="4" minimum="3"/>

                  </h:inputText>

                  <br>             

                  </br>

       

                  <h:commandButton value="Save" >

                      <f:ajax execute="@form" immediate="true"    render="cmblanid txtname" listener="#{customerBean.save}"  />

                  </h:commandButton>

                  <h:commandButton value="Cancel" />

              </h:form>

       

      ========================controller class=======================

       

          @PostConstruct

          public void init() {

       

              System.out.println(" load : ");

       

              langues = new ArrayList<>();

       

              langues.add(new Language(1, "English"));

              langues.add(new Language(2, "Bangla"));

              langues.add(new Language(3, "Hindi"));

              langues.add(new Language(4, "Arabic"));

              langues.add(new Language(5, "Finish"));

              langues.add(new Language(6, "Urdu"));

              langues.add(new Language(7, "Trukis"));

              langues.add(new Language(8, "ABCD"));

              langues.add(new Language(9, "Pali"));

              langues.add(new Language(10, "Rassian"));

              langues.add(new Language(11, "Tamil"));

       

              langues.add(new Language(10, "Spanis"));

              langues.add(new Language(11, "MMMMM"));

              langues.add(new Language(12, "PPPPP"));

       

              langues.add(new Language(13, "SDFS"));

              langues.add(new Language(14, "POIU"));

              langues.add(new Language(15, "WERT"));

       

          }

       

          public void save(AjaxBehaviorEvent event) throws AbortProcessingException  {

       

              System.out.println(" id : " + myid);

              System.out.println(" Name : " + appName);

       

              System.out.println(" ----------------------------> : ");

       

              // Screen Refresh

              myid = null;

              appName = null;

       

          }

       

       

       

      p3.png

        • 1. Re: JSF2.2 Mojarra problem of wildfly 8
          michpetrov

          <f:ajax execute="@form" immediate="true" render="cmblanid txtname" listener="#{customerBean.save}"  />

           

          The bolded part is what tells the server what components to reload, if you don't want that, don't set them up in the attribute. I am not sure what you mean by screen reset though.

          • 2. Re: JSF2.2 Mojarra problem of wildfly 8
            masummymesingh

            yes,

             

            render="cmblanid txtname" attribute perform reload .  when i don't set this attribute , i can not refresh my component after save button press.


            I want to just clearing field and set default value in combo box after save button perform successfully completed.


            pls tell me a suggestion , how to refresh/clear field after save ?


            Thanks



            • 3. Re: JSF2.2 Mojarra problem of wildfly 8
              michpetrov

              I don't understand. When you select a value in the combobox why do you want to reset the component? Do you not need to know what value you selected?

              • 4. Re: JSF2.2 Mojarra problem of wildfly 8
                masummymesingh

                When you select a value in the combobox why do you want to reset the component?




                I want to reset those components after successfully save button perform  , not before save .

                • 5. Re: JSF2.2 Mojarra problem of wildfly 8
                  masummymesingh

                  @

                  <html xmlns="http://www.w3.org/1999/xhtml"

                        xmlns:ui="http://java.sun.com/jsf/facelets"

                        xmlns:h="http://java.sun.com/jsf/html"

                        xmlns:f="http://java.sun.com/jsf/core"

                        xmlns:p="http://primefaces.org/ui">

                      <h:head>

                          <script name="jquery/jquery.js" library="primefaces"></script>

                          <script>

                              function handleComplete(xhr, status, args) {

                                  var isValid = args.isValid;

                                  if (isValid) {

                                      $('#txtname').val('');

                              

                                     // PF('myselectlang').selectValue('');

                                       PF('myselectlang').

                                     

                                      alert("successfully perform-->" + isValid );

                                  } else {

                                      alert(" validation failed..");

                                  }

                    

                              }

                             

                             

                                function dhaka(){

                                            $('#txtname').val('');

                                    

                                      PF('myselectlang').selectValue('');

                               

                                       alert(" vdhaka");

                              

                                }

                   

                           

                          </script>

                          <title>Register Employee</title>

                      </h:head>

                      <h:body>

                          <h:form prependId="false">

                   

                              <p:selectOneMenu id="cmblanid" widgetVar="myselectlang" value="#{utilitiesManagedBean.myid}">

                                  <f:selectItem itemValue="#{null}" itemLabel="please select"/>

                                  <f:selectItems value="#{utilitiesManagedBean.langues}" var="itm" itemLabel="#{itm.name}" itemValue="#{itm.id}"/>

                              </p:selectOneMenu>

                   

                   

                              <p:inputText id="txtname" value="#{utilitiesManagedBean.appName}">

                                  <f:validateLength maximum="4" minimum="3"/>

                              </p:inputText>

                   

                              <p:commandButton value="save" process="@form"  async="true" ajax="true" partialSubmit="true"  action="#{utilitiesManagedBean.save()}"

                                               oncomplete="handleComplete(xhr,status,args)"/>

                   

                   

                   

                          </h:form>

                      </h:body>

                  </html>