Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here’s how to create a simple JSON example using the Struts 2 jQuery plugin.</p> <ol> <li>Go to <a href="http://struts.jgeppert.com/struts2-jquery-showcase/index.action" rel="nofollow">Struts2 jQuery Plugin Showcase</a></li> <li>Navigate to <strong>Ajax Forms > Buttonset / Checkboxes</strong></li> <li>Review the code for <em>Buttonset that was populated from AJAX JSON Result</em>. This is code I selected to create a simple example.</li> <li>Create dynamic web project in Eclipse</li> <li>Create a Java package and name it <em>test</em>.</li> <li>Download the <a href="http://code.google.com/p/struts2-jquery/downloads/list" rel="nofollow">Struts 2 jQuery plugin showcase source</a> (<em>struts2-jquery-showcase-x.x.x-sources.jar</em>) and extract the JAR file.</li> <li>Import <code>Echo.java</code>, <code>JsonSample.java</code>, and <code>ListValue.java</code> into the <em>test</em> package and move the code into the package with quick fix.</li> <li>Change the class annotation in <code>Echo.java</code> and <code>JsonSample.java</code> to @<code>ParentPackage(value = "test")</code></li> <li>In addition to the standard Struts 2 libraries, ensure that the <em>struts2-json-plugin-x.x.x.jar</em>, <em>struts2-jquery-plugin-x.x.x.jar</em>, and <em>struts2-convention-plugin-x.x.x.jar</em> files are in your classpath.</li> <li><p>Create a <code>struts.xml</code> file and add the following XML:</p> <pre><code>&lt;struts&gt; &lt;constant name="struts.devMode" value="true" /&gt; &lt;constant name="struts.convention.action.packages" value="test" /&gt; &lt;package name="test" extends="json-default” namespace="/"&gt; &lt;/package&gt; &lt;/struts&gt; </code></pre></li> <li><p>Create an index.jsp file and insert the following code:</p> <pre><code>&lt;s:form id="form2" action="echo" theme="xhtml"&gt; &lt;s:url id="remoteurl" action="jsonsample" /&gt; &lt;sj:checkboxlist href="%{remoteurl}" id=“remoteCheckboxlist” name="echo" list="languageList" label="Language" /&gt; &lt;sj:submit targets="formResult" value="AJAX Submit" indicator=“indicator” button="true"/&gt; &lt;/s:form&gt; </code></pre></li> <li><p>Run the example.</p></li> </ol>
 

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