Monday, January 30, 2012

HTML 5 going forward

Good example of using HTML 5 with Domino
It's about XPages application, for offline mobile e-mail management. It's call "D+ Everywhere". http://www.edbrill.com/ebrill/edbrill.nsf/dx/dominoplus-introduces-d-everywhere

How To: Iterable DocumentCollection and View

Trivial iteration of DocumentCollection or View in Domino:
It's looks a little ugly.
Fortunatly we could improve it:
ExtendedCollection realization
Example

How To: compare two documents

Java Code for compearing two documents item by item.
It prints only item's that is different by Name, Type, IsSummary, Values.

How To: Correct handle 404 and other errors in Domino Web server

The best is to use DSAPI filter.
Look at http://dpastov.blogspot.com/2012/01/error-pages-in-domino.html for a solution

How To: print all items of document

Java Code for printing all items and it's values from some document:

How To: highlight java syntaxis on your blog posts

Utility: SyntaxHighlighter
Site: http://alexgorbatchev.com
Version: 3.0.83

Add next code in to your head section
On the page
Result
This example will highlight also JavaScript, C, C++, VisualBasic (LotusScript), XML and CSS.
Look for more higllights:
http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/

Tuesday, January 18, 2011

Easy operate with database settings profile in java

The easy way to get settings from profile document from any part of your java progam.

Call "readProperties" method at the beginig of your program to read properties from profile.

The next example read one item called "isProductionDatabase". You could extend this class to read all items.

public class DatabaseProperties{
 private DatabaseProperties(){}
 
    private static String ProfileDatabaseSettings = 
         "settings.database";
    private final static String ITEM_IS_PRODUCTION_DATABASE = 
         "isProductionDatabase";
    
    private static Properties databaseProperties;

    private static void readPropertyFromDocument(
      Document profile, 
      String propertyName) throws NotesException{
       String property = profile.getItemValueString(propertyName);
     databaseProperties.setProperty(propertyName, property);   
    }
    
    public static void readProperties(Database database) throws NotesException{
     databaseProperties = new Properties();
     Document profile = 
      database.getProfileDocument(ProfileDatabaseSettings, null);
     
     readPropertyFromDocument(profile, ITEM_IS_PRODUCTION_DATABASE);
    }

    public static void readProperties(
      Database database, 
      String profileName) throws NotesException{
       if(profileName != null){
      ProfileDatabaseSettings = profileName;
     }
       readProperties(database);
    }
 
    public static String get(String key){
     return databaseProperties.getProperty(key); 
    }
    
    public static boolean isProductionDatabases(){
        String isProductionDatabase = 
         databaseProperties.getProperty(ITEM_IS_PRODUCTION_DATABASE);
        return "1".equals(isProductionDatabase);
    }
}

Monday, January 17, 2011

Serialization in to doucment item

Utility function to serialize\deserialize java object in to the domino document item. This object will be possible to read with another languages like LotusScript and so on.
    public static void serializeObject(Document document, String itemName, Serializable o) 
throws IOException, NotesException{
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(bos);  
        out.writeObject(o);
        byte[] oByte = bos.toByteArray();
       
        document.replaceItemValueCustomDataBytes(itemName, o.getClass().getName(), oByte);
    }
   
    public static Object deSerializeObject(Document document, String itemName, String oTypeName) 
throws IOException, NotesException, ClassNotFoundException{
        byte[] oByte = document.getItemValueCustomDataBytes(itemName, oTypeName);
       
        ByteArrayInputStream bis = new ByteArrayInputStream(oByte);
        ObjectInput in = new ObjectInputStream(bis);
        Object o = in.readObject();

        return o;
    }

Friday, January 14, 2011

DateTime.toJavaDate() issue

Lotus Notes DateTime.toJavaDate() function sets time part to curren time if it was avoided in the DateTime Object. So each time you call toJavaDate() on such object you will receive different time. For example
"15.01.2011" -> "15.01.2011 15:36:37"
"15.01.2011" -> "15.01.2011 15:36:41"
and so on. Code for fix this:

Tuesday, February 26, 2008

Unread Marks Methods not imlemented

New java methods from Domino 8 for unread marks not implemented in CORBA. So will be wait 8.5 for this features.