Marcel Gascoyne

Center VWP components

There isn’t any standard function in the Visual Web Pack to center components on the page. You can only use absolute or flow layout.

If you want center your components horizontally or vertically, you need CSS. This is done with the style setting of your component.

position: absolute;
left: 50%;
top: 50%;

This setting would center the left upper corner of your component on the page, but not the whole component. To center the whole component you must adjust the margins. The margins can be negative, so substract the half of the vertical and horizontal size from the corresponding margin. In this sample assume that the component has a height of 100 pixels and a width of 200 pixels.

position: absolute;
left: 50%;
top: 50%;
margin-top: -50px;
margin-left: -100px;

IMAP server setup under SuSE Linux

First you must install the UW-Imap daemon with yast. UW-Imap uses the standard mail folder structure from Linux, so no additional configuration is needed.

Create SSL certificates

The certificates are stored in folder /etc/ssl/certs. Change to this directory:

cd /etc/ssl/certs

Now create the certificates for your system with the following command:

openssl req -new -x509 -nodes -out imapd.pem -keyout imapd.pem -days 365

You are asked about country name (2 letter code), state or province Name (full name), locality name (eg, city), organization name (eg, company), organizational unit name (eg, section), common name (eg, your name) and email address.

For «common name» you must enter the full DNS or IP address of your system ! If your system has more than one DNS name or IP addresses you must generate an own certificate for each DNS name or IP address.

Configuration of xinetd

Open the file /etc/xinetd.d/imap with a editor of your choice.

$EDITOR /etc/xinetd.d/imap

Add the section imaps if it doesn’t already exists:

service imaps
{
  disable         = no
  socket_type     = stream
  protocol        = tcp
  wait            = no
  user            = root
  server          = /usr/sbin/imapd
  flags           = IPv4
}

Save the changes and restart xinetd with the command

rcxinetd restart

Hibernate with JPA

To use Hibernate as a persistence provider for the Java Persistence API (JPA) you must include the following jar files into your classpath:

  • From Hibernate Entity Manager
    • hibernate-entitymanager.jar
    • lib/hibernate-annotations.jar
    • lib/hibernate-commons-annotations.jar
    • lib/jboss-archive-browsing.jar
  • From Hibernate Core
    • hibernate3.jar
    • lib/antlr-2.7.6.jar
    • lib/asm-attrs.jar
    • lib/asm.jar
    • lib/c3p0-0.9.1.jar
    • lib/cglib-2.1.3.jar
    • lib/commons-collections-2.1.1.jar
    • lib/commons-logging-1.0.4.jar
    • lib/concurrent-1.3.2.jar
    • lib/dom4j-1.6.1.jar
    • lib/ehcache-1.2.3.jar
    • lib/javassist.jar
    • lib/log4j-1.2.11.jar

If you use a Java SE project you must also include the javaee.jar file from the Java EE 5 SDK.

Here is a sample persistence.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
  xmlns="http://java.sun.com/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
  http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

  <persistence-unit name="webstore-ejbPU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>jdbc/webstore</jta-data-source>
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
    </properties>
  </persistence-unit>
</persistence>

Firebird connection pool with SJSAS

To use a connection pool datasource with the Sun Java System Application server you must copy the Firebird JDBC driver “Jaybird” in the directory ${com.sun.aas.instanceRoot}/lib/ext of your application server. The variable ${com.sun.aas.instanceRoot} stands for the application server instance directory, e.g. c:\sun\appserver\domains\domain1 for the default instance under windows environment.

The jaybird driver includes the following special classes for sun application servers:

org.firebirdsql.pool.sun.AppServerDataSource
org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource
org.firebirdsql.pool.sun.AppServerXADataSource

Use the following properties to configure the datasource:

userName      FireBird username
password      FireBird password
databaseName  FireBird database URL (host:<database path>)
encoding      Database charset
loginTimeout  Login timeout (seconds)

PostgreSQL backup

PostgreSQL databases are dumped with the pg_dump command. A simple shell script to do the backup job could be as follows:

#!/bin/sh
pg_dump -h <hostname> -U <user> -f <dumpfile> -Z 9 <dbname>

Passwords cannot be transfered to the pg_dump as a parameter, you must create a file .pgpass in the home directory of the calling user with the following content:

<hostname>:<port>:<database|*>:<username>:<password>