Hi,

i have the following JavaScript code that should execute a partial
submit. After the response is completed the focus should be set on the
input element that have triggered the request.

<tr:inputText label="#{bundle.searchPattern}"
  value="#{myBean.searchPattern}"
  onkeyup="clickButton_afterEnter(event, submitBtn, this);" />

<tr:commandButton id="submitSearch" action="#{myBean.executeSearch}"
  text="#{bundle.search}" partialSubmit="true" />

<tr:table partialTriggers="submitSearch" value="#{myBean.tableData}">
  <!-- my columns goes here -->
</tr:table>

<script type="text/javascript" language="javascript">
  // <![CDATA[
    var submitBtn = window.document.getElementById("submitSearch");
    var lastFocusElem = null;
                                
    function setFocus(state)
    {
      if(state != TrRequestQueue.STATE_BUSY)
      {
        if(lastFocusElem != null)
        {
          lastFocusElem.focus();
          lastFocusElem = null;
        }
 
TrPage.getInstance().getRequestQueue().removeStateChangeListener(setFocu
s);
      }
    }
                                
    function clickButton_afterEnter(evt, button, source)
    {
      evt = (evt) ? evt : (window.event) ? window.event : "";
      var keycode = evt.which ? evt.which : (evt.keyCode) ? evt.keyCode
: window.event.keyCode;
      if(keycode == 13)
      {
        var btn = (button == null) ? submitBtn : button;
        var form = document.forms[0];
        if(btn != null && form != null)
        {
          lastFocusElem = source;
 
TrPage.getInstance().getRequestQueue().addStateChangeListener(setFocus);
          TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
        }
      }
    }
  // ]]>
</script>

Unfortunately the focus is lost from the input field if I have pressed
the enter key and the response was completed.
Does anybody have an idea what is going wrong here?

Regards,

Sven

JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
Complexity, Compliance & Cost: Globale Herausforderungen und lokale Losungen
22. Oktober 2008 . Frankfurt am Main 

_______________________________
Think before you print
CONFIDENTIALITY: This e-mail (including any attachments) may contain 
confidential, proprietary and privileged information, and unauthorized 
disclosure or use is prohibited.  If you receive this e-mail in error, please 
notify the sender and delete this e-mail from your system.

SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt 
HRB 56839  Geschaftsfuhrer Harold Finders, Thorsten Junike, Dr. Dirk Luth, 
Michael Joseph Ruane, Victoria Elizabeth Silbey


Reply via email to