Announcement Announcement Module
Collapse
No announcement yet.
Disable Functionality Issue on Filtering Select Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Disable Functionality Issue on Filtering Select

    Hi , i have created an ajax functionality through which i am populating data in my select boxes using ItemFileWriteStore class of Dojo.
    The functionality is that when i click on Author , Books of that Author get Populated.

    Using STS, Tomcat 6.0 , Jackson CodeHaus Json Processor ( jackson-mapper-asl 1.7.1)

    Here is the code

    Code:
    public class Books {
    
    @NotNull
    private long id ;
    private String name;
    
    }
    
    
    public class Author {
    
    @NotNull
    private long id ;
    private String name ;
    
    }
     <field:select field="author" id="com_test_author" itemValue="id" items="${author}" path="/author" />
     <field:select field="books" id="com_test_books" itemValue="id" items="${books}" path="/books" />
    
    <script type="text/javascript">
     			 dojo.require("dojo.data.ItemFileWriteStore");
             	 dojo.addOnLoad(function() {
    
                          var sourceWidget=dijit.byId(_author_id);
                          var targetWidget=dijit.byId(_books_id);
                         dojo.connect(sourceWidget, "onChange", dojo.partial(customEventHandler,targetWidget)); 
                                    
                                       function customEventHandler(target,value) {
    
                                                dojo.xhrGet({
     							url: "books/getBooks",
     							handleAs: "json",
     							content: {
     								id : value
     							},
     							load: function(response, ioargs) {
     								console.log(ioargs.xhr.status+"...Succeddds.........:");
                                                                    if(response==null) {
                                                                           targetWidget.attr("disabled","disabled");
                                                                   }
                                                                         targetWidget.attr("disabled","");
     								hanldeResponse(response, ioargs);
     							},
     							error:function(response, ioargs){
     								console.log(ioargs.xhr.status+"...error.........:"+response);
     							}
     							
     						});
    
                                              function hanldeResponse(response, ioargs){
                                                             var storeData = {
    											identifier:'id',
    											label:'name',
    											items: response
    								               };
    							target.displayedValue ='name';
    					                target.searchAttr ='name';		                 
    						        target.store = new dojo.data.ItemFileWriteStore({data: storeData});
                                                   }
    
                                            }
     			});
    
    From the server side , i am just Returning a Collection of Books
                 
              </script>
    Everything Works fine , i.e. When i change on Author , the particular Authors Books are populated. And when the Response is Null then the Books gets Disabled as i return a null if no Books are found on server side. List<Books> as null. When i change the selection again , some books get populated , but when i press on Submit , a null id of the books , even after selecting the book from the select box , is passed. It can be observed in Tamper data Addon that, in the post , the book id was passed, but at the server side , on debugging no id is received and it throws a NotNull Validation. This happens only When i use the disable functionality Else it works like a charm. Also , i cannot input any data in the Filtering select to match the name once i disable and then re-enable the filtering select box.
    Someone Please Help !
Working...
X