4 Replies Latest reply on Sep 27, 2011 12:55 PM by tehackio teha

    Datatable row id switch tabpanel tab to view detailed reg tab

    tehackio teha Newbie

      Richafaces 4.0.0.Final
      GlassFish Server Open Source Edition 3.1.1 (build 12).

       

       

      I want set currentId and render it on the form in "editTab".

      "userHome" is a named(CDI bean), conversationscoped.

      I can set currentId, but can't switch tab, and, I can switch tab but currentId is not setted;

       

      I would like switch to the tab "editTab" and after, set currentId on the new conversation on "editTab";

       

      Anyone?

       

      <rich:tabPanel id="principal" switchType="ajax">

      <rich:dataTable var="reg" ...

      ...

      <rich:column>

                                                                  <h:form>

                                                                            <h:commandLink>

                                                                            <h:graphicImage value="resources/img/telescope.gif" />

        <a4j:param value="#{reg.id}" assignTo="#{userHome.currentId}" />

                                                                            <rich:toggleControl targetPanel="principal" targetItem="editTab"/>

                                                                            </h:commandLink>

                                                                  </h:form>

      </rich:column>

      ...

       

      <rich:tab id="editTab">

      <form>

      ...

        • 1. Re: toggleControl
          Ilya Shaikovsky Master

          In RF 4 you can't use forms inside tabs, accordion items and so on..  Only one form around whole tab panel could be used. That's because of JSF 2 limitation of adding the form programatically. (tab controls itself requires form around and in RF 4 we can't add it if developer not added it explicitly wrapping whole panel).

           

          So add form around tabpanel, remove from every tab and limit processing by playing with execute on your controls inside the tabs.

           

          P.S. could be good to rename the thread

          • 2. Re: toggleControl
            tehackio teha Newbie

            Thank you for answer. I remove the forms, but the problem persist.

            The tab switch but... conversation id for each tab is different and currentID is not setted, hence, the form in editTab is not loading.

             

            <h:form>

            <rich:tabPanel id="principal" switchType="ajax">

            <rich:dataTable var="reg" ...

            ...

            <rich:column>

            <h:outputText value="#{userHome.conversation.id}" />

            <a4j:commandLink execute="@this">

            <h:graphicImage value="resources/img/telescope.gif"/>

            <f:param name="cid" value="#{userHome.conversation.id}"/>

            <a4j:param value="#{reg.id}" assignTo="#{userHome.dao.currentId}"/>

            <rich:toggleControl event="click"  targetItem="editTab"/>

            </a4j:commandLink>

            </rich:column>

            ...

            <rich:tab id="editTab">

            <h:outputText value="#{userHome.conversation.id}" />

            <h:outputText value="#{userHome.dao.currentId}" />

            </rich:tab>

            ...

            </rich:tabPanel>

            </h:form>

            • 3. Re: toggleControl
              Ilya Shaikovsky Master

              <a4j:commandLink execute="@this">

              <h:graphicImage value="resources/img/telescope.gif"/>

              <f:param name="cid" value="#{userHome.conversation.id}"/>

              <a4j:param value="#{reg.id}" assignTo="#{userHome.dao.currentId}"/>

              <rich:toggleControl event="click"  targetItem="editTab"/>

              </a4j:commandLink>

              there you trying to submit the row id for editing and switch the tab in the same time. Then I think it will be better to remove the toggleControl. Currently you using 2 requests for that. toggleControl added to onclick sends switching event first and only then link itself submits the id.

               

              tabPanel provides activeItem binding to manage current page. So change code to make change and submission in one reqeust:

              <a4j:commandLink execute="@this">

              <h:graphicImage value="resources/img/telescope.gif"/>

              <f:param name="cid" value="#{userHome.conversation.id}"/>

              <a4j:param value="#{reg.id}" assignTo="#{userHome.dao.currentId}"/>

              <a4j:param value="editTabId" assignTo="#{controller.activeTab}"/>

              </a4j:commandLink>

              where

              <rich:tabPanel id="principal" switchType="ajax" activeItem="#{controller.activeTab}">

              and

              <rich:tab id="editTabId">

              And change render of the link to tabPanel id.

               

              Hope it helps.

              • 4. Re: toggleControl
                tehackio teha Newbie

                Thank you! It solves my problem but...

                When I click on tab "editTab", after I click on prior tab "searchTab" (that has dataTable), lastly I click on row reg(before all rigth), and nothing happens.

                 

                And.. can I pass parameters on tabChange?