4 Replies Latest reply on Nov 22, 2012 3:36 PM by aalbertopp

    rich:tab focus not working

    jhaley

      After a tab is selected, I'm trying to place focus on a rich:comboBox field. Below I have two ways to do it. I'm not sure why the first way does not work. The second way works (and it may be my best solution), but there seems to be a lag since an ajax call is invoked

      focus does not work

      <rich:tabPanel width="250" height="300" switchType="client">
       <rich:tab label="All" focus="availableArticlesFrm:categoryBasedOnFiltercomboboxField" >
       <t:panelGrid columns="2">
       <h:outputLabel for="categoryBasedOnFilter" value="Categories"/>
       <rich:comboBox id="categoryBasedOnFilter" valueChangeListener="#{roomCtrl.resetFilteredCategoryList}" value=""
       directInputSuggestions="true" listStyle="text-align:left;" width="150">
       <f:selectItems value="#{roomCtrl.categoryNameList}"/>
       <a4j:support event="onselect" ajaxSingle="true" reRender="filteredAvailableArticlesPanelBar"></a4j:support>
       </rich:comboBox>
       </t:panelGrid>
      


      focus does work
      <rich:tabPanel width="250" height="300" switchType="client">
       <rich:tab label="All" >
       <a4j:support event="onlabelclick" focus="availableArticlesFrm:categoryBasedOnFiltercomboboxField" ajaxSingle="true"></a4j:support>
       <t:panelGrid columns="2">
       <h:outputLabel for="categoryBasedOnFilter" value="Categories"/>
       <rich:comboBox id="categoryBasedOnFilter" valueChangeListener="#{roomCtrl.resetFilteredCategoryList}" value=""
       directInputSuggestions="true" listStyle="text-align:left;" width="150">
       <f:selectItems value="#{roomCtrl.categoryNameList}"/>
       <a4j:support event="onselect" ajaxSingle="true" reRender="filteredAvailableArticlesPanelBar"></a4j:support>
       </rich:comboBox>
       </t:panelGrid>
      


        • 1. Re: rich:tab focus not working
          ilya_shaikovsky

          1) focus attribute activated only after ajax request completion. So only works if your tabPanel ajax switched.

          2) I think just your custom js on ontabenter event (which will activate the comboBox) will be better that ajax reuqest firing which you described in second snippet.

          • 2. Re: rich:tab focus not working
            jhaley

            I tried using the ontabenter, but it product a script error. I know the script works because if i put it on a button's onclick event it work properly. The script error is "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus." So I'm guessing at the time the ontabenter fires the page has not been built


            <rich:tab label="All" ontabenter="document.getElementById('availableArticlesFrm:categoryBasedOnFiltercomboboxField').focus();" >
            


            • 3. Re: rich:tab focus not working
              ilya_shaikovsky

              yes sorry. this event is cancelable so fired before enter actually. Need to think about something else :)

              • 4. Re: rich:tab focus not working
                aalbertopp

                Great! I'm a Newbie and i did'nt know how to focus a rich combobox.

                Thanks a lot!