2 Replies Latest reply on Dec 29, 2011 9:27 AM by Pavel Zelenka

    Table filtering - setCaretToEnd

    Pavel Zelenka Newbie

      Hi,

       

      I have a problem with table filtering (RichFaces 3.3.3 and JSF 1.2). The problem is that cursor in input field doesn't stay there.

      The setCaretToEnd function is placed in script file which is referenced from template. It seems the function is called but it has no effect.

      Can anybody help?

       

      Thanks

       

      <?xml version='1.0' encoding='UTF-8' ?> 
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:rich="http://richfaces.org/rich"
            xmlns:h="http://java.sun.com/jsf/html">
      
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              <link href="#{facesContext.externalContext.requestContextPath}/css/default.css" rel="stylesheet" type="text/css" />
              <script src="${facesContext.externalContext.requestContextPath}/scripts/myscript.js" type="text/javascript"/>
              <title>...</title>
          </head>
      
          <body>
      
              <div style="width:1024px; margin-left:auto; margin-right:auto">
                  <div id="top" class="top">
                      <ui:insert name="top">
                          <h:form>
                              <rich:toolBar height="34" itemSeparator="line">
                                  <rich:toolBarGroup>
                                      <h:commandLink value="Pracovní výkazy EDS" action="vykaz" style="font-size: 14px"/>
                                  </rich:toolBarGroup>
                                  <rich:toolBarGroup>
                                      <h:commandLink value="Doručovatelé" action="dorucovatele" style="font-size: 14px"/>
                                  </rich:toolBarGroup>
                                  <rich:toolBarGroup>
                                      <h:commandLink value="Vozidla" action="vozidla" style="font-size: 14px"/>
                                  </rich:toolBarGroup>
                              </rich:toolBar>
                              <rich:separator height="4" lineType="none"/>
                          </h:form>
                      </ui:insert>
                  </div>
      
                  <div id="content" class="center_content">
                      <ui:insert name="content">Content</ui:insert>
                  </div>
              </div>
          </body>
      
      </html>
      

       

      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                      template="WEB-INF/template.xhtml"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      xmlns:a4j="http://richfaces.org/a4j">
          <ui:define name="content">
              <h:form>
                  <h:commandButton value="Tisk výkazů" action="#{reportBean.generatePDF}"/>
                  <h:commandButton value="Založit nový výkaz" action="novy"/>
                  <rich:dataTable id="table" value="#{vykazBean.vykazList}" var="item" binding="#{vykazBean.htmlDataTable}">
                      <f:facet name="header">
                          <rich:columnGroup>
                          ... header colums ...
                          </rich:columnGroup>
                      </f:facet>
                      <rich:column filterExpression="#{fn:containsIgnoreCase(item.rok, sessionBean.rokFilterValue)}">
                          <f:facet name="header">
                              <h:inputText id="frok" value="#{sessionBean.rokFilterValue}" style="width:40px">
                                  <a4j:support event="onkeyup" reRender="table" ignoreDupResponses="true"  oncomplete="setCaretToEnd(event)"/>
                              </h:inputText>
                          </f:facet>
                          <h:outputText value="#{item.rok}"/>
                      </rich:column>
                      <rich:column filterExpression="#{fn:containsIgnoreCase(item.tyden, sessionBean.tydenFilterValue)}">
                          <f:facet name="header">
                              <h:inputText id="ftyden" value="#{sessionBean.tydenFilterValue}" style="width:30px">
                                  <a4j:support event="onkeyup" reRender="table" ignoreDupResponses="true"  oncomplete="setCaretToEnd(event)"/>
                              </h:inputText>
                          </f:facet>
                          <h:outputText value="#{item.tyden}"/>
                      </rich:column>
      
                     ... other columns ...
      
                  </rich:dataTable>
              </h:form>
          </ui:define>
      
      </ui:composition>