Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the issue is to use the built in struts2 functionality then one easy option is to render your view with freemarker, which readily supports the dynamic addition of attributes. </p> <p>If you are using conventions, it is VERY trivial you just need to create a file with a ".ftl" extension, if you are using xml it is also very easy just use the freemarker result type (see <a href="http://struts.apache.org/2.3.4.1/docs/Freemarker%20Support.html" rel="nofollow">here</a> for greater description):</p> <pre><code>&lt;action name="test" class="package.Test"&gt; &lt;result name="success" type="freemarker"&gt;/WEB-INF/content/testView.ftl&lt;/result&gt; &lt;/action&gt; </code></pre> <p>Here is example view using a map to dynamically add attributes (example also taken from liked page):</p> <pre><code>&lt;@s.textfield name="test" dynamicAttributes={"placeholder":"input","foo":"bar"}/&gt; </code></pre> <p>The dynamicAttributes would be extremely useful in all JSP UI tags but alas it is not currently implemented.</p> <p><strong>NOTE</strong>: There is one error/omission in the above link. It tells you to add the following line which causes an error in my environment (simply the line is not needed).</p> <pre><code>&lt;#assign s=JspTaglibs["/WEB-INF/struts.tld"] /&gt; </code></pre> <p>That is, this line in a file <em>all by it self</em> is sufficient for rendering a text element, no explicit tag library declaration needed!</p> <pre><code>&lt;@s.textfield name="test" dynamicAttributes={"placeholder":"input","foo":"bar"}/&gt; </code></pre> <p>There are a number of advantages to using freemarker over plain JSPs, so taking a moment to explore the syntax and using it for this one case may prove useful later. </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. This table or related slice is empty.
    1. 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