2 Replies Latest reply on Nov 27, 2007 10:53 AM by Stan Silvert

    ClassCastException on ajaxSubmit with parameters

    John Gilbert Apprentice

      I am getting this exception on ajaxSubmit when I have parameters.

      java.lang.Long
      
      java.lang.ClassCastException: java.lang.Long
      at org.jboss.jsfunit.richfaces.Ajax4jsfClient.addExtraA4JParams(Ajax4jsfClient.java:208)
      at org.jboss.jsfunit.richfaces.Ajax4jsfClient.ajaxSubmit(Ajax4jsfClient.java:177)
      at org.jboss.jsfunit.richfaces.Ajax4jsfClient.ajaxSubmit(Ajax4jsfClient.java:152)
      at com.comcast.catalog.qa.MyJSFUnitTest.testDelete(MyJSFUnitTest.java:216)
      


      Here is my facelet snippet.

      <a4j:htmlCommandLink id="deleteLink" action="#{editor.delete}"
       <f:param name="id" value="#{row.id}"/>
      </a4j:htmlCommandLink>
      


      This is the generated html.

      <a id="searchForm:searchTable:0:deleteLink" href="#"
      onclick="return _JSFFormSubmit('searchForm:searchTable:0:deleteLink','searchForm',null,{'id':34} )">
      


      This is the code with the exception:

       protected void addExtraA4JParams(PostMethodWebRequest req, Map options)
       {
       Map params = (Map)options.get("parameters");
       for (Iterator i = params.keySet().iterator(); i.hasNext();)
       {
       String param = (String)i.next();
       req.setParameter(param, (String)params.get(param));
       }
       }
      


      I haven't tried this yet, but I suspect it could be changed to something like this:

       req.setParameter(param, params.get(param).toString());
      


      Thoughts?