14 Replies Latest reply on Jun 8, 2010 4:36 AM by Erman bas

    problem with a4j:commandButton and h:comandButton

    Erman bas Newbie

      it doesnt enter commanButton action method. 

       

      my xhmtl is

       

       

      <rich:tab id="tabBookImages" label="Kitap Detaylari">

                                  <h:panelGrid id="gpTab2" columns="3">
                                      <h:outputLabel value="#{msgs.baseIntroduction}" id="lblTemelGiris"/>
                                      <h:inputTextarea cols="30" rows="3"   id="txtTemelGiris"    value="#{kitapEkle.bookDeatil.temel_giris}"/>
                                      <h:message for="txtTemelGiris" showDetail="true" tooltip="#{msgs.validationBaseIntroduction}"/>

                                      <h:outputLabel value="#{msgs.yayinDagitim}" id="lblYayinDagitim"/>
                                      <h:inputTextarea  required="false"  id="txtYayinDagitim"
                                                        cols="30" rows="2" value="#{kitapEkle.bookDeatil.yayin_dagitim}"/>
                                      <h:message for="txtYayinDagitim" showDetail="true" tooltip="#{msgs.validationYayinDagitim}"/>

                                      <h:outputLabel value="#{msgs.fizikselNiteleme}" id="lblFizikselNiteleme"/>
                                      <h:inputTextarea  rows="2" cols="30"  id="txtFizikselNiteleme"   value="#{kitapEkle.bookDeatil.fiziksel_nitelme}"/>
                                      <h:message for="txtFizikselNiteleme" showDetail="true" tooltip="#{msgs.validationFizikselNiteleme}"/>

                                      <h:outputLabel value="#{msgs.bibliyografiNotu}" id="lblBibliyografiNotu"/>
                                      <h:inputTextarea required="false" cols="30" rows="2" id="txtBibliyografiNotu" value="#{kitapEkle.bookDeatil.bibliyografi_notu}"/>
                                      <f:verbatim/>
                                      <h:outputLabel value="#{msgs.kitapBaslik}" id="lblKitapBasliklari"/>
                                      <h:inputTextarea id="txtKitapBasliklari" cols="30" rows="4" value="#{kitapEkle.txtKitapBasliklariStringVal}" />

                                      <h:commandButton id="btnKitapBasliklariEkle" action="#{kitapEkle.kitapBasligiEkle}"
                                                       value="ekle">
                                          <a4j:support  event="onclick" ajaxSingle="true" process="txtKitapBasliklari" reRender="gpKitapBasliklari"/>
                                      </h:commandButton>
                                      <h:outputLabel value="Eklenen Kitaplar" />
                                  </h:panelGrid>

                                  <h:panelGroup id="gpKitapBasliklari" >
                                      <h:selectManyListbox  styleClass="styleSelectManyListbox" id="ddlKitapBalsiklari" value="#{kitapEkle.konuBasliklariSecilenler}">
                                          <f:selectItems var="#{kitapEkle.txtKitapBasliklariStringVal}" value="#{kitapEkle.konuBasliklariMenu}"/>
                                      </h:selectManyListbox>
                                  </h:panelGroup>
                                  <hr noshade="1" size="1" width="96%"/>
                                  <br/>
                                  <h:outputLabel styleClass="lblBaslik" value="#{msgs.kitapPdfEkle}" id="lblkitapPdfBaslik"/>
                                  <br/>
                                  <rich:fileUpload ajaxSingle="true" immediate="false" fileUploadListener="#{kitapEkle.uploadPDF}"
                                                   maxFilesQuantity="5"
                                                   styleClass="fileupload"
                                                   id="uploadPDF"
                                                   immediateUpload="false"
                                                   acceptedTypes="pdf" allowFlash="false">
                                  </rich:fileUpload>

                                  <br/>
          <h:commandButton action="#{kitapEkle.girisiTamamla}" id="btnKitapGirisiTamamla"   value="#{msgs.btnKitapGirisiTamamla}"/>
          <a4j:commandButton action="#{kitapEkle.girisiTamamla}" id="btnKitapGirisiTamamla1" value="#{msgs.btnKitapGirisiTamamla}"/>

      these 2 button call same action but both of them dont enter the action why??

        • 1. Re: problem with a4j:commandButton and h:comandButton
          Ilya Shaikovsky Master

          1) add rich:messages to the page to check all messages appeared in context. h:message(s) - is not an option because not updated by ajax componentxs automatically.

          2) remove nested supports from h:command* components - concurrent requests send in this case.

          • 2. Re: problem with a4j:commandButton and h:comandButton
            Erman bas Newbie

            Ilya Thanx for reply;

            first one is ok but i couldnt understand  the second one;

            • 3. Re: problem with a4j:commandButton and h:comandButton
              Ilya Shaikovsky Master
                <h:commandButton id="btnKitapBasliklariEkle" action="#{kitapEkle.kitapBasligiEkle}"
                                                               value="ekle">
                                                  <a4j:support  event="onclick" ajaxSingle="true" process="txtKitapBasliklari" reRender="gpKitapBasliklari"/>
                                              </h:commandButton>

               

              h:command - performs normal POST and a4j:support inside - performs ajax request for it's onclick event. Both requests will be fired in the same time. Just change that combination to simple a4j:commandButton.

               

              B.t.w. this space not designed to discuss usage questions. oving to RichFaces space from RichFaces development.

              • 4. Re: problem with a4j:commandButton and h:comandButton
                Erman bas Newbie

                ilya i have already <h:messages

                 

                full xhmtl code is this

                 

                 

                <ui:define name="body">
                        <h:form id="form1">
                            <rich:messages ajaxRendered="true" globalOnly="true" showDetail="true" />
                            <rich:layout id="pnlLayoutContainer">
                                <rich:layoutPanel position="left" id="pnlLayoutLeft"></rich:layoutPanel>
                                <rich:layoutPanel position="center" id="pnlLayoutCenter">
                                    <rich:tabPanel id="tabPanelContainer" switchType="client">
                                        <rich:tab id="tabBookAndAuthor" label="Kitap Girisi">

                                            <h:panelGrid id="gpTab1" columns="2">
                                                <h:outputLabel value="#{msgs.bookName}" id="lblBookName"/>
                                                <h:inputTextarea styleClass="txtStyleForSmall" rows="3" cols="60" id="txtBookName" value="#{kitapEkle.book.bookName}"/>


                                                <h:outputLabel value="#{msgs.isbnNo}" id="lblisbn"/>
                                                <h:inputText styleClass="txtStyleForSmall" size="150" id="txtIsbn" value="#{kitapEkle.book.isbn}"/>


                                                <h:outputLabel value="#{msgs.publisDate}" id="lblYayinTarihi"/>
                                                <rich:calendar id="calendarPublishDate" value="#{kitapEkle.selectedDate}"
                                                               locale="#{msgs.calendarLocale}" popup="true"
                                                               datePattern="#{msgs.calendarDatePattern}"
                                                               cellWidth="24px" cellHeight="22px" styleClass="styleCalendar"/>

                 

                                                <h:outputLabel value="#{msgs.categoryId}" id="lblBookImage"/>
                                                <h:selectOneMenu id="ddCategory" value="#{kitapEkle.bookCategoryId}">
                                                    <f:selectItems value="#{applicationBeanInit.listBookCategories}" id="ddlCategoriesMenu"/>
                                                </h:selectOneMenu>
                                            </h:panelGrid>
                                            <h:panelGrid id="gpFileUploadandImage" columns="2">

                                                <rich:fileUpload ajaxSingle="true" immediate="false" fileUploadListener="#{kitapEkle.listener}"
                                                                 maxFilesQuantity="#{kitapEkle.uploadsAvailable}"
                                                                 id="upload" styleClass="fileupload"
                                                                 immediateUpload="#{kitapEkle.autoUpload}"
                                                                 acceptedTypes="jpg, gif, png, bmp" allowFlash="false">
                                                    <a4j:support id="s4jSupportImages" event="onuploadcomplete" reRender="info,infoPanel"/>
                                                </rich:fileUpload>
                                                <a4j:region id="regionImagesEkleme" selfRendered="true" renderRegionOnly="true">
                                                    <a4j:outputPanel id="info" ajaxRendered="true">
                                                        <rich:panel id="infoPanel"  bodyClass="info">
                                                            <f:facet name="header">
                                                                <h:outputText id="lblYuklenmisResim" value="Yuklenmis Resim" />
                                                            </f:facet>
                                                            <h:outputText id="lblYuklenmisDosyalar" value="No files currently uploaded"
                                                                          rendered="#{kitapEkle.size==0}" />
                                                            <rich:dataGrid id="panelGridFiles" columns="1" value="#{kitapEkle.files}"
                                                                           var="file" rowKeyVar="row">
                                                                <rich:panel id="richPanelYuklenmisImages" bodyClass="rich-laguna-panel-no-header">
                                                                    <h:panelGrid id="panelGridYuklenmisResimler" columns="3">
                                                                        <a4j:mediaOutput id="mediaImage"  element="img" mimeType="image/png"
                                                                                         createContent="#{kitapEkle.paint}" value="#{row}"
                                                                                         uriAttribute="src" style="width:100px; height:100px;" cacheable="false">
                                                                            <f:param value="#{kitapEkle.timeStamp}" name="time"/>
                                                                        </a4j:mediaOutput>
                                                                        <h:panelGrid id="panelGridImageDetay" columns="2">
                                                                            <h:outputText id="lblImageName" value="File Name:" />
                                                                            <h:outputText value="#{file.name}" />
                                                                            <h:outputText id="lblImageFileSize" value="File Length(bytes):" />
                                                                            <h:outputText value="#{file.length}" />
                                                                        </h:panelGrid>
                                                                    </h:panelGrid>
                                                                </rich:panel>
                                                            </rich:dataGrid>
                                                        </rich:panel>
                                                        <rich:spacer height="3"/>
                                                        <br />
                                                        <a4j:commandButton id="btnYuklenmisResimleriSil" action="#{kitapEkle.clearUploadData}"
                                                                           reRender="info, upload" value="Yuklenmis Resimleri Temizle"
                                                                           rendered="#{kitapEkle.size>0}" />
                                                    </a4j:outputPanel>
                                                </a4j:region>
                                                <rich:listShuttle sourceValue="#{applicationBeanInit.authorList}"
                                                                  targetValue="#{kitapEkle.authorList}" var="items"
                                                                  converter="authorConverter" styleClass="styleListShuttle"
                                                                  sourceCaptionLabel="Mevcut Yazarlar" copyAllControlLabel="#{msgs.listShuttleCopyAll}"
                                                                  copyControlLabel="#{msgs.listShuttleCopy}"
                                                                  id="listShuttleAuthorList"
                                                                  removeAllControlLabel="#{msgs.listShuttleRemoveAll}"
                                                                  removeControlLabel="#{msgs.listShuttleRemove}"
                                                                  targetCaptionLabel="Secilen Yazarlar">
                                                    <rich:column>
                                                        <h:outputText value="#{items.list_id}"></h:outputText>
                                                    </rich:column>
                                                    <rich:column>
                                                        <h:outputText value="#{items.list_name}"></h:outputText>
                                                    </rich:column>
                                                </rich:listShuttle>
                                            </h:panelGrid>

                                        </rich:tab>
                                        <!-- ******************************************************************2. TAB************************************************************************************** -->
                                        <rich:tab id="tabBookImages" label="Kitap Detaylari">

                                            <h:panelGrid id="gpTab2" columns="3">
                                                <h:outputLabel value="#{msgs.baseIntroduction}" id="lblTemelGiris"/>
                                                <h:inputTextarea cols="30" rows="3"   id="txtTemelGiris"    value="#{kitapEkle.bookDeatil.temel_giris}"/>
                                                <h:message for="txtTemelGiris" showDetail="true" tooltip="#{msgs.validationBaseIntroduction}"/>

                                                <h:outputLabel value="#{msgs.yayinDagitim}" id="lblYayinDagitim"/>
                                                <h:inputTextarea  required="false"  id="txtYayinDagitim"
                                                                  cols="30" rows="2" value="#{kitapEkle.bookDeatil.yayin_dagitim}"/>
                                                <h:message for="txtYayinDagitim" showDetail="true" tooltip="#{msgs.validationYayinDagitim}"/>

                                                <h:outputLabel value="#{msgs.fizikselNiteleme}" id="lblFizikselNiteleme"/>
                                                <h:inputTextarea  rows="2" cols="30"  id="txtFizikselNiteleme"   value="#{kitapEkle.bookDeatil.fiziksel_nitelme}"/>
                                                <h:message for="txtFizikselNiteleme" showDetail="true" tooltip="#{msgs.validationFizikselNiteleme}"/>

                                                <h:outputLabel value="#{msgs.bibliyografiNotu}" id="lblBibliyografiNotu"/>
                                                <h:inputTextarea required="false" cols="30" rows="2" id="txtBibliyografiNotu" value="#{kitapEkle.bookDeatil.bibliyografi_notu}"/>
                                                <f:verbatim/>
                                                <h:outputLabel value="#{msgs.kitapBaslik}" id="lblKitapBasliklari"/>
                                                <h:inputTextarea id="txtKitapBasliklari" cols="30" rows="4" value="#{kitapEkle.txtKitapBasliklariStringVal}" />

                                                <h:commandButton id="btnKitapBasliklariEkle" action="#{kitapEkle.kitapBasligiEkle}"
                                                                 value="ekle">
                                                    <a4j:support  event="onclick" ajaxSingle="true" process="txtKitapBasliklari" reRender="gpKitapBasliklari"/>
                                                </h:commandButton>
                                                <h:outputLabel value="Eklenen Kitaplar" />
                                            </h:panelGrid>

                                            <h:panelGroup id="gpKitapBasliklari" >
                                                <h:selectManyListbox  styleClass="styleSelectManyListbox" id="ddlKitapBalsiklari" value="#{kitapEkle.konuBasliklariSecilenler}">
                                                    <f:selectItems var="#{kitapEkle.txtKitapBasliklariStringVal}" value="#{kitapEkle.konuBasliklariMenu}"/>
                                                </h:selectManyListbox>
                                            </h:panelGroup>
                                            <hr noshade="1" size="1" width="96%"/>
                                            <br/>
                                            <h:outputLabel styleClass="lblBaslik" value="#{msgs.kitapPdfEkle}" id="lblkitapPdfBaslik"/>
                                            <br/>
                                            <rich:fileUpload ajaxSingle="true" immediate="false" fileUploadListener="#{kitapEkle.uploadPDF}"
                                                             maxFilesQuantity="5"
                                                             styleClass="fileupload"
                                                             id="uploadPDF"
                                                             immediateUpload="false"
                                                             acceptedTypes="pdf" allowFlash="false">
                                            </rich:fileUpload>

                                            <br/>
                                            <h:commandButton action="#{kitapEkle.girisiTamamla}" id="btnKitapGirisiTamamla"   value="#{msgs.btnKitapGirisiTamamla}"/>
                                                           

                 

                                        </rich:tab>

                                    </rich:tabPanel>
                                </rich:layoutPanel>
                            </rich:layout>
                        </h:form>

                    </ui:define>

                </ui:composition>

                 

                this commandButton id="btnKitapGirisiTamamla" doesnt enter action method

                • 5. Re: problem with a4j:commandButton and h:comandButton
                  Ilya Shaikovsky Master

                  remove gloobalOnly=true from messages component definition to check all the possible messages

                  • 6. Re: problem with a4j:commandButton and h:comandButton
                    Erman bas Newbie

                    Ilya thanx again ,

                    i have already tried with

                    <h:commandButton id="btnKitapBasliklariEkle" action="#{kitapEkle.kitapBasligiEkle}"
                                                                     value="ekle">
                                                        <a4j:support  event="onclick" ajaxSingle="true" process="txtKitapBasliklari" reRender="gpKitapBasliklari"/>
                                                    </h:commandButton>

                     

                    it worked but some times doesnt work i cdont understand

                     

                    instead of using <h:commandButton i used <a4j:commanButton  same manner.

                    sometimes doesnt work.

                    • 7. Re: problem with a4j:commandButton and h:comandButton
                      Ilya Shaikovsky Master
                      <h:commandButton id="btnKitapBasliklariEkle" action="#{kitapEkle.kitapBasligiEkle}"
                                                                       value="ekle">
                                                          <a4j:support  event="onclick" ajaxSingle="true" process="txtKitapBasliklari" reRender="gpKitapBasliklari"/>
                                                      </h:commandButton>

                      re-read my comments. I descried why this will not work.

                       

                      instead of using <h:commandButton i used <a4j:commanButton  same manner.

                      if "in the same manner" mean with nested support - will also not work according to the same reasons.

                      • 8. Re: problem with a4j:commandButton and h:comandButton
                        Erman bas Newbie

                        i try  using

                        <a4j:commandButton reRender="glMessages" action="#{kitapEkle.girisiTamamla}" id="btnKitapGirisiTamamla"   value="#{msgs.btnKitapGirisiTamamla}"/>

                         

                        but doent enter action nothing do no log no error no action

                        • 9. Re: problem with a4j:commandButton and h:comandButton
                          Erman bas Newbie

                            <h:commandButton action="#{kitapEkle.girisiTamamla}" id="btnKitapGirisiTamamla"   value="#{msgs.btnKitapGirisiTamamla}">
                                                          <a4j:support  event="onclick" ajaxSingle="true" process="txtKitapBasliklari" reRender="gpKitapBasliklari"/>

                                                      </h:commandButton>

                           

                          ok now it works,

                          • 10. Re: problem with a4j:commandButton and h:comandButton
                            Ilya Shaikovsky Master
                            remove gloobalOnly=true from messages component definition to check all the possible messages
                            • 11. Re: problem with a4j:commandButton and h:comandButton
                              Erman bas Newbie

                              but if i use only a4j:commandButton ,it doesnt enter action,

                              now,

                              if ise

                              <h:commandButton action="#{kitapEkle.girisiTamamla}" id="btnKitapGirisiTamamla"   value="#{msgs.btnKitapGirisiTamamla}">
                                                              <a4j:support  event="onclick" ajaxSingle="true" process="txtKitapBasliklari" reRender="gpKitapBasliklari"/>

                                                          </h:commandButton>

                              ok it enter the action

                               

                              but why  doesnt enter if i used only a4j:commanButton

                              • 13. Re: problem with a4j:commandButton and h:comandButton
                                Ilya Shaikovsky Master

                                When you getting answers like "it should not be used in that way" - you should not continue "playing with workarounds".. Just try to use as it should by design and solve concrete problems because workarounds will cause other problems in future and the new problems will appears even earlier than old ones disappears.

                                 

                                i removed gloobalOnly=true

                                and what do you see (when not using nested support)

                                • 14. Re: problem with a4j:commandButton and h:comandButton
                                  Erman bas Newbie

                                  both of them works same   logic,isnt it?

                                  i wonder only while nested one working ,another only using <a4j:command isnt.

                                   

                                  thanx for reply Ilya