elstar IT

Fullstack | Java | Tech Speaker | Tech Coach | Frank van der Linden

  • About me
  • Blog license
  • My Open source projects

Control the labels in a XPage app

01-10-2014 4 responses flinden68 development

When I develop XPages applications I always use properties files, stored in the files section under Resources in the application.

When the application is finished I can easily copy the properties file and create a new language file, and  let it controlled by a Language bean to display the labels in the application based by a key. It is a easy way to give the application multi language support.

Back in my head there was all the time the need to give an administrator or editor of the application more control of the labels.

Over the weekend I made a ProperrtyHandler bean, but first I created a Property class. This is a very basic class, with only 2 properties, label and value.

 

loadPropertiesFromView method

This method is to collect all the documents from the view and store the value and key in the TreeMap. This method is triggered by the creating of the bean, so everything is in place to serve the front end

[dropshadowbox align=”none” effect=”lifted-both” width=”600px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ]loadPropertiesFromView[/dropshadowbox]

 

loadPropertiesFromFile method

This method is to collect all the rows from the default property file, located in the files section and store these values in a TreeMap, with the key as key and a Property object as Value.

Also the code store the key and value in documents, so the user can edit the lablels.

[dropshadowbox align=”none” effect=”lifted-both” width=”600px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ]loadPropertiesFromFile[/dropshadowbox]

 

Integrate everything

In my Language I made a small enhancement, to not collect the label from the property file, but from the PropertyHandler. In this way I don’t have to change the whole application.

[dropshadowbox align=”none” effect=”lifted-both” width=”600px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ]getLanguageString[/dropshadowbox]

And off course my Front end

To make it possible to control and edit the label values of my properties, I made 2 XPages. An overview with buttons to load the backend properties file.

[dropshadowbox align=”none” effect=”lifted-both” width=”600px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ]properties overview[/dropshadowbox]

a XPage to display the labels and key. Only the label is editable, because the key is needed in the application When the document is saved, the property in the TreeMap will also be updated.

[dropshadowbox align=”none” effect=”lifted-both” width=”600px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ]property document[/dropshadowbox]

 

As requested, I put the Java classes in GIT repository

https://github.com/flinden68/PropertyHandler4XPages

4 thoughts on “Control the labels in a XPage app”

  1. Markus says:
    13-10-2014 at 08:06

    Hi Frank,
    how can I save a changed properties file?

    Thanks a lot!
    Markus

    Reply
    1. Frank van der Linden says:
      24-10-2014 at 13:32

      I have looked into that, but till now I was not able to save the changes back to the properties file.
      This weekend I will have a next attempt, because I now know more about this process. In my current project at a customer I am into JSF.
      I will keep you posted.

      Reply
  2. Pingback: XPages tip: Multi language support for labels - elstar IT
  3. Pingback: XPages tip: Demo code for multi language support - elstar IT

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • « Xcode update breaks Bower, but there is a solution
  • Say hello to InstallJack »

Contact me

My name is Frank van der Linden and I am an independent software developer based in the Netherlands. The last 2 years I was awarded as IBM Champion. Also I am on the board of OpenNTF. My specialisations are Java, Web development and Domino.


If you want to hire me, please fill in the Contact form


IBM Champion web badge
Apache Logo

All the code on this blog are under the Apache License 2.0. For more details, see Apache License 2.0

Most recent posts

  • NL Portal, a open source project
  • 10th anniversary as a freelancer and more…
  • Engage 2020: Hello are you listening, There is stream for everything
  • Spring Cloud Function on Azure run locally
  • Deploy Spring Cloud Function to IBM Cloud

Latest reactions

  • Spring Cloud Function on Azure run locally - elstar IT on Deploy Spring Cloud Function to IBM Cloud
  • flinden68 on Quick XPages tip: add Fullcalendar plugin to your application
  • Rajesh samal on Quick tip: Swagger support for Spring Webflux
  • dsieyx on Quick XPages tip: add Fullcalendar plugin to your application
  • John on Named as IBM Champion 2019

Archive

  • November 2024
  • April 2024
  • March 2020
  • February 2020
  • January 2020
  • October 2019
  • September 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • January 2019
  • December 2018
  • October 2018
  • September 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • December 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014

Category

  • bluemix
  • business
  • cloudant
  • community
  • development
  • hrassistant
  • openntf
  • running
  • salesforce
  • Springboot
  • Tesla
  • trailrunning
  • Uncategorized
  • watson
  • OpenNTF
  • Collaboration Today
  • XSnippets
  • Stackoverflow
  • IBM Collaboration Solutions
  • Social Business Toolkit
  • About me
  • Dutch curriculum vitae
  • English curriculum vitae
  • Google+
  • LinkedIn profile
  • Twitter
  • Slideshare
  • Blog license
  • My open source projects