2 Replies Latest reply on Mar 31, 2009 11:13 AM by mugglmenzel

    [a4j:actionparam] mapping from a javascript array to a bean

    pericoloso

      Hi everybody,

      If I map a javascript String to a String property of my backing bean using <a4jactionparam>, there is no problem :

      <script>
      var titi = new Array();
      titi[0] = 'creationDate';
      titi[1] = 'comment';
      </script>
      
      <a4j:commandButton value="Apply">
       <a4j:actionparam noEscape="true" name="selection" value="titi[1]" assignTo="#{myBean.myString}" />
      </a4j:commandButton>
      


      The problem is that I want to map a javascript created array of String.
      So I tried the same thing with a javascript Array :

      <a4j:commandButton value="Apply">
       <a4j:actionparam noEscape="true" name="selection" value="titi" assignTo="#{myBean.myList}" />
      </a4j:commandButton>
      


      But I get a ClassCastException. I tried to use a List or a String[] for myList, but I allways get the same exception.
      I think I could serialize my ajavascript Array and map it to my backing bean where convertion to a List or something else could be done, but it's a bit dirty and I'm pretty sure there is a good way to do this.
      The problem is that I don't know what to search, so any track of solution would be appreciated :)