Posts Tagged: ‘tipp’

XPages & Angular.js: AngScope for Firebug

6. Juni 2014 Posted by Sven Hasselbach

AngScope is a

“Simple Firebug extension that allows you to inspect the AngularJS scope that a DOM element binds to.”

Just do a right click on the DOM element you want to inspect and select “Inspect Angular Scope“:

This gives you a direct access to all elements of the scopes of your Angular.js application:

You can find the extension here.

XPages: Create a Database without Template

30. Mai 2014 Posted by Sven Hasselbach

On, an interessting topic was asked about how to create a notes database programmatically without using a template. The problem is, that it will not contain a Icon document. But in this document are all database properties stored. So the question is: How can you create this document?

Jesse Gallagher came up with the idea to use the DXL import and create the Icon document this way, which works fine. But the next problem is, that there is no ACL note in the database and no default view.

That’s why I modified his idea and created a Java Utility class. This class creates a new database which includes all of the required design elements.

package ch.hasselba.core;

import lotus.domino.ACL;
import lotus.domino.Base;
import lotus.domino.Database;
import lotus.domino.DbDirectory;
import lotus.domino.DxlImporter;
import lotus.domino.Session;

 * DB Utilities
 * @author Sven Hasselbach
 * @version 1.1
public class DBUtil {

     * creates a new database 
     * the database is identically to a database created by the -blank- template in designer.
     * The default access is set to Manager
     * @param session
     *             the session used to create the database
     * @param dbTitle
     *             the database title
     * @param dbPath
     *             the path of the database
     * @param dbServer
     *             the server 
     * @version 1.1
    public static void createDatabase( Session session,  final String dbTitle, final String dbPath, final String dbServer ) {
        DbDirectory dbDir = null;
        Database db = null;
        DxlImporter importer = null;
        ACL acl = null;

            // create a new database
            dbDir = session.getDbDirectory( dbServer );
            db = dbDir.createDatabase( dbPath );

            // initialize dxl importer
            importer = session.createDxlImporter();
            importer.setDesignImportOption( DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_CREATE );

            // generate DXL
            String dxl = generateDXL( dbTitle, dbPath, db.getReplicaID() );

            // import DXL
            importer.importDxl(dxl, db);

            // set ACL: Default to Manager
            acl = db.getACL();

        }catch(Exception e){
            recycleObj( acl );
            recycleObj( importer );
            recycleObj( db );
            recycleObj( dbDir );


     * generates the DXL for a blank database
     * @param dbTitle
     *            the title of the database
     * @param dbPath
     *             the path of the database
     * @param dbReplicaId
     *             the replica of the database
     * @return    String with DXL
     * @version 1.1
    private static String generateDXL( final String dbTitle, final String dbPath , final String dbReplicaId ){

        StringBuilder str = new StringBuilder();

        str.append("<?xml version='1.0' encoding='utf-8'?>");
        str.append("<!DOCTYPE database SYSTEM 'xmlschemas/domino_8_5_3.dtd'>");
        str.append("<database xmlns='' version='8.5' maintenanceversion='3.0' ");
        str.append( dbReplicaId );
        str.append("' path='");
        str.append( dbPath );
        str.append("' title='");
        str.append( dbTitle );
        str.append("' allowstoredforms='false' ");
        str.append("usejavascriptinpages='false' increasemaxfields='true' showinopendialog='false'>");
        str.append("<databaseinfo dbid='");
        str.append( dbReplicaId );
        str.append( "' odsversion='51' ");
        str.append("<note default='true' class='icon'>");
        str.append("<noteinfo noteid='11e'>");
        str.append("<item name='IconBitmap' summary='true'>");
        str.append("<rawitemdata type='6'>");
        str.append("<item name='$Daos'><text>0</text></item>");
        str.append("<item name='$TITLE'><text>");
        str.append( dbTitle );
        str.append("<item name='$Flags'><text>7f</text></item>");
        str.append("<item name='$FlagsNoRefresh'><text/></item></note>");
        str.append("<view xmlns='' version='8.5' maintenanceversion='3.0' ");
        str.append( dbReplicaId );
        str.append("' showinmenu='true' publicaccess='false' default='true' noviewformat='true'>");
        str.append("<noteinfo noteid='11a' sequence='1'></noteinfo>");
        str.append("<code event='selection'><formula>SELECT @All</formula></code>");
        str.append("<item name='$FormulaClass'><text>1</text></item></view>");

        return str.toString();


     * recycles notes objects
     * @param obj
     *             the notes object to recycle
    private static void recycleObj( Base obj ){
            if( obj != null )
        }catch( Exception e ){}

Here is an example XPage how to use the class:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="">

    DB Path:<xp:inputText id="inputTextDBPath" value="#{viewScope.dbPath}" /><xp:br />
    DB Title:<xp:inputText id="inputText1" value="#{viewScope.dbTitle}" /><xp:br />

    <xp:button value="Create DB" id="buttonCreateDB">
        <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
                    importPackage( ch.hasselba.core );
                    var dbUtil = new ch.hasselba.core.DBUtil();
                    dbUtil.createDatabase(session, viewScope.dbTitle, viewScope.dbPath, "");


You can enter the database Title and the database path. After clicking the button “Create DB”, the database is created on the server (assuming you have the right to do that).

Performance Tuning Guidelines for Windows Server

20. Mai 2014 Posted by Ralf Petter

The whole Internet is full of more or less useful tips for performance tuning on windows server. Many tips to change some mystery registry settings are not only not useful, but the can cause serious problems on your servers. Some popular performance tricks in the Internet make only sense in older releases and are obsolete in newer versions of Windows Server. You should really carefully evaluate every tip before you implement it on your production servers.

But why trust on tips from the Internet when there are very good performance tuning guidelines from the creators of Windows Server like the

Performance Tuning Guidelines for Windows Server (Windows 2008, 2008 R2, 2012)
Performance Tuning Guidelines for Windows Server 2012 R2

This guides are packed with useful tips&tricks and detailed explanations how Windows server work and which settings should be applied in different scenarios like File, Application or Web servers. My recommendation is to not change any settings on your windows server before you have read and understood the above documents!

You might not need jQuery

8. Mai 2014 Posted by Sven Hasselbach

I have found a very interesting website: You might not need jQuery. It contains a lot of usefull solutions for the different IE versions.

XPages: Use async / defer option for external CSJS Script Libraries

10. März 2014 Posted by Sven Hasselbach

When adding CSJS libraries to your XPage, try to use the defer or the async option for a better user experience. When not using this options, the Page might be blocked during page load.

Have a look at this example XPage which contains two external CSJS scripts (for demonstration purposes they are computed to get a remote script out of nowhere):

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="">
        <xp:script clientSide="true">
               <![CDATA[#{javascript:"http://" + @Unique() + ".null";}]]>
    <xp:scriptBlock id="scriptBlock1">
           <![CDATA[#{javascript:"http://" + @Unique() + ".null";}]]>

When opening the XPage, the DOM is blocked, until the operation times out:

The best you can do is to use the async or the defer option of external CSJS scripts. For script blocks, there is an option in the DDE available:

The async option can be set with an attribute:

    <xp:attr name="async" value="async" minimized="true" />

To use the option for a resource, you must add them as an attribute for both options:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="">
        <xp:script clientSide="true">
               <![CDATA[#{javascript:"http://" + @Unique() + ".null";}]]>
                <xp:attr name="async" value="async" minimized="true" />
    <xp:scriptBlock id="scriptBlock1" defer="true">
           <![CDATA[#{javascript:"http://" + @Unique() + ".null";}]]>

There are some other techniques, but this is the simplest way and supported in most browsers:

XPages: Optimized Partial Refreshs

7. März 2014 Posted by Sven Hasselbach

Inspired by the last post of Mark, I have created a small CSJS snippet which allows to optimize the behaviour of a Partial Refresh. Normally, if you execute a Partial Refresh, all elements of a form are sent to the server. Take a look at this XPage:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="">

        value="#{sessionScope.inputText01}" />
        value="#{sessionScope.inputText02}" />
        value="#{sessionScope.inputText03}" />
        value="#{sessionScope.inputText04}" />
        value="#{sessionScope.inputText05}" />
        value="#{sessionScope.inputText06}" />
        value="#{sessionScope.inputText07}" />
        value="#{sessionScope.inputText08}" />
        value="#{sessionScope.inputText09}" />
        value="#{sessionScope.inputText10}" >

    <xp:div id="refreshMe">
            id="labelNow" />

        value="Normal Refresh"
            refreshMode="partial" refreshId="refreshMe">


The button refreshes only a small portion of the XPage, the DIV element refreshMe. It does not require any of the posted field values, it just refreshes the DOM element in the frontend. But when clicking the button, the posted data to the server contain all the fields and their values, which is not necessary in this case.

This is how the request looks like in Firebug (I have prefilled all fields with the values 1..9):

The response of the server is – as expected – the actual HTML code for the refreshed DOM element:

The optimized  version adds the option clearForm to partial refreshs. When using this option, only the XPages internal fields are sent to the server, but DOM will be refreshed correctly:

        value="Cleaned Refresh"
                            clearForm: true,

Now, the POST looks like this:

But wait, this is useless, you can do a XSP.partialRefreshGet instead!

That’s why there is the second option additionalFields. This allows to define all fields you want to update during the refresh:

        value="Cleaned Refresh"
                            clearForm: true,
                            additionalFields: ['#{id:inputText01}',
                                              '#{id:inputText02}' ],

When clicking the button now, the specified fields are added to the POST request (and will be updated in the JSF tree:

Here is the snippet (Tested on IE 11, Chrome 33 & FF 27 with ND9 & ND 8.5.3 )

<xp:scriptBlock id="scriptBlockPROptimized">

    // hijack the existing partial refresh method
    if( !XSP.__partialRefresh ){
        XSP.__partialRefresh = XSP._partialRefresh;

    // add the new one to the XSP object
    XSP._partialRefresh = function x_prfh(method, form, refreshId, options){

        // clear the form?
        if( options.clearForm ){

            // create a new HTML form...
            var newForm = document.createElement( "form" );
            newForm.setAttribute( "method", form.method );
            newForm.setAttribute( "action", form.action );

            // ... and loop all existing fields
            for( var i = 0; i<form.length; i++ ){
                var field = form[i];
                var fieldName =;
                var includeField = false;


                    // check for addition fields
                    if( options.additionalFields ){
                        includeField = dojo.indexOf(options.additionalFields, fieldName)!=(-1)?true:false;

                    // only add XPages relevant fields and addtional fields
                    if( fieldName == || fieldName.substr(0,2) == '$$' || includeField ){

                        var newField = null;
                        if( field.options ){
                            // special handling for fields with options
                            for( var j=0; j<field.length; j++ ){
                                if( field.options[j].selected ){
                                    newField = document.createElement( "input" );
                                    newField.setAttribute( "type", "hidden" );
                                    newField.setAttribute( "name", fieldName );
                                    newField.setAttribute( "value", field.options[j].value );
                                    newForm.appendChild( newField );
                            // default field handling: just clone the DOM element
                            newField = field.cloneNode( true );
                            newForm.appendChild( newField );

            // call the original refresh method with the new form
            return XSP.__partialRefresh(method, newForm, refreshId, options);

        XSP.__partialRefresh(method, form, refreshId, options);

Just add the script block above to your XPage, or move it into a CSJS library. But keep in mind that you have to think twice when removing data from the request. It can lead in an inconsistence between the data in the client and the data stored in the component tree on the server.

Java: Reflection Madness

13. Januar 2014 Posted by Sven Hasselbach

A very interesting presentation about reflection in Java: Reflection Madness from Dr. Heinz M. Kabutz. You can find the slides here.

What’s new in Policies for Domino 9.0

18. Oktober 2013 Posted by Ralf Petter

In September IBM made an open mic Webcast "What's new in Policies for Domino 9.0".

Agenda of this Webcast:
  • Widgets and How To apply settings
  • Configuring Widgets for Specific Notes Client Versions
  • New Notes Client Preferences configured via policies
  • Policy related SPR's fixed in Domino/Notes 9.0
You can access the presentation and an MP3 recording of the Webcast in the technote

If you need additional informations how to troubleshoot Policy problems in Notes/Domino you can have a look on an older webcast to this topic

Tips for new Nokia Lumia users

20. August 2013 Posted by Ralf Petter

I was a long time user of Nokia symbian smartphones, but after Nokia gave up Symbian i have switched to android. But now since the arrival of windows phone 8 devices Nokia has very attractive new smartphones in there portfolio again. If you are new to the Lumia world as i am, then for sure you will find the Top tips for new Lumia owners on Nokia Conversations very interesting.

Show pictures in emails from iPhones as attachments and not as inline images

14. August 2013 Posted by Ralf Petter

It is very annoying, that the iPhone send pictures in email not as attachments but as inline images. This is especially a problem when you use a client to view such a mail, because it is a little bit difficult to save inline images to your file system.

Fortunately the notes client have the setting "Show in-line MIME images as attachments" which you can find in the Preferences Dialog in the "Basic Notes Client Configuration".

When you set the above described option all pictures in e-mails from iPhone user, will be shown as attachments, which you can open in your favorite photo editor, or save to the file system. This setting will not only change the behavior for new mails, but also for old ones. So you can always uncheck the "Show inline MIME images as attachments" option and will get the old behavior back. But i am pretty sure, you will not want it back if you have tried out this setting. An example for the email with the option set:

The option in the ui sets the variable "ShowMIMEImagesAsAttachments=1" in your Notes.ini. So when you want do deploy this useful option to all your notes users, you can set the "ShowMIMEImagesAsAttachments=1" variable in the notes.ini section of your Desktop policy.

Quick-n-Dirty: Upgrading XPiNC / XULRunner

17. Juli 2013 Posted by Sven Hasselbach

I have tested a small upgrade of XULRunner (the internal browser used for XPiNC applications) and successfully changed the version from to in DDE 8.5.3 and 9.0.

Version was released on 15.10.2010
Release Notes for Firefox 3.6.10
Version was released on 13.03.2012
Release Notes for Firefox 3.6.28

To do this by your own you have process the following steps:

  1. Close Notes and Designer completly
  2. Download the package for your platform from
  3. Extract the ZIP file
  4. Open the folder <NOTES>\framework\rcp\eclipse\plugins
  5. Open the folder [The name of the folder depends on your DDE]
  6. Rename the folder xulrunner to xulrunner_bak (if you have problems with DDE you can switch back later by renaming the folder)
  7. Copy the xulrunner folder from the downloaded ZIP into this folder
  8. Restart Notes

P.S. Keep in mind that this article has been posted in the “Quick-n-Dirty” category.

XPages: Use a PhaseListener for global URL commands

11. Juli 2013 Posted by Sven Hasselbach

One of my customers wanted an easy way for printing XPages in different formats and with different content, depending of the current XPage opened in the browser. It was a requirement to develope a global solution for every XPage-based application in his company. That is why I created a global Java class which does not require to modify the existing applications at all. But it allows to customize and configure the output for the different needs of the departments and their required reports and print outs.

I decided to use a special PhaseListener to hook into the different applications. This allows the PDF generation depending on some URL parameters, and only runs if the URI contains a special command for printing the current XPage (but works for thw whole application).

The example code is what I have created:

package ch.hasselba.xpages.util;

import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PhaseListenerPDFGenerator implements PhaseListener {

    private static final long serialVersionUID = 1L;
    private static final String GENERATE_PDF = ".PDF";
    private static final String URL_PARAMETER_FILENAME = "filename";
    private static final String URL_PARAMETER_PDFTYPE = "type";
    private static final String HTTP_HEADER_CONTENTTYPE = "application/pdf";

    public void beforePhase(PhaseEvent event) {}

    public PhaseId getPhaseId() {
        return PhaseId.RESTORE_VIEW;

    public void afterPhase(PhaseEvent event) {

        FacesContext facesContext = event.getFacesContext();

        HttpServletRequest req = (HttpServletRequest) facesContext
        String uri = req.getRequestURI();

        if (uri.endsWith(GENERATE_PDF) == true ) {

    private void servePDF(FacesContext facesContext) {
        Map requestMap = facesContext.getExternalContext()

        String pdfName = getPDFName(requestMap);
        String pdfType = getPDFType(requestMap);

        HttpServletResponse response = (HttpServletResponse) facesContext

        try {

            response.setContentType( HTTP_HEADER_CONTENTTYPE );
            response.setHeader( "Content-Disposition", "attachment; filename="
                      + pdfName );
            ServletOutputStream outputStream = response.getOutputStream();

            // Generate the PDF here
            // and send the data to the outputStream
            //outputStream.write( PDFDATA );

        } catch (Exception exception) {

    public static String getPDFName(Map requestMap) {
        String pdfName = (String) requestMap.get( URL_PARAMETER_FILENAME );
        return pdfName;
    public static String getPDFType(Map requestMap) {
        String pdfName = (String) requestMap.get( URL_PARAMETER_PDFTYPE );
        return pdfName;


The PhaseListener scans the URI every time a request is sent to the server. As soon the URI ends with .PDF, the parameters fileName and type are extracted. The correct PDF template is identified and the requested PDF can be generated (Code for generating is not included in this example).

After generating the PDF, the output is written, and the response is completed. The file download headers are added to the response. The user receives a file download dialog and can open the generated PDF (and print it if required).

When this PhaseListener is enabled in the faces-config.xml, every XPage can use the URL command. For example if your XPage is named “MyXPage.xsp” the URL to enable the PDF generation instead the generation of the XPage looks like this:

This returns a PDF with the filename test.pdf which is generated from the PDF template exportAll, containing the data of the current XPage. It is easy to add a link like this to your application to enable the PDF generation.

This is how the faces-config.xml has to look like:

<?xml version="1.0" encoding="UTF-8"?>

Trace DHCP traffic with wireshark

25. Juni 2013 Posted by Ralf Petter

The best tool to analyze weird problems in DHCP Systems is the network analysator Wireshark. But the network traces of wireshark can be very big and confusing. So you have to use filters to select only the traffic you really need to solve your problem. To see only DHCP traffic on your network interface you have to apply "bootp.option.type==53" in Wireshark.

Visual Explain explained

8. Juni 2013 Posted by Ralf Petter

Visual Explain in Db2 is a great tool which shows you how the query optimizer actually processes your sql statements. It gives you every information that you need to improve your sql statements or gives you hints which indexes you should create to get a better performance. Here is an example of the output of visual explain:

Every little icon represents one process step in your query. Some of the icons are pretty clear. Everyone knows what a table scan or and index probe means. But what about the others? The online help of Visual explain is not really helpfull, because there are only very short descriptions of every icon. But fortunatly there is a detailed description with examples of every access method the query optimizer can choose to process your sql statements in the IBM i information center. If you prefer to read this informations on paper you can download a PDF from

Howto make regular expressions caseinsensitive

25. Mai 2013 Posted by Ralf Petter

Regular expression are very useful for string operations, but one annoying thing is that regular expressions are normally case sensitive. But with a simple option you can change this default behavior. You only have to add the "(?i)" clause to your regular expression. Here is an example:

String test = "The lazy brown fox jumps over the quick Dog";
// The following command will not replace Dog, because the regex is not
// case insensitive.
System.out.println(test.replaceAll("dog", "cat"));
// With (?i) added the regex will ignore case and Dog will be replaced
// by cat.
System.out.println(test.replaceAll("(?i)dog", "cat"));

But be aware, that the "(?i)" clause does only work for ASCII strings. If you have international characters in your regular expressions you have to add the "u" flag to your regex.

String test = "Äpfel und Birnen";
// The following command will not replace Äpfel, because the regex is
// not unicode aware.
System.out.println(test.replaceAll("(?i)äpfel", "Zitronen"));
// With (?iu) added the regex is unicode aware and Äpfel will be
// replaced by Zitronen.
System.out.println(test.replaceAll("(?iu)äpfel", "Zitronen"));