1 Reply Latest reply on May 2, 2009 9:31 AM by Nick Belaevski

    actionparam converter

    Kerdudou Ronan Apprentice

      is it planned to finish the dev of org.ajax4jsf.component.UIActionParameter ?
      it contains the following TODO : "perform conversion if converter is present".

      Because i need to use a 'converter' on an 'actionparam' and without hacking, it doesn't work...

      I wanted to do (and I would like to do) :

      <a4j:jsFunction name="_onModificationValeurImputation#{rowCategorie}"
       action="#{ressourcesHandler.onModificationValeurImputation}"
       reRender="#{ressourcesHandler.columnsToReRender}">
       <a4j:actionparam name="value" assignTo="#{ressourcesHandler.value}"
       converterId="#{ligneCategorie.categorie.converterId}" />
       <a4j:actionparam name="idProjet" assignTo="#{ressourcesHandler.idLigneProjetModifiee}" />
       <a4j:actionparam name="idPhase" assignTo="#{ressourcesHandler.paramId}" />
       <a4j:actionparam name="idColonne" assignTo="#{ressourcesHandler.idColonne}" />
       <a4j:actionparam name="columnsToReRender" assignTo="#{ressourcesHandler.columnsToReRender}"/>
      </a4j:jsFunction>
      but param 'converterId' doesn't exist...

      so I tryed :
      <a4j:jsFunction name="_onModificationValeurImputation#{rowCategorie}"
       action="#{ressourcesHandler.onModificationValeurImputation}"
       reRender="#{ressourcesHandler.columnsToReRender}">
       <a4j:actionparam name="value" assignTo="#{ressourcesHandler.value}" >
       <f:converter converterId="#{ligneCategorie.categorie.converterId}" />
       </a4j:actionparam>
       <a4j:actionparam name="idProjet" assignTo="#{ressourcesHandler.idLigneProjetModifiee}" />
       <a4j:actionparam name="idPhase" assignTo="#{ressourcesHandler.paramId}" />
       <a4j:actionparam name="idColonne" assignTo="#{ressourcesHandler.idColonne}" />
       <a4j:actionparam name="columnsToReRender" assignTo="#{ressourcesHandler.columnsToReRender}"/>
      </a4j:jsFunction>
      but 'f:converter' doesn't support 'a4j:actionparam '...

      then I created my own converterFactory and did :
      <a4j:jsFunction name="_onModificationValeurImputation#{rowCategorie}"
       action="#{ressourcesHandler.onModificationValeurImputation}"
       reRender="#{ressourcesHandler.columnsToReRender}">
       <a4j:actionparam name="value" assignTo="#{ressourcesHandler.value}"
       converter="#{converterFactoryHandler.converter[ligneCategorie.categorie.converterId]}" />
       <a4j:actionparam name="idProjet" assignTo="#{ressourcesHandler.idLigneProjetModifiee}" />
       <a4j:actionparam name="idPhase" assignTo="#{ressourcesHandler.paramId}" />
       <a4j:actionparam name="idColonne" assignTo="#{ressourcesHandler.idColonne}" />
       <a4j:actionparam name="columnsToReRender" assignTo="#{ressourcesHandler.columnsToReRender}"/>
      </a4j:jsFunction>
      (using Map interface to be able to give a param to the getter function)

      it was still not-functionning so i went in the actionparam's code

      And Finally I edited org.ajax4jsf.component.UIActionParameter to make it use the provided 'converter' param :-)
      public Converter getConverter() {
       //HACK Begin
       if (null != _converter) {
       return _converter;
       }
       ValueExpression ve = getValueExpression("converter");
       if (ve != null) {
       _converter = (Converter)ve.getValue(getFacesContext().getELContext());
       }
       //HACK End
       return _converter;
      }


      now that works...
      but i don't like overriding 3rd party packages like that...

      thanks in advance for completing your code (as i did or in a better way)
      is there a jira for this TODO ? (i didn't find it)


        • 1. Re: actionparam converter
          Nick Belaevski Master

          Hello Ronan,

          Works fine for me:

          <a4j:actionparam name="username" assignTo="#{userBean.name}" value="12345" converter="javax.faces.Integer"/>
          

          either as:
          <a4j:actionparam name="username" value="12345" assignTo="#{userBean.name}" converter="#{userBean.converter}"/>
          

          Tested with the latest 3.3.1-snapshot/Facelets. Are you using JSP?

          P.S. I'm going to move this thread into users forum, looks like it is usage question...