Announcement Announcement Module
No announcement yet.
CheckedMultiSelect and Roo Controller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • CheckedMultiSelect and Roo Controller

    I have been using all my Googling-ninja skillz to try and find a solution to this, but I can't seem to get a multi-select to work in Roo.

    My HTML code looks like this:
    HTML Code:
      			<form id="newArtForm" name="newArtForm" action="${add_user_art_base}${userObject.username}" method="post" enctype="multipart/form-data" >
    	  			<br/><label for="newArtTitle">Title: </label><input type="text" id="newArtTitle" dojoType="dijit.form.TextBox" name="newArtTitle" trim="true" />
    	  			<br/><label for="newArtDescription">Description: </label><textarea id="newArtDescription" name="newArtDescription" dojoType="dijit.form.Textarea" style="width:200px;"><jsp:text /></textarea>
    	  			<br/><label for="newArtCategories">Category: </label>
    	  			<select name="newArtCategories" id="newArtCategories" dojoType="dojox.form.CheckedMultiSelect" multiple="true">
    	  				<!-- This is a "Hack".  Need a better, more openly-compatible way to render these nested categories -->
    	  				<c:forEach items="${rootCategories}" var="category" varStatus="index">
    	  					<option value="${}">${}</option>
    	  					<c:if test="${not empty category.childCategories}">
    	  						<c:forEach items="${category.childCategories}" varStatus="childIndex1" var="child1">
    	  							<option value="${}"><span style="padding-left:10px">${}</span></option>
    	  							<c:if test="${not empty child1.childCategories}">
    	  								<c:forEach items="${child1.childCategories}" varStatus="childIndex2" var="child2">
    	  									<option value="${}"><span style="padding-left:20px">${}</span></option>
    	  			<br/><label for="newArtFile">File: </label><input type="file" id="newArtFile" name="newArtFile" />
    	  			<br/><input type="button" value="Submit Form" id="newArtBusyButton" dojoType="dojox.form.BusyButton" label="Upload" busyLabel="Submitting Form..." timeout="2000" />
    And on my controller:
       	public @ResponseBody String addUserArt(
       			@PathVariable("username") String username, 
       			@RequestParam(value="newArtTitle") String newArtTitle, 
       			@RequestParam(value="newArtDescription") String newArtDescription, 
       			@RequestParam(value="newArtCategories",required=false) Integer [] newArtCategories, 
       			@RequestParam(value="newArtFile") MultipartFile newArtFile, 
       			Model uiModel,
       			Principal principal) throws IOException {
        	SiteUser user = SiteUser.findSiteUsersByUsernameEquals(username).getSingleResult();
        	if(user!=null) {
    	    	ArtPiece art = new ArtPiece();
    	    	art.setUploaded(new Date());
    	    	return "{ status:ok }";
        	} else {
        		return "{ status:failed }";
    The problem is, the newArtCategories variable is alway null, no matter what I change it too or do on the UI. I tried making it a String and an array of Integers, but it still comes over as null. If I set the required to true, it fails because it's null.

    Anyone know where I have deviated from the path?

    Edit: I am pasting in the rendered HTML from doing a View Source.
    HTML Code:
      <form enctype="multipart/form-data" method="post" action=
      "/ArtSite/json/addUserArt/mbauer" name="newArtForm" id="newArtForm">
        <br />
        <label for="newArtTitle">Title:</label> <input trim="true" name="newArtTitle"
        dojotype="dijit.form.TextBox" id="newArtTitle" type="text" /><br />
        <label for="newArtDescription">Description:</label> 
        <textarea style="width:200px;" dojotype="dijit.form.Textarea" name=
        "newArtDescription" id="newArtDescription">
    </textarea><br />
        <label for="newArtCategories">Category:</label> <select multiple="true" dojotype=
        "dojox.form.CheckedMultiSelect" id="newArtCategories" name="newArtCategories">
          <option value="1">
          <option value="5">
          <option value="8">
            Computer Generated
          <option value="7">
          <option value="9">
          <option value="11">
            Natural World
          <option value="12">
            Human Experience
          <option value="13">
          <option value="6">
            One-Line Drawing
          <option value="10">
          <option value="14">
            Real World
          <option value="15">
          <option value="2">
          <option value="16">
            Dramatic Narrative
          <option value="19">
          <option value="20">
          <option value="17">
          <option value="18">
          <option value="3">
          <option value="22">
          <option value="21">
          <option value="4">
            Written Word
          <option value="23">
          <option value="24">
            Short Story
        </select><br />
        <label for="newArtFile">File:</label> <input name="newArtFile" id="newArtFile" type=
        "file" /><br />
        <input timeout="2000" busylabel="Submitting Form..." label="Upload" dojotype=
        "dojox.form.BusyButton" id="newArtBusyButton" value="Submit Form" type="button" />
    There may be something with how the page is rendering. I can add the full files if needed.
    Last edited by mbabauer; Nov 14th, 2011, 01:37 PM.

  • #2
    More information

    More information...used Chrome's Dev Tools to see what is actually getting rendered after Dojo and the rest of the JavaScript has its way. I couldn't paste it directly, so here is the pastebin link.

    One thing I noticed is that the options don't end up under the select tab. I think this is most likely the problem, but it would be nice to have some reassurance. So, this may just likely be a Dojo problem.


    • #3
      I wanted to update this posting in case someone else happens across it.

      The problem looks to be with Dojo. There is an open bug report here that discribes the problem, and has several suggested patches. I tried updating to dojo 1.6.1, then applied the suggestions in comment #12 on the bug report, but it still doesn't work. If you use the DOM inspector on your browser (I personally use Chrome), you will see that with the patched code, the hidden select does get the options set, but the DOM element node does not have a name. The result is that it doesn't get processed with the rest of the form.

      For now, I am switching my UI to use the plan vanilla MultiSelect. It's not really the component I want, but at least it works.


      • #4
        Hello mbabauer,
        I got the same problem but made it work.
        After you apply the patch you see here:
        you have also to modify the internal template in CheckedMultiSelect.js. It uses that (instead of CheckedMultiSelect.html) I think because is a "compiled" version of dojo.
        Here my working version:

        check my blog for the more clear steps to make it work:
        Last edited by Macs; Jan 26th, 2012, 07:01 AM.


        • #5
          Fantastic! Thanks for the help!