cancel
Showing results for 
Search instead for 
Did you mean: 

How to format custom aspects

redbull
Champ in-the-making
Champ in-the-making
I would add to my documents some "amount" custom aspects so that, when I enter the values and when I view the "amount" custom properties, they include formatting separators (eg. Total amount:   $1,350.58).
Is it possible? How can I do this?
Thanks so much.
6 REPLIES 6

loftux
Star Contributor
Star Contributor
Have a look at how you create custom forms. http://wiki.alfresco.com/wiki/Forms
In this case, you can copy the text field (textfield.ftl) control and make a copy of it. Call it something like currencyfield.ftl. In your forms definition, reference this new control.

In your new control, change the field for view mode. There is a currency formatter for freemarker, not sure if this will work for you, but check it out. http://freemarker.sourceforge.net/docs/ref_builtins_number.html#ref_builtin_string_for_number

redbull
Champ in-the-making
Champ in-the-making
thank you, Loftux.
maybe I was not precise.
To create my custom aspects and I followed the process of customizing the Alfresco content model, so:
1) I created my custom model context file (customModel.xml) with my custom aspects definition
2) I configure the web client for the custom aspect (web-client-config-custom.xml)
3) I use custom aspect in a new business rule when I add new content to my space.
To format my currency custom field I thought I would change something in these files. Or not?
thank you

loftux
Star Contributor
Star Contributor
web-client-config-custom.xml is for Alfresco Explorer, if that is what your are using, then web-client-config-custom.xml is on the right track. Next would be to create some jsf control/stuff, and that is out of my knowledge.

But if you are using Alfresco Share client, then what I pointed you at applies. If you are in the beginning of your project, I really recommend using the Share client.

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi Loftux,

You can create your  custom converter to display different format . Check byteSizeConverter which display the bytes along  with size . Try to follow the same flow and you will be able to create custom converter.

Thanks,

redbull
Champ in-the-making
Champ in-the-making
Amita, could you give me some more details about your hint?
thank you so much!

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi Loftux,

Here are the brief steps to create custom  converters :
1. Create a tag  in alfresco.tld  , sample of the tag is  given below:
     
 <tag>
      <name>convertSize</name>
      <tag-class>org.alfresco.web.ui.common.tag.ByteSizeConverterTag</tag-class>
      <body-content>JSP</body-content>
      <description>
         Allows the ByteSizeConverter to be used on a page
      </description>
      </tag>

2. Create  a java file similar to "ByteSizeConverterTag"  which must extends "ConverterTag" class . You can check the existing "ByteSizeConverterTag" class

3. Create a java file similar to  "ByteSizeConverter"  which must implement the interface "Converter" . You can check existing  "ByteSizeConverter" class. Implement logic of conversion in this class.

4. Make the changes accordingly in web-client-config-custom.xml to use the custom tag .

Thanks,