Jun
19
Posted on 19-06-2007
Filed Under (Java, XML) by Johan Känngård

Those of you who haven’t used System.out.println(“My variable: ” + myVariable) in some Java classes to get debug information to the console, raise your hands please. None? ;-)

I am very fond of logging as a complement to debugging, since I can “trace” actions in my programs even if the classes is in production. “But hey, logging makes the application go slower!” you might think. Well, it’s up to you to decide, a small performance hit is likely to occur, a big hit if you don’t read the documentation of for instance the PatternLayout.
I use Log4j a lot in the Java code I design and write, and haven’t noticed any big difference between logging and not logging.
So, you might have used Log4j a bit and used Chainsaw to look at Log4j logging files. Why not look at the logging in realtime? Here is how to do it.
Read the rest of this entry »

(0) Comments    Read More   
May
25
Posted on 25-05-2007
Filed Under (Domino/Notes, Fun, Java, XML) by Johan Känngård

Johan defeating Darth Vader
I was a key speaker at the first g33k date ever yesterday, and it was Ekakan that held the meeting in their small but great office at Saltmätargatan in Stockholm. Quite a lot showed up, many of which I know by name, but not by face, since they are all bloggers with no pictures at their sites! :-) After having slurped down some well-known red-canned sugary liquid, I started my speech using OpenOffice Impress as presenter application. The slides can be found at the bottom of this post. It has not been cleaned up, so some references are to my local file system and applications on my Domino server will not work. I have put the database I used for the web service stuff as an attachment below, but use it at your own risk!
I talked briefly about who I am, what I like, what my shoe size is and other important stuff. A short history on how the web has evolved over time (1.0, 1.5, 2.0) and my own suggestion of the next 3.0 level, which includes web services on the client side. I demonstrated a simple AJAX solution for typeahead with script.aculo.us and Domino and a web service consumer in the browser.
A Midlet with a web service consumer was the next item to show, and it worked as a charm in the emulator!
After my 15 minutes of fame (or rather 40), we had a short drinking and chatting pause.

Joachim Dagerot introduced us into ext.js, a client-side framework with lot’s of goodies like menus, trees, tabbed tables, layouts etc. The framework looked really impressive, and applications based on it was more of a Windows experience. When developing applications with ext.js, almost everything is done in JavaScript, including the templates of the pages. You don’t have to download the complete framework, you can take bits and pieces, if you want only a part of the gadgets.

After more beverages, snacks and more chatting, connections were made, business cards and email addresses exchanged hands. I left rather early though, I hope my fellow bloggers to give the full story ;-) Photos were taking during the meeting, and I would really love to see them, since I didn’t use my own camera.

I hope that this event wasn’t the last of it’s kind in Sweden, it was great fun to see fellow bloggers and geeks!
Thanks for a great event everyone, especially Ekakan who arranged the g33k date!!

Btw, the picture at the top is NOT from the g33k date, it was just a picture I used in the presentation as an illustration of the thin red line between being a geek and a nerd. :-D

[tags]g33k, geek, J2ME, AJAX, Webservice, Ekakan[/tags]

(7) Comments    Read More   
Mar
20
Posted on 20-03-2007
Filed Under (JavaScript) by Johan Känngård

Here’s a short snippet to set the opacity of an element:

function setOpacity(e,opacity){
var o=e.style;
o.opacity=(opacity/100); //Opera
o.MozOpacity=(opacity/100); //Mozilla+Firefox
o.KhtmlOpacity=(opacity/100); //Konqueror
o.filter="alpha(opacity="+opacity+")"; //IE
}

Use it like this:

var e=document.getElementById('myElement');
setOpacity(e, 50);//Sets the opacity to 50%

[tags]JavaScript[/tags]

(2) Comments    Read More   
Mar
14
Posted on 14-03-2006
Filed Under (Domino/Notes, Java) by Johan Känngård

Detta är i korthet vad som sades under halvdagen den 8:e mars i Kistam som IBM valt att kalla Lotusphere Comes to You. Presentationerna som visades finns att hämta hos IBM.

