Category Archives: Tips

XPage : Dynamic field Binding

In my application I wanted to bind a viewScope variable with the field, but the key was not static. The viewScope key was generated based on some business logic. To solve this problem, I created a dataContext variable (whose name is constant) and computed the value of this (data context) variable. I wrote the code there to calculate the key name. Finally I binded the field with the viewScope variable as follows:

The dataContext variable:

The field binding:

Same technique can be extended to other objects like NotesDocument, NotesViewEntry, etc.

How to know validation of which control is getting failed

Sometimes in XPage applications it happens that our code do not run due to validation errors.
It becomes really difficult to debug if the form contains too many fields. To simplify the debug process in this scenario I have written a code snippet which gives client id of the control for which validation is getting failed.

XPages: Rendered Vs Loaded

Today I observed runtime error in one of my XPage. I investigated later and found that the error is occuring on a custom control which should not be rendered in this scenario. I have several custom controls added on my XPage and display only one custom control based on some condition, so I have computed the rendered property.
Now the question is, if the custom control is not rendered then why it is generating error?
I further investigated properties of the custom control and found there is a property “loaded”.

Rendered: it controls the visibility of the control, i.e., if it is true then the markup for this control will be added in the response.

Loaded: it controls the creation of control, i.e., if it is true then only the control is going to be created else it will not be created.

Coming to my problem, I moved my code from rendered to loaded property and everything is working fine. The custom control is not being created so there is no possibility of execution of any code inside that custom control.

Lotus Notes and Git

If multiple developers are working on a project it is possible that they do development on their local machine(Lotus Domino server is installed on their local machine). Everybody is working on separate module so they can work independently. After the development is complete we need to merge the changes done by every developer into single nsf file so that we can deploy. We used to make a list of design elements which we have modified/created/deleted during the development process, and based on that list from every developer we do merging. Since we are human, we are bound to make mistakes. This list is created manually so there is a possibility to make mistakes or miss out something. So after merging process all unit tests must be executed to ensure all changes has been merged.

To avoid this mistake and overhead of unit testing again and again, we need to automate this process. Let me tell you how we can automate it and ensure it would not break our application.

  1. Install Git on all developers machines for version controlling. This step is not required but it will help during merging process if some conflict arise. Git will give you list of all design elements which are created/modified/deleted without any error.
  2. There are two possibilities, either Git is installed on all developers machine or it is not installed on some/all of developers machine
    1. If Git is installed on all machines: We can use Git pull request to pull and merge all changes made. If a conflict arise(conflict arise only when if a change is made on same line and same file by two or more developers) Git will ask you how to resolve the conflict. We can select manual resolution to ensure we are not going to lose anything
    2. If Git is not installed:
      1. take ntf from all developers(e.g., app1.ntf, app2.ntf, app3.ntf, …)
      2. Create nsf(app.nsf) from first ntf(app1.ntf) and set up version controlling using Git for it.
      3. By default Git creates a branch and call it “master”. Commit all changes in master branch
      4. Create a new branch “app2″ and switch to this branch
      5. Go to Lotus Notes workspace and replace design of created nsf(app.nsf) with design of next template(app2.ntf). Once design replace is completed, it will automatically export all changes to Git repository.
      6. Commit all changes in current branch
      7. Perform step iii – vi for all templates
      8. Now we have all design changes recorded in Git on separate branches, we just need to merge it. Merge “app2″ branch with “master” branch and commit it, then merge next branch with master.
      9. Once this merging process is complete, open Domino Designer and sync the application with on disk project.
      10. You are done. Nothing more to do.

I explained above how can we use Git in our development environment and it gives us flexibility to work in distributed manner. It do not enforce all of us to use it. If few of us are not comfortable in using it they can easily avoid it without any complexity. If you are new to Git, I recommend you to read this documentation.

Install LAMP in UBUNTU 12.10 / 13.04 / 13.10

I installed Ubuntu 12.10 on my new laptop and now I have to setup LAMP on it. To setup LAMP I need to install Apache Web Server, PHP and MySQL.
For installation issue following commands:

Above command will download and install Apache Web Server. It will ask for permission to download the setup file. After completion of above command open the browser and browse following URL:

If it is opening properly, your web server is installed properly. Now we will install PHP:

Above command will download and install PHP and apache integration library. It will ask for permission to download the setup file.
To check the installation of php issue following command:

Write following code in this file and save it:

In the browser open following URL:

It will display PHP configuration details. We have installed PHP and integrated it with Apache Web Server.
If you are not getting required page the you need to restart Apache:

Our next task is to install MySQL server and PHP-MySQL connector. For this issue following command:

If you are running Ubuntu 13.10, issue following command:

It will download and install MySQL Server. After installation it will ask to setup root password for database server.
Now we have installed Apache Web Server, PHP and MySQL. For database management you may need phpMyAdmin. To install phpMyAdmin issue following command:

After installation open following URL:

You will get the login screen of phpMyAdmin.

Congrats, You are done!!