6 Replies Latest reply on Nov 27, 2008 10:00 AM by hwoarang

    a4j:include and focus

    dblue

      Hi!
      I have simple problem but I can't resolve it.
      My components in included pages are losing focus after any ajax action:

      This is my code:

      home.xhtml

      ...
      <ui:define name="body">
       <a4j:include id="inc" viewId="simple.xhtml"/>
      </ui:define>
      ...
      


      simple.xhtml
      <a4j:form id="dg" ajaxSubmit="true" xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j">
      <h:inputText id="myInput">
       <a4j:support ajaxSingle="true" process="colA" event="onkeyup" reRender="outtext"/>
      </h:inputText>
      <h:outputText id="outtext" value="#{rich:findComponent('myInput').value}" />
      </a4j:form>
      

      This is example with <h:inputText/> but it doesn't depends from the component type.
      After onkeyup event text field loses focus.

      This is my configuration:

      RichFaces 3.2.2
      Seam 2.0.2.SP1


      Where is my mistake ??
      Can anyone tell me ??

        • 1. Re: a4j:include and focus
          justinmbirch
          • 2. Re: a4j:include and focus
            dblue

            I was trying to put focus attribute in few places but it doesn't work propertly.

            1) When I put focus="myInput" in <a4j:form> tag - doesn't help.
            2) When I put focus="myInput" in <a4j:support> tag - it's almost working, and I think I could fix it to work with <h:inputText> tag.

            But what with components where I can't use <a4j:support> to catch event ?

            • 3. Re: a4j:include and focus
              ilya_shaikovsky

              Please use ajaxRendered="false" on your include and reRender its parent if you need navigation only from corresponding controls. include designed to be refreshed every ajax request as it designed for wizards creation.

              • 4. Re: a4j:include and focus
                dblue

                Now I see, I'm not very smart ;).
                Thanks for your help.
                Now, everything is working as I wanted.

                • 5. Re: a4j:include and focus
                  hwoarang

                  I have a similar problem: if my page has a4j:include tag, I can't set focus on modalPanel's elements when shown...

                  I'm pretty sure that is related with a4j:include, because when I remove the tag, the focus works...

                  Note: The page included is not the one that my modalPanel belongs. I put my modalPanel in my template (I'm using facelets).

                  Someone has another hint about?

                  my code:

                  modalPanel

                  <r:modalPanel
                   id="panel"
                   onshow="#{r:element('botaoOk')}.focus()"
                   showWhenRendered="#{facesContext.maximumSeverity != null}">
                   ...
                   <h:commandButton
                   id="botaoOk"
                   action="#{ControleApp.cancelarModal}"
                   value="#{msg.botaoOk}" />
                  


                  page with a4j:include
                  ...
                  <a4j:include
                   viewId="mpLocalizacao.jspx"
                   id="mpLocalizacao"
                   ajaxRendered="false">
                   <ui:param
                   name="paramId"
                   value="#{ManterPessoa.localizacaoId}" />
                  ...
                  


                  • 6. Re: a4j:include and focus
                    hwoarang

                    hmmm...
                    using ui:include works...

                    maybe some problem with a4j:include