cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing document library views: table.effectivity

billydekid
Star Contributor
Star Contributor
Hi,

I'm new on Alfresco development and just started with a little customization project.
I want to add more column headers on table view of document library page.
They are effectivity date information.

Editing share-documentlibrary-config.xml I can add more columns by adding these lines into table's view-renderer part:

                     {
                        "property": "cm:from",
                        "label": "table.effectivity.label.from",
                        "width": "100"
                     },
                     {
                        "property": "cm:to",
                        "label": "table.effectivity.label.to",
                        "width": "100"
                     }

My questions is about the label.
Page http://docs.alfresco.com/5.1/concepts/share-customizing-document-library-views.html at below paragraph explains:
"Note that the value of labels such as table.minimalist.label.name are set in properties files, so that multiple translations can be provided."

What is the "properties files"? and where is it?
I curious on that since if I set the label to "label.to" will display label.to on column header, not "Effective from/to" as it should be.

Thank you,
[bayu]
3 REPLIES 3

steven_okennedy
Star Contributor
Star Contributor
Hi

Alfresco allows for multi-language support by allowing different message bundles to be packaged with the system and using ids to allow the correct label to retrieved from whatever bundle is being used.

In your case with "label": "table.effectivity.label.from", this value is actually a message id that will be retrieved from the currently loaded language bundle for the current user
(as defined by their browser locale settings).  To make things not break, if Alfresco doesn't find a value for this message id in the bundle, it will display the message id as the message string (so you'll see "table.effectivity.label.from" on the screen).  This allows you, if you wish to use an actual value (e.g. "Effective From") as the label value but this is bad practice as you're hard coding to a single language.

To add in a properly localised string, you just need to add your key and your value to a messages property file. This is basically a small text file in the Java properties style, e.g.  my-ext.properties

table.effectivity.label.from=Effective From
table.effectivity.label.to=Effective To


You can then include language variants by creating copies of the file with the relevant locale in the name, e.g. my-ext_de.properties, my-ext-messages_fr.properties, my-ext_ru.properties etc.

Lastly, you need to let the application know about your resource bundle using a Spring Bean:

    <bean id="my-ext.resources"
          class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
        <property name="resourceBundles">
            <list>
                <value>alfresco.web-extension.messages.my-ext</value>
            </list>
        </property>
    </bean>


If you're using the Alfresco SDK to create an AMP file for your Share customisations, then you'll get all this done for you, in the src/main/amp/config/alfresco/web-extension/messages/ folder of your project.  All you'll need to do is add the properties to the file it creates for you.

Regards

Steven

For the existing codes (running version), where is the file defined actually?
If so, then we could edit it normally and without build any Java code.

steven_okennedy
Star Contributor
Star Contributor
Hi,

Editing the out of the box files direclty is likely to lead you into trouble, the time you save now by changing files directly usually gets paid back a number of times over when you do things like apply updates, migrate from one environment to another, redeploy your war files or just make a mistake and try to revert backwards.  The Alfresco SDK does almost all the heavy lifting for you these days, so if as you say you're starting a customisation project then it saves time to do it cleanly.

Alfresco is an extensible platform because it gives you a wide variety of extension points and ways to change the product, not because its possible to modify the war files.

If you want to know where the values are coming from in any case, this particular set of values is bundled with the document-list-v2 webscript at share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\documentlibrary\documentlist-v2.get.properties, but again I would not advise changing it - you'll see that recommendation all over the forums as well as in the documentation

Regards

Steven