Inledningstal av Ed Brill

Ed Brill

Det var kul att se Ed Brill på hans första besök i Sverige! Han presenterade siffror som visar att Lotusphere är populärare än någonsin och att Notes knappast är dött! Dessutom drog kort han igenom de nyheter som kommer framöver, vilka presenterades i detalj av de svenska IBM-medarbetarna. Framförandet var innehållsrikt, men lite för kort. Själv hade jag inte möjligheten att tala med honom, och jag hoppas att han återkommer till Sverige vid ett senare tillfälle!

Notes på Linux

Karl Dettner

v.7.0.x av Notes kommer att gå att köra på Linux via Workplace Managed Client. Karl Dettner demonstrerade detta LIVE genom att köra en fönsterhanterare i Linux, och startade Notes samt surfade runt i databaser. Domino Designer kommer inte att kunna köras på Linux (än), vilket gör att man fortfarande är hänvisad till Windows alternativt Wine, en öppen-källkodsimplementation av Windows API på Linux. Dock har det dykt upp ett försök till att skapa en webbbaserad IDE som liknar Domino Designer, vilket kan vara värt att bevaka.

Notes på Mac

Version 7.0.2 kommer att kunna köras på MacOS X. Domino Web Access i samma version kommer att stödja Mozilla Firefox på MacOS X, dock ej Safari.

Notes 8 “Hannover”

8:an bygger på Eclipse och kan därmed köras på ett flertal plattformar. Publik beta dyker upp i slutet av 2006. Alla befintliga Notesapplikationer kommer att fungera i Hannover (vilket upprepades som ett mantra ett flertal gånger). Fokus på något som kallas aktiviteter, som är en form av delprojekt i en arbetsgrupp. Möjlighet att spara/gruppera dokument, mail, chat etc. i aktiviteter för att senare kunna söka fram informationen. Markering av dokument sker genom att hela raden visas i annan färg, som är standard i alla andra program på de flesta plattformar. Bockarna i kanten kommer således att försvinna.
Notesklienten kommer att kunna köra Webservices, även i lokala applikationer.

Sametime 7.5

Anders Kjellner

Anders Kjellner förklarade att även denna nya release är baserad på Eclipse, vilket möjliggör olika utseende i olika operativsystem, dvs. det ser ut som en MacOS-applikation på MacOS, och ser ut som en Windowsapplikation i Windows. Pluginarkitekturen från Eclipse gör att tredjepartsutvecklare kan ta fram produkter för att utöka funktionaliteten. Till en början finns t.ex. plugins för att koppla Sametime till videokonferensutrustning (Tandberg) och IP-telefoni (Avaya).
Det bakomliggande nätverksprotokollet är förbättrat pÃ¥ mÃ¥nga punkter, bl.a. har mängden data som skickas minskats, samt att den använder “intelligent” teknik för att hitta det mest optimala sättet att kommunicera med servern.
Några användarnyheter är bl.a. möjligheten att använda olika stilar på chattmeddelanden, stavningskontroll (endast engelska till att börja med), smileys, kunna skicka Noteslänkar och historik som behåller formattering. Positionsmedvetande gör att Sametime känner av i vilket nät du kopplat upp dig i, och frågar efter den exakta adressen. Detta gör att applikationen kan hjälpa till med t.ex. val av rätt skrivare, hitta rätt till restauranger etc.
Numera krävs en JVM pÃ¥ minst 1.4 för att använda Sametime, vilket betyder att Internet Explorers MS JVM inte kommer att fungera, utan man mÃ¥ste ladda ner “en annan”, förslagsvis Suns.

Workplace Designer 2.6

Erik Söderholm

Utvecklingsmiljön för Workplace Collaborative Services, Workplace Designer, är väldigt likt Domino Designer, och arbetssättet är lika intuitivt och enkelt, men skiljer på några punkter. Bl.a. har WD stöd för dra-och-släpp av element, exakt positionering och databasmodellering. För att göra livet ännu enklare, använder sig WD av @funktioner i kod i t.ex. knappar. Alla @funktioner från Notes/Domino är inte implementerade, men de mest basala. En inbyggd Java-brygga medger åtkomst av Javaobjekt och klasser på servern direkt från Javascript.

Innovation Pack

Ny funktionalitet till Notes och Domino 7 genom nya mallar/databaser, ingen uppdatering av koden i Notes/Domino. Dessutom en ny installation som tillåter Notes att installeras på USB-minne (som dock kan göras idag men lite mer omständligt). Släpps under tredje kvartalet 2006.
Några av mallarna som kommer att följa med:
-Blog, för att skapa en webblogg
-RSS, för att skapa RSS-flöden från befintliga databaser

Bowstreet Portal Factory

Patrik

Bowstreet köptes av IBM dÃ¥ produkten Portal Factory var intressant. Den används för att bygga portlets utan att koda en enda rad, utan man följer ett antal guider eller sÃ¥ kallade builders. Portal Factory är en plugin som kan användas i RAD eller Eclipse. I paketet ingÃ¥r 120 builders, som i bakgrunden skapar JEE-kod. Denna kod kan självklart ändras, men det behövs ej, dÃ¥ i stort sett allt kan konfigureras. Patrik (antecknade ej efternamnet, tyvärr…) visade ett exempel genom att använda builders för Dominovyer och formulär, för att hämta och visa information frÃ¥n Dominoapplikationer i en JEE-applikation.
Man behöver inte använda Portal Server för att använda de byggda applikationerna, utan man kan generera dessa för vanliga JEE-servrar, som t.ex. Apache Tomcat, Borland AppServer och självklart Websphere Application Server.
Portal Factory är ännu inte paketerad med IBMs namn, men kan redan idag köpas. En inte allt för vågad gissning är att denna produkt kommer att integreras med RAD och förhoppningsvis paketeras med Domino!?!

Till sist

Lotusphere Comes to You är ett bra initiativ av IBM, vi är många som inte har möjlighet att åka över Atlanten för att närvara på Lotusphere, men ändå vill få information. Visst finns det mesta tillgängligt på nätet, men det kan vara svårt att skilja godbitarna från allt brus därute! Glöm inte att titta på presentationerna, speciellt den som avhandlar Bowstreet!

Gula boxningshandskar
Efter inlämnad utvärdering fick vi en nyckelring med de berömda gula boxningshandskarna! :-)

[tags]Lotus Notes, Lotus Domino, Workplace, Bowstreet, RAD, Sametime, Hannover[/tags]

(0) Comments    Read More   
Mar
07
Posted on 07-03-2006
Filed Under (Domino/Notes) by Johan Känngård

Thomas tipped about the DocumentViewer Notes “Smart Icon” application, that can be used to inspect the fields of a document. It’s easier to find values you’re looking for, and it allows copying of both multiple values and field names. I have written a similar application for use on the web, but DocumentViewer is great if the database is restricted from web access!
[tags]Lotus Notes, Smart Icon[/tags]

(0) Comments    Read More   
Mar
06
Posted on 06-03-2006
Filed Under (Java) by Johan Känngård

Here is a simple method (actually two) for removing multiple characters from a String:

/**
* Removes the specified characters from the supplied String.
*
* @param s the String to remove characters in.
* @param a the characters to remove from the supplied String.
* @return the String stripped from all the supplied characters.
*/
public static String removeChars(String s, char[] a) {
StringBuffer r = new StringBuffer();
for (int i = 0; i < s.length(); i ++) {
if (!contains(s.charAt(i), a)) {
r.append(s.charAt(i));
}
}
return r.toString();
}

/**
* Searches a char array for the specified character.
*
* @param c the char to find in the char array.
* @param a the char array to search in.
* @return true if the char is found in the char array,
* false if not.
*/
public static boolean contains(char c, char[] a) {
for (int i = 0; i < a.length; i++) {
if (c == a[i]) {
return true;
}
}
return false;
}


The above can be used like this to check if a String is a valid phone number:

/**
* Checks if the String is a valid phone number.
* It is valid if it only contains numbers or any of the characters
* +-() and space
*
* @param s the String to test for a valid phone number.
* @return true if the supplied String is a valid phone number,
* false if not.
*/
public boolean isValidPhoneNumber(String s) {
char[] a = {'-', '+', '(', ')', ' '};

try {
Double.parseDouble(removeChars(s, a));
return true;
} catch (NumberFormatException e) {
return false;
}
}

Apache Jakarta Commons Lang StringUtils has a variant of the removeChars method above called replaceChars that also can be useful.
[tags]Java[/tags]

(1) Comment    Read More   
Feb
24
Posted on 24-02-2006
Filed Under (Domino/Notes) by Johan Känngård

Den 8 mars kommer Lotusphere till Sverige! Närmare bestämt till IBMOddegatan i Kista. Ed Brill kommer att medverka som talare. Själv har jag redan anmält mig, det kan du också göra!

(3) Comments    Read More   
Feb
15
Posted on 15-02-2006
Filed Under (JavaScript) by Johan Känngård

When developing web applications, select-boxes are usually involved in the UI. I’ve put together a custom JavaScript class to handle things like removing, adding and selecting elements. By the way, Matt Kruse has a bunch of nice JavaScript libraries!

Example:

var e=new DynamicSelect('MySelect');
e.removeAll();
e.append('Entry 1','');
e.append('Entry 2','');
e.selectAll();
e.unselectAll();
e.select('Entry 2');
e.toggleAll();
if(e.contains('Entry 1')){
alert('We got Entry 1!');
}
if(e.indexOf('Entry 2'!=-1)){
alert('We got Entry 2!');
}
e.insert('Entry 0','',0);
e.select('Entry 2');
e.removeSelected();
e.remove(0);
alert('Original HTML element name: '+e.parent().name);

The methods are documented in the source file, if you want to know more about them.

[tags]JavaScript[/tags]

(0) Comments    Read More   
Feb
15
Posted on 15-02-2006
Filed Under (Domino/Notes, JavaScript) by Johan Känngård

This has been done before. Here is my contribution:

/**
* Replaces \\\"No Documents Found\\\" with a custom text.
*
* @author Johan Känngård, http://johankanngard.net
* @param message the text to replace with
*
*/
function replaceNoDocumentsFound(message){
var h2=document.getElementsByTagName(\\\'h2\\\');
if(h2!=\\\'undefined\\\'&&h2.length>0&&h2[0]!=\\\'undefined\\\') {
var oldTextNode=h2[0].firstChild;
var newTextNode=document.createTextNode(message);
h2[0].replaceChild(newTextNode,oldTextNode);
}
}

Put the function in the HTML Head (or in an imported JS-file) and call the function at the bottom at the page like this:



The easiest way to hide the text is via a stylesheet like this:


…but you already knew that, huh?
[tags]JavaScript, DOM, Lotus Domino, CSS[/tags]

(0) Comments    Read More   
Feb
13
Posted on 13-02-2006
Filed Under (Domino/Notes, Java, XML) by Johan Känngård

Here is an example how to use the XMLEchoer class, that I have refurbished from Sun’s tutorial Echoing an XML File with the SAX Parser. It is of limited use, but can be a good start learning SAX.

import java.io.PrintWriter;
import lotus.domino.AgentBase;
import net.kanngard.xml.XMLEchoer;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {
String xml = "Hello World";
PrintWriter writer = getAgentOutput();
writer.println("Content-type: text/xml");
XMLEchoer echoer = new XMLEchoer(writer);
echoer.start(xml);
} catch(Exception e) {
e.printStackTrace();
}
}
}

To get it working, you need a SAX implementation, like Apache Xerces 2. Just drop the JAR files from Xerces 2 into the jvm/lib/ext directory in your Notes or Domino installation. Restart the http task if you are testing with Domino.

[tags]Java, XML, SAX[/tags]

(0) Comments    Read More