Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot focus on form tags in stuts2 div after submit
    primarykey
    data
    text
    <p>I have a struts2 project which uses a tabbed panel. The tabs are jsp pages within divs. When you first select the tab the javascript at the end of the page sets the focus on the desired input field. Once you hit submit though the tab comes back with no focus in the input field. I have debugged it extensively to see what is happening, and I've noticed that the javascript at the end of the page is running, but it just cannot focus in the field. It can see the field through getElementById and even get it's value (i've tested this with alerts) but it cannot do anything TO the field. It cannot put text in either through javascript. If I click on another tab and then click back the script the focus is restored.</p> <p>The submit and textfield in the tab are below:</p> <pre><code>&lt;s:form id="myForm" action="myTabAction.do" method="post" validate="true" &gt; . . . &lt;s:submit name="submitz" value="Save" id="billbo" formId="myForm" executeScripts="true" href="myTabAction.do?submit=Save" targets="myTab" showLoadingText="false" theme="ajax" cssClass="buttonSmallClass" indicator="loadingImage_case" /&gt; . . . &lt;s:textfield name="testVal" maxlength="80" id="textField" cssClass="textClass" /&gt; </code></pre> <p>The javascript at the end of the tab jsp is as follows:</p> <pre><code>. . . &lt;/s:form&gt; &lt;/table&gt; &lt;script type="text/javascript"&gt; var field = document.getElementById("textField"); field.focus(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The relevant parts of the parent page are:</p> <pre><code>&lt;s:tabbedPanel selectedTab="%{selectedTabId2}" id="CasePartyTabbedPanel" theme="ajax" requiredposition="left" cssClass="subTabedpanelClass" cssStyle="width: 710px; height: 200px;" doLayout="false" templateCssPath="includes/TabContainer.css"&gt; . . . &lt;s:div label="My Label" id="myTab" href="MyAction.do?param1=%{paramVal1}&amp;param2=%{paramVal2}" theme="ajax" cssStyle="display:none" refreshOnShow="true" executeScripts="true" &gt; &lt;p&gt;Loading... &lt;/s:div&gt; &lt;/s:tabbedPanel&gt;&lt;/td&gt; </code></pre> <p>I am using struts 2.0.9 with dojo.</p> <p>I really need to find out how to set the focus to the input field after a submit. Any help would be greatly appreciated. Sorry if it is a bit long winded, but I wanted to be clear.</p> <p>Thanks</p> <p>Bill</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload