2 Replies Latest reply on Mar 28, 2011 4:40 AM by Coen Damen

    commandLink inside datagrid doesn't fire correctly

    Coen Damen Novice

      Hi, I have the following form and a datagrid. Problem is the commandlink recalls/rerenders the same page instead of the correct url.


      I've tried all sorts of tweaks, changing it to ajax doesn't even refresh the page. When I put the commandlinks outside of the dataGrid the links work fine.


      Hope anyone knows a solution. Thanks,Coenos


      <h:form styleClass="Content">
                          <rich:panel style=" width : 584px; height : 595px; float: center;">
                               <f:facet name="header">
                                    <h:outputText value="Products"></h:outputText>
                               </f:facet>
      
                               <rich:dataGrid align="center"
                                    value="#{productRepos.getProductsByCategoryId(param.categoryId)}"
                                    var="product" columns="2" elements="9" width="550px"
                                    rendered="#{not empty productRepos.getProductsByCategoryId(param.categoryId)}">
                                    <rich:panel bodyClass="pbody">
                                         <f:facet name="header">
                                              <h:outputText value="#{product.name}"></h:outputText>
                                         </f:facet>
                                         <h:panelGrid columns="2">
                                              <h:panelGroup>
                                                   <h:outputText value="Price:" styleClass="label"></h:outputText>
                                                   <h:outputText value="#{product.currencyCode} #{product.price}" />
                                                   <br />
                                                   <h:outputText value="Rating:" styleClass="label"></h:outputText>
                                                   <h:outputText value="#{product.rating}" />
                                                   <br />
                                                   <h:commandLink value="details" action="productdetails.xhtml">
                                                        <f:param name="productId" value="#{product.id}" />
                                                   </h:commandLink>
                                                   <br />
                                                   <h:commandLink value="link" action="http://www.coenos.com" />
                                                   <br />
                                              </h:panelGroup>
                                              <h:graphicImage width="40" height="50" style="float: right;"
                                                   value="#{product.imageUrl}" />
                                         </h:panelGrid>
      
                                    </rich:panel>
                                    
                               </rich:dataGrid>
                          </rich:panel>
                     </h:form>
      
      



        • 1. Re: commandLink inside datagrid doesn't fire correctly
          Coen Damen Novice

          OK, I tried this piece of code which works fine.


          <h:form styleClass="Content">
                                          <h:outputLabel value="Products" />
          
                                          <rich:panel style="height : 704px; width : 577px;">
                                                  <f:facet name="header">
                                                          <h:outputText value="Car Store"></h:outputText>
                                                  </f:facet>
                                                  
                                                          <rich:dataGrid value="#{productCategoryRepos.allCategories}" var="cat"
                                                                  columns="2" elements="9" width="550px">
                                                                  <rich:panel bodyClass="pbody">
                                                                          <f:facet name="header">
                                                                                  <h:outputText value="#{cat.name}"></h:outputText>
                                                                          </f:facet>
                                                                          <h:panelGrid columns="2">
                                                                                  <h:panelGroup>
                                                                                  <h:outputText value="Name:" styleClass="label"></h:outputText>
                                                                                  <h:outputText value="#{cat.name}" />
                                                                                  <br />
                                                                                  <h:outputText value="Display Name:" styleClass="label"></h:outputText>
                                                                                  <h:outputText value="#{cat.categoryDisplayName}" />
                                                                                  <br />
                                                                                  <h:commandLink action="http://www.coenos.com" value="KLIK" />
                                                                                  <br />
                                                                                  </h:panelGroup>
                                                                                  <h:graphicImage width="40" height="50" value="/img/Emperor-Palpatine.jpg" />
                                                                          </h:panelGrid>
                                                                          
                                                                  </rich:panel>
                                                                  <f:facet name="footer">
                                                                          <rich:datascroller></rich:datascroller>
                                                                  </f:facet>
                                                          </rich:dataGrid>
                                          </rich:panel>
                                  </h:form>
          
          





          Is it because I call the pages without a navigation case??


          So this is my scenario:
          Main page with categories  -- call products page with parameter categoryId (works)
          Products by category page  -- call product detail page with parameter productId (does not work).


          Hope anyone knows a solution for this.
          Coen

          • 2. Re: commandLink inside datagrid doesn't fire correctly
            Coen Damen Novice

            So this is my scenario (now in correct formatting)


            Main page with categories -- call products page with parameter categoryId (works).


            Products by category page -- call product detail page with parameter productId (does not work).