1 2 Previous Next 19 Replies Latest reply on Feb 20, 2008 10:32 AM by pdaniel

    commandButton problem

    pdaniel

      Hello. When i include a page with <a4j:include and in that page i have a command button, this does not work. If i put the same button in the main page not in the included one the problem is solved. Why i cannot use this command button in a included file?

        • 1. Re: commandButton problem
          pdaniel

          Any idea?

          • 2. Re: commandButton problem
            ilya_shaikovsky

            But what did you mean by not working?? It's very hard to tell anything using such description. I can answer you - look at demosite.. all works fine there.

            • 3. Re: commandButton problem
              pdaniel

              I have a search page. When i click on search button the table is populated with data. This table is included in the main search page. In these table page i have a button, next... When i click on the next button the new page that this button calls is rendered (but this only after the page refresh : F5) in place where my table was rendered, not replacing the entire page. So i will have the search options and under the search options i have this new page rendered on a partial area. Also i have a javascript error : Object Required. this error appears even when the works properly.

              • 4. Re: commandButton problem

                code snippet is much better than millions of words

                • 5. Re: commandButton problem
                  pdaniel

                  ok, here it is :

                  main search page:


                  <a4j:portlet
                  xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:a4j="http://richfaces.org/a4j">
                  <f:view>
                  <h:form id="portlet_form">
                  <h:panelGrid columns="2">
                  <h:outputLabel for="ss" value="ss:" />
                  <h:inputText label="ss" value="#{bean.ss}" id="ss"/>
                  <h:outputLabel for="mm" value="mm:" />
                  <h:inputText label="mm" value="#{bean.mm}" id="identityNumber"/>
                  <h:outputLabel for="rr" value="rr :" />
                  <h:inputText label="rr" value="#{bean.rr}" id="rr"/>

                  <a4j:commandButton action="#{controller.executeSearch}" value="Search" reRender="documentSearchResults" />

                  </h:panelGrid>
                  <!--<a4j:commandButton action="newdocument" value="Next" />-->
                  <a4j:include viewId="/portlets/myportlet/jsf/xhtml/include/result_table.xhtml" rendered="true" />

                  </h:form>
                  </f:view>
                  </a4j:portlet>



                  result_table page


                  <f:subview id="resultTable"
                  xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:t="http://myfaces.apache.org/tomahawk"
                  xmlns:rich="http://richfaces.org/rich">
                  <h:panelGroup id="documentSearchResults">
                  <rich:dataTable var="docsearch" rendered="#{not empty bean.listBean}" value="#{bean.listBean}" cellpadding="2" cellspacing="2" width="100%">
                  <f:facet name="header">
                  <rich:columnGroup rendered="true" >
                  <rich:column rendered="true">
                  <h:outputText value="Id"/>
                  </rich:column>
                  <rich:column rendered="true">
                  <h:outputText value="tdd"/>
                  </rich:column>
                  ....................................
                  <rich:column rendered="true">
                  <h:outputText value="actions"/>
                  </rich:column>
                  </rich:columnGroup>
                  </f:facet>
                  <rich:column>
                  <h:outputText value="#{docsearch.docId}"/>
                  </rich:column>
                  <rich:column>
                  <h:outputText value="#{docsearch.tdd}"/>
                  </rich:column>
                  ................................................................................
                  <rich:column>
                  <!--<a4j:form>-->

                  <a4j:commandButton actionListener="#{controller.executeView}" value="#{docsearch.docId}" image="/images/edit.gif" reRender="table" oncomplete="javascript:Richfaces.showModalPanel('panel');" />
                  <a4j:commandButton actionListener="#{controller.executeView}" value="V" reRender="table" oncomplete="javascript:Richfaces.showModalPanel('panel');">
                  <a4j:actionparam name="doc_view_id" value="#{docsearch.docId}"/>
                  </a4j:commandButton>
                  <!-- </a4j:form>-->
                  </rich:column>

                  <f:facet name="footer">
                  <a4j:commandButton action="newdocument" value="New document" />
                  </f:facet>

                  </rich:dataTable>
                  </h:panelGroup>
                  <a4j:include viewId="/portlets/myportlet/jsf/xhtml/include/panel/document_view_panel.xhtml" rendered="true" />
                  </f:subview>




                  Where i've put ................. I've replaced portions of the code to be a smaller post :)

                  My problem is when i click on "New document"

                  faces-config

                  <navigation-rule>
                  <from-view-id>*</from-view-id>
                  <navigation-case>
                  <from-outcome>newdocument</from-outcome>
                  <to-view-id>/portlets/myportlet/jsf/xhtml/newdocument.xhtml</to-view-id>
                  </navigation-case>
                  </navigation-rule>


                  • 6. Re: commandButton problem
                    pdaniel

                    Any idea why the button does not work?

                    • 7. Re: commandButton problem

                      at least, you have to provide an id for commandButton explicitly. Try this first.

                      • 8. Re: commandButton problem
                        pdaniel

                         

                        "SergeySmirnov" wrote:
                        at least, you have to provide an id for commandButton explicitly. Try this first.


                        I don't quite understand. You mean that i have to do something like :


                        <a4j:commandButton actionListener="#{controller.executeView}" id="myid" value="V" reRender="table" oncomplete="javascript:Richfaces.showModalPanel('panel');">


                        or that i have to give in the faces-config an ID for from-view-id? If this is the case i've done this already without result.

                        • 9. Re: commandButton problem
                          viggo.navarsete

                          pdaniel: Did you finally manage to fix this? I have a similar situation, with a search input field, a button (a4j:commandButton or h:commandButton..?), and a searchresult which is supposed to be shown to the user when he push the button. But I'm _NOT_ able to do it by ajax, to reRender a component based on the button pushed, it doesn't even seem like the action method is called. I'm confused!!

                          • 10. Re: commandButton problem
                            pdaniel

                            No i didn't managed to resolve it, you?

                            • 11. Re: commandButton problem
                              viggo.navarsete

                              no I didn't, and I haven't found any good examples either. Hopefulle someone at the Richfaces/Ajax4jsf team can come up with some tutorials/examples on these very normal use cases.

                              • 12. Re: commandButton problem
                                ilya_shaikovsky

                                Please create jira issue. Provide war with sources, libs and steps to reproduce described. It will be fastest way to reproduce and solve this.

                                Under our tests examples - this works..

                                • 13. Re: commandButton problem
                                  pdaniel

                                  I haven't seen any example regarding this classic use-case. Can you point us to this example?

                                  • 14. Re: commandButton problem
                                    ilya_shaikovsky

                                    I mean internal tests. Provide your own for investigations.

                                    1 2 Previous Next