11 Replies Latest reply on Mar 20, 2008 9:09 AM by rulinsun

    Need help on rich:tab issue

      Hi,

      I have a tabPanel in my application, I need tell backbean which tab user clicked. I tried to use an inputHidden field and onclick callback on rich:tab.
      Unfortunetaly, the onclick(or onlabelclick) never get triggered. Even just put onclick="alert('hi');", nothing happen. I am using 3.1.4 GA release.

      Any advice?

      Thanks!

      Rulin Sun

        • 1. Re: Need help on rich:tab issue

          try this:

          <rich:tabPanel switchType="ajax" selectedTab="#{richTabPanelHelper.selectedTab}">


          • 2. Re: Need help on rich:tab issue

            Thanks for the reply. This is not related to my problem. From my understanding, selectedTab tells which tab (matching the name attribute of a tab) will be selected when the page is rendered. The value can be assigned from backbean, something like in your example.

            But when user changes the selectedTab by click an unselectedTab, the property value of the backbean binding by selectedTab will not change. So from backbean, you can not tell which tab is reselected. That's my problem

            Thanks!

            Rulin

            • 3. Re: Need help on rich:tab issue

              ah - you are using switchType client, are you?

              • 4. Re: Need help on rich:tab issue

                No, I am using switchType="server"

                • 5. Re: Need help on rich:tab issue

                  works for me

                  did you actually try it?

                  • 6. Re: Need help on rich:tab issue

                    I tried switchType="ajax" too. I question is basically why "onclick never triggered".

                    As to the selectedTab, my understanding is oneway binding, you can assign a value from backbean to change selected tab (even to a tab other than user clicked), but the value in the backbean will not change when user switch tab.

                    • 7. Re: Need help on rich:tab issue

                       

                      "rulinsun" wrote:
                      I tried switchType="ajax" too. I question is basically why "onclick never triggered".


                      I also have no idea.

                      "rulinsun" wrote:
                      As to the selectedTab, my understanding is oneway binding, you can assign a value from backbean to change selected tab (even to a tab other than user clicked), but the value in the backbean will not change when user switch tab.

                      I doubt that, since the code I've pasted works for me and the value of my backing bean changes, when I select a different tab.
                      again - did you actually try this?

                      • 8. Re: Need help on rich:tab issue

                        I think I know why it works for you. You put the backbean is session scope. I can't do that. The reason is if user changes the tab in one window, it will change the tab in a spawed window of same session.

                        • 9. Re: Need help on rich:tab issue

                           

                          "rulinsun" wrote:
                          I think I know why it works for you. You put the backbean is session scope. I can't do that. The reason is if user changes the tab in one window, it will change the tab in a spawed window of same session.


                          actually it's in page scope - should work 4 U.

                          • 10. Re: Need help on rich:tab issue
                            ilya_shaikovsky

                            if you use not client side switching just try f:param to put for example name of tab in requestParametersMap ;)

                            • 11. Re: Need help on rich:tab issue

                              Thanks! This works! I like to share the codes, in the application, we have dynamic number of tabs, under each tab we have a table with dynamic number of columns and heads, we also has a customization page to allow the user change Tab display and table dimesion. All of the information can determined by selectedTab id,

                              source of xhtml page:

                              <rich:tabPanel styleClass="mytable"
                              selectedTab="{controller.selectedId}"
                              switchType="server">
                              <c:forEach items="#{controller.tableDefinitions}" var="definitionEntry">
                              <rich:tab id="#{definitionEntry.id}"
                              name="#{definitionEntry.id}"
                              label="#{definitionEntry.viewTitle}"
                              action="#{controller.loadTableDefinition}"
                              >
                              <f:param name="selectedTab" value="#{definitionEntry.id}" />
                              <c:if test="#{controller.selectedDefintion.id eq definitionEntry.id}">
                              <ui:include src="table_view.xhtml" >
                              <ui:param name="viewId" value="{definitionEntry.id}"/>
                              </ui:include>
                              </c:if>
                              </rich:tab>
                              </c:forEach>
                              </rich:tabPanel>

                              Backend

                              public String loadTableDefinition(){
                              if(getTableDefinitions()==null ||
                              getTableDefinitions().size()==0) {
                              loadDefinitionsFromDatabase();
                              }
                              FacesContext context = FacesContext.getCurrentInstance();
                              HttpServletRequest request =(HttpServletRequest) context.getExternalContext().getRequest();
                              Map<String, Object> params = request.getParameterMap();
                              for (String param : params.keySet()) {
                              if(param.equals(Constants.TAB_SELECTION_KEY)){
                              String[] values = (String[])params.get(param);
                              selectedId = values[0];
                              break;
                              }
                              }
                              ...