cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Converter's with parameters?

ajv
Champ in-the-making
Champ in-the-making
Hello,

I want to apply a NumberConverter to a custom property with parameters (for formatting a custom metadata).
In the wiki it says (http://wiki.alfresco.com/wiki/Displaying_Custom_Metadata) how to assign a simple converter (one not requiring any parameters), but is it possible assign one converter with parameters??

I try with this (without parameters) in web-client-config-custom.xml config file:
<show-property name="qt:custom_property" show-in-edit-mode="false" converter="javax.faces.convert.NumberConverter"/>

But it fires NullPointerException:
08:27:23,302 ERROR [org.apache.myfaces.application.ApplicationImpl] Could not instantiate converter null
java.lang.NullPointerException


Any suggestion?
Thank you!
3 REPLIES 3

kevinr
Star Contributor
Star Contributor
This isn't possible at the moment - please raise JIRA item for it.

Thanks,

Kevin

gavinc
Champ in-the-making
Champ in-the-making
no, unfortunately, you can't use converters with parameters in the way you have tried (as you found out).

However, you could create a custom component generator for your property that as part of it's implementation created and attached a NumberConverter.

Have a look at the component generator wiki page: http://wiki.alfresco.com/wiki/Component_Generator_Framework and also the existing generators which can be found in org.alfresco.web.bean.generator

ajv
Champ in-the-making
Champ in-the-making
Hi, thanks for your reply.
I add an item (http://issues.alfresco.com/browse/AWC-1538) in JIRA.

Al the moment, I try to create a custom component generator.
Thanks,
Adrian.