Note that there are some explanatory texts on larger screens.

plurals
  1. POgoing crazy about the spring mvc checkbox
    primarykey
    data
    text
    <p>I got the checkbox working, but I can't remember what modification I have done to my code. it's never working again. it keeps saying:</p> <pre><code>org.springframework.web.servlet.tags.form.Checkbox Tag - java.lang.NullPointerException at org.springframework.web.servlet.tags.form.Selected ValueComparator.exhaustiveCompare(SelectedValueCom parator.java:157) </code></pre> <p>the java looks like this:</p> <pre><code>public class ServiceRequest implements Serializable { ...... private GenericAddress serviceAddress; private String problemDescription; private String referenceNumber; private String[] optionExchangeList = new String[10]; ...... </code></pre> <p>the jsp code looks like this:</p> <pre><code>&lt;INPUT TYPE="checkbox" NAME="addPrima" onclick="showHideDiv(this,'exchangeOfOption')"&gt; &lt;spring:message code="serviceRequest.label.ExchangeOfOption"/&gt;&lt;br /&gt; &lt;div id="exchangeOfOption" style="display:none; margin-left : 15px;" &gt; &lt;spring:message code="serviceRequest.label.OnsiteExchangeOfDevice"/&gt; &lt;form:checkbox path="serviceRequest.optionExchangeList" value="Duplex"/&gt;&lt;br /&gt; &lt;spring:message code="serviceRequest.label.Drawer"/&gt; &lt;form:checkbox path="serviceRequest.optionExchangeList" value="Drawer"/&gt;&lt;br /&gt; &lt;spring:message code="serviceRequest.label.Feeder"/&gt; &lt;form:checkbox path="serviceRequest.optionExchangeList" value="Feeder"/&gt;&lt;br /&gt; &lt;spring:message code="serviceRequest.label.MaintenanceKit"/&gt; &lt;form:checkbox path="serviceRequest.optionExchangeList" value="Maintenance Kit"/&gt;&lt;br /&gt; &lt;spring:message code="serviceRequest.label.Other"/&gt; &lt;form:checkbox path="serviceRequest.optionExchangeList" value="Other"/&gt; &lt;/div&gt; </code></pre> <p>it worked before. I even use optionExchangeList.toString() to look at the result. it was the names for the one I checked. (it's impossible huh? should be something like @afaswe) . and for now. I have to initialize the optionExchangeList as something like:</p> <pre><code>private String[] optionExchangeList = new String[]{"Duplex","Drawer"}; </code></pre> <p>and for Duplex and Drawer, they stayed checked in the browser. but for the rest field. they stayed unchecked, and even if I check them, they don't appear in the optionExchangeList if I print them out in the action method using something like:</p> <pre><code>for (String s:serviceRequest.optionExchangeList){ System.out.println(s+"\n"); } </code></pre> <p>the list stayed the same regardless the Checkbox status.</p> <p>Did I just have a dream??? or did I meet a ghost??? I am going crazy. HELP!!!!</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.
 

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