Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>Scriptlet</code>s are the old way of doing things, <a href="https://stackoverflow.com/a/3180202/1654265">you should avoid writing <code>Java</code> code in <code>JSP</code>'s at all</a>; <br>Struts2 helps you achieving the same goals using its tags and <code>OGNL</code> only. </p> <p>The <code>&lt;input /&gt;</code> part is working because you are injecting a <code>scriptlet</code> inside an HTML tag, that is allowed. </p> <p>The <code>&lt;s:select /&gt;</code> part is not working because you are injecting a <code>scriptlet</code> inside an Struts2 tag, that is not allowed.</p> <p>To make it work, you should use <code>#attr</code> syntax in <code>OGNL</code> to access the <code>Java</code> variables declared in <code>Scriptlets</code> and pushed <em>by you</em> in the <code>Page Context</code>, like this (completely untested):</p> <pre class="lang-xml prettyprint-override"><code>&lt;% for (int counter=0;counter&lt;myList.size();counter++) { // pushing it into the pageContext pageContext.setAttribute("counter",counter); %&gt; &lt;s:select cssClass="login-textbox" cssStyle="width:130px" list="#masterColDO.validation" name="chngdColumnValues" id="%{'columnId' + #attr['counter']}" /&gt; &lt;% } %&gt; </code></pre> <p>However, even if it's technically possible, it is discouraged. You should use the pure Struts2 way for that, that would be the following:</p> <pre class="lang-xml prettyprint-override"><code>&lt;s:iterator value="myList" status="ctr"&gt; &lt;s:select cssClass="login-textbox" cssStyle="width:130px" list="#masterColDO.validation" name="chngdColumnValues" id="%{'columnId' + #ctr.index}" /&gt; &lt;/s:iterator&gt; </code></pre> <hr> <p>P.S: Struts tags doesn't have any <code>styleClass</code> attribute; you can use <code>cssClass</code> and/or <code>cssStyle</code>; <br> And, if <code>controlType</code> is a String, you should use <code>.equals</code> instead of <code>==</code>: <code>&lt;s:if test="%{#masterColDO.controlType.equals('dropdown')}"&gt;</code>.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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