Tuesday, January 28, 2014

Dynamically pointing DomSQL to current database

I couldn't find a way to specify current database in the .jdbc file, so I dug around in the API.

When creating the connection to a DomSQL database, you can do it with getConnection and the name of a .jdbc config file:
public static Connection getConnection() throws SQLException {
    return JdbcUtil.getConnection( FacesContext.getCurrentInstance(), "nameOf.jdbc" );
}

Or use createConnection and specify the path for the connection:
public static Connection getConnection() throws SQLException {
    String dbPath = null;
    try {
        dbPath = ExtLibUtil.getCurrentDatabase().getFilePath().replaceAll( "\\\\", "/" );
    } catch( NotesException exception ){
        // Ignore
    }
  
    return JdbcUtil.createConnectionFromUrl( FacesContext.getCurrentInstance(), "jdbc:domsql:" + dbPath + "/nameOf.domsql" );
}


If you haven't heard of DomSQL: JDBC Access for IBM Domino

Monday, January 27, 2014

HTML5, script tags and partial refresh inside target area

I had some issues with a script tag not loading inside a panel. The panel was set to only be visible when a view scope variable was set.

It turns out that this is by design for HTML5.

When script tags are inserted into a document using Ajax/innerHTML, the spec states that the script tag should not execute.

HTML5 spec
"...script elements inserted using innerHTML do not execute when they are inserted..."

My workaround for this was to set full refresh for the event that refreshed the panel.