0 Replies Latest reply on Jul 7, 2012 6:23 AM by kwutzke

    RF 4: Setting focus on search inputText inside rich:dataTable (without using render="...@body")

    kwutzke

      Hello,

       

      I'm stuck on the issue here (NO NEED TO READ IT ALL, just notice that I have two columns in a table, the first one is filtered by an inputText):

       

      https://community.jboss.org/thread/201628

       

      Here's the current code:

       

      {code:xml}

        <rich:dataTable value="#{testBean.filteredDocumentGroups}"

                        var="dg"

                        rows="4"

                        footerClass="center"

                        id="repo-tdoc-datatable">

          <f:facet name="header">

            <rich:columnGroup>

              <rich:column>

                <h:panelGrid columns="1" style="width: 100%;">

                  <h:outputText value="Title" />

                  <h:inputText value="#{testBean.searchString}"

                               style="width: 70px;"

                               id="repo-tdoc-search-input">

                    <a4j:ajax execute="@this" render="repo-tdoc-datatable repo-tdoc-datascroller" event="keyup" oncomplete="rich:component(‘repo-tdoc-search-input’).focus();" />

                  </h:inputText>

                </h:panelGrid>

              </rich:column>

              <rich:column><h:outputText value="File Name" /></rich:column>

            </rich:columnGroup>

          </f:facet>

          <rich:collapsibleSubTable value="#{dg.documents}"

                                    var="doc"

                                    rowKeyVar="rowNbr">

            <rich:column rowspan="#{dg.numDocuments}"

                         rendered="#{empty rowNbr or rowNbr eq 0}">

              <h:outputText value="#{dg.title}" />

            </rich:column>

            <rich:column styleClass="left">

              <h:outputText value=" #{doc.fileName}" />

            </rich:column>

          </rich:collapsibleSubTable>

          <f:facet name="footer">

            <rich:dataScroller id="repo-tdoc-datascroller" />

          </f:facet>

        </rich:dataTable>

      {code}

       

      What I'm trying to do now is to filter the list of elements by hand (filteredDocumentGroups), so this requires me to render the whole table like

       

      {code:xml}<a4j:ajax execute="@this" render="repo-tdoc-datatable repo-tdoc-datascroller" event="keyup" />{code}

       

      instead of just

       

      {code:xml}<a4j:ajax execute="@this" render="repo-tdoc-datatable@body repo-tdoc-datascroller" event="keyup" />{code}

       

      as also described here: https://community.jboss.org/thread/166709

       

      However, the latter (@body) doesn't re-read the list of items and the former (without @body) loses the focus of the inputText, which gets rendered because it is inside the updated dataTable.

       

      Question:

      How do you set the focus on the inputText inside the whole rerendered dataTable, that is without using @body?

       

      The code

      {code:xml}<a4j:ajax execute="@this" render="repo-tdoc-datatable repo-tdoc-datascroller" event="keyup" oncomplete="rich:component(‘repo-tdoc-search-input’).focus();" />{code}

       

      does nothing.

       

      What's wrong?

       

      Karsten

       

      PS: There used to be a4j:support focus="" for this in RF3. I have no idea why it's not in RF4.