1 Reply Latest reply on Jan 25, 2011 9:55 AM by ilya40umov

    Field focus jumps unpredictably upon rerender

    tomba

      Hi,

       

      I'm having a quite annoying problem with a4j:support in the following structure:

       

      {code}

                              <rich:panel id="ps">

                              <a4j:region>

                              <mw:panel id="ps">

                                  <ui:repeat var="setting" value="#{quoteInput.service.pSettings}">

                                      <t:panelGrid columns="3">

                                          <h:outputLabel for="pcs" value="#{setting.labelText}:" />

                                          <h:selectOneListbox id="pcs" size="1" value="#{setting.value}">

                                              <f:selectItems value="#{setting.choiceItems}"/>

                                              <a4j:support event="onchange" reRender="ps" ajaxSingle="true" />

                                          </h:selectOneListbox>

                                          <h:message styleClass="error" for="pcs" />

                                      </t:panelGrid>

                                      <ui:repeat var="qsetting" value="#{setting.qSettings}">

                                          <t:panelGrid columns="3">

                                              <h:outputLabel value="#{qsetting.labelText}:"/>

                                              <h:panelGroup>

                                                  <h:inputText id="qinputn" value="#{qsetting.value}"/>

                                              </h:panelGroup>

                                          </t:panelGrid>

                                      </ui:repeat>

                                  </ui:repeat>

                              </mw:panel>

                              </a4j:region>

                              </rich:panel>

      {/code}

       

      Within this, when I switch the value of one of the generated pcs dropdowns, I perform a rerender of all code posted here ("ps"). It is possible that due to this switch, more or less qsetting elements will appear. All this works fine.

       

      The problem is that when doing so, after everything is done (oncomplete), for some reason the focus of my field is lost, and moved to an apparently random "pcs" dropdown. So, is there a possiblity to prevent this focus switching, or at least some explanation as to why this is happening?

       

       

      Thanks,

      Steven

        • 1. Field focus jumps unpredictably upon rerender
          ilya40umov

          When you are re-rendering the parent element a4j replaces it with all its children in DOM tree and thus the focus is lost. Try to re-render elements directly without the parent element if it's possible. I can see that now it's pretty hart to do but may be you can change some logic of the page?