Using Editor Templates for Repetitive Code
I’ve been doing a little bit of XPages control development lately, and if you ever dabble in the dark art of this you will realise there is a lot of repeating yourself when it comes to writing the getters and setters for Control properties.
If your control properties are going to support value binding, then you will do the same pattern over and over.
For the getter:
If property is set explicitly Then return property,
Otherwise, If there is value binding, compute and return the value.
Otherwise, return the default.
For the setter:
normal setter!
Eclipse (and therefore Domino Designer) supports the idea of Templates, there are many default templates available, but you can also craft your own, so if you do a lot of repetitive code, it might be worth having a look into creating your own templates to use.
So I made myself a nice little Editor Template (this one in Domino Designer as I do the prototyping in there before moving completed files out to an OSGi plugin in normal Eclipse).
I have submitted the template as an XSnippet To use, copy the xml to an XML file then go to
Domino Designer Preferences -> Java -> Editor ->Templates
Click Import, select the xml file and you will have a new template ‘vbgettersetter’ which means ValueBinding Getter and setter.
Here is a 2 Minute video of it in action.