Domino
Aug 30, 2010
New ideas from RedTurtle....
RedTurtle Technology seeks to contribute to improving Notes
Jul 02, 2010
Generating pdf with iText and Xpages
Brief tutorial to simply create PDF's inside XPages
Many thanks to John Mackey:
http://www.jmackey.net/groupwareinc/johnblog/johnblog.nsf/d6plinks/GROC-7G9GT4
and to Daniele Vistalli http://factor-y.com for this idea, for their help and the great powers.
Since Domino 8.5 is Eclipse based, you can switch to the Java perspective and add Java code to your project. The nsf database is the project. (If you haven't done this yet, it is interesting to switch perspectives and look around at the structure and the code.) By switching to the Java perspective, you open up your code to the importing or referencing of Java libraries, or the creation of your own classes.
Now we investigate how to create PDF using XPages. This tutorial summarize John's article, with some other things that you have to pay attention to.
Step by step.....
- Create your own .nsf
- Switch to the Java perspective by selecting: Window->Open Perspective->Other.
- Expand your project on the Left hand Project navigator. Select the WebContent/WEB-INF Folder
- right click and select New->Folder. Name the folder source, click Finish.
- right click on the source folder and select New->Package. Name the Package mypackage click Finish.
- right click on the mypackage package and select New->File. Enter Test.java for the name. Click Finish.
- Now double click on the Test.java and paste in the following code:
package mypackage;
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
/**
* First iText example: Hello World.
*/
public class Test {
public static void createPdf(String filename) throws Exception {
try {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(new Paragraph("Hello World!"));
document.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
- select the project and then select Project->Properties from the menu (or right click)
- select the Java Build Path and click on Add Folder button. Select the new source folder. Click OK.
- In WebContent\WEB-INF add the folder called lib
- Right-click on it and select Import->File System->Browse and select itext jar (i.e iText-5.0.2.jar)
- import itext jar (i.e iText-5.0.2.jar) in your Java Build Path: Project->Properties->Java Build Path->Libraries->Add Jar and select jar from WebContent\WEB-INF
- Note: you have to deploy jar in your server, in data\domino\java and append this line in notes.ini, JavaUserClasses variable
JavaUserClasses=......;C:\Programmi\IBM\Lotus\Domino\data\domino\java\iText-5.0.2.jar
this will not cause security problem when you call iText methods to generate PDF
- Create a Script Library Server Side called SLCode and save this code on it
function create(){
mypackage.Test.createPdf("hello.pdf");
}
- Now create an xpage
- in Resources section, include SLCode library
- Drag a Button control in Xpage
- Goto Event section of this button, onClick event, and put this JSS code
create();
- Open your XPage in a browser and click the button: pdf will be created in domino directory on server
That's all!
Jun 26, 2010
System.getProperty() returns null
How to avoid a null pointer using System.getProperty() within a java agent.
Sometimes, for some reason, you have to do it. I'm talking about the use of System.setProperty() method within a java agent. If you don't pay attention it's easy to get a null pointer as result. Infact I got it.
After a quick search I found out a way to solve the issue:
I will use "jna.library.path" as example.
First of all add the following line in "java.policy" file (in the "jvm\lib\security" folder below the Domino program folder).
permission java.util.PropertyPermission "jna.library.path", "read,write";
After that, add the java code to your agent :
String jnaProperty = "jna.library.path";
if(System.getProperty(jnaProperty) == null) {
System.setProperty(jnaProperty,"your path");
}
Jun 17, 2010
Jun 01, 2010
Problem with documentcontext in Java Agent
In a Java agent, If you are accessing your document via agentContext.getDocumentContext(), I've found a problem in managing attachment with extractFile method
Error found is "a database handle to a remote database cannot be used by more than one thread"
This is my workaround.
Instead of doing:
AgentContext agentContext = session.getAgentContext(); lotus.domino.Document inDoc = agentContext.getDocumentContext(); Database db = agentContext.getCurrentDatabase();
try doing this :
AgentContext agentContext = session.getAgentContext(); lotus.domino.Document inDoc = agentContext.getDocumentContext(); String unid = inDoc.getUniversalID(); inDoc.recycle(); Database db = agentContext.getCurrentDatabase(); lotus.domino.Document inDoc2 = db.getDocumentByUNID( unid );
Now works!
May 13, 2010
managing replicas on database using Lotusscript
How to manage database replication options using Lotusscript also if user doesn't have manager access
Customer request was:
Disable replication on the database if user never replicate it in the last week
User only has author rights in ACL database (which is a replica of a management deployed on n users laptops)
How to get it programmatically even if the user has no rights manager?
If you try to access the object NotesReplication and try to do something like that:
Dim session As New NotesSession Dim db As NotesDatabase Dim rep As NotesReplication Set db = session.CurrentDatabase Set rep = db.ReplicationInfo If rep.Disabled Then rep.Disabled = False End If Call rep.Save()
You get the following error:
"Error supplied to access product object method"
The key is to use the Notes API, in particular NSFDbReplicaInfo
API in this case exploit user credentials of id who wrote the Lotusscript code, so you should sign the agent with the ID of the administrator or with a user who has manager rights to the database
We must define the following class in the "Declaration" agent
Dim rc As Integer Type DBREPLICAINFO ID AS TIMED flags As Integer CutoffInterval As Integer As cutoff TimeDate End Type Declare Function Lib W32_NSFDbOpen "nnotes.dll" Alias "NSFDbOpen" (ByVal dbname As String, hdb As Long) As Integer Declare Function Lib W32_NSFDbClose "nnotes.dll" Alias "NSFDbClose" (ByVal hdb As Long) As Integer Declare Function Lib W32_NSFDbReplicaInfoGet "nnotes.dll" Alias "NSFDbReplicaInfoGet" (ByVal HDB As Long As retReplicationInfo DBREPLICAINFO) As Integer Declare Function Lib W32_NSFDbReplicaInfoSet "nnotes.dll" Alias "NSFDbReplicaInfoSet" (ByVal HDB As Long As retReplicationInfo DBREPLICAINFO) As Integer Declare Function Lib W32_OSLockObject "nnotes.dll" Alias "OSLockObject" (ByVal handle) As Long Declare Sub OSUnlockObject Lib "NNOTES.DLL" Alias "OSUnlockObject" (ByVal handle) Declare Sub W32_OSMemFree Lib "NNOTES.DLL" Alias "OSMemFree" (ByVal handle) Class NotesReplicationSettings Private hdb As Long As private retReplicationInfo DBREPLICAINFO Private prvdb As NotesDatabase Private flgDBExist As Integer Sub Delete If hdb <> 0 Then Call W32_NSFDbClose (hdb) End Sub Sub New (inpNotesDatabase As NotesDatabase) As String Dim sDatabase As New NotesSession Dim uaesession Dim rc As Integer Me.flgDBExist = False 'Get a valid NotesDatabase to the specified database If inpNotesDatabase Is Nothing Then Error 14104, "NotesUserActivity: Object Database is invalid" Exit Sub End If September prvdb = New NotesDatabase (inpNotesDatabase.Server, inpNotesDatabase.FilePath) If (prvdb.Server = "") Or (uaesession.IsOnServer) Then sdatabase = prvdb.filepath Else sdatabase prvdb.server = + "!" + Prvdb.filepath End If 'Open the target database rc = W32_NSFDbOpen (sDatabase, Me.hDb) If rc <> 0 Then Me.flgDBExist = False End If 'Set the Replication Information rc = W32_NSFDbReplicaInfoGet (Me.hDb, Me.retReplicationInfo) If rc <> 0 Then Me.flgDBExist = False End If Me.flgDBExist = True End Sub DBExist As Integer Public Function DBExist = Me.flgDBExist End Function Public Function Parent As NotesDatabase Set Parent = prvdb End Function Public Function SetDisableReplica (sFlag As Integer) As Integer As Long Dim puActivity If Not Then Me.flgDBExist Error 14104, "Notes DB not opened" SetDisableReplica = False Exit Function End If Me.retReplicationInfo.flags = (Me.retReplicationInfo.flags Or & H4) rc = W32_NSFDbReplicaInfoSet (Me.hDb, Me.retReplicationInfo) If rc <> 0 Then Me.flgDBExist = False End If End Function End Class
get an instance in initialize agent method as follows (db is target database to manage):
Dim nrs As New NotesReplicationSettings (db)
and disable (or enable depending on the parameter that is passed, 1 or 0) replication:
nrs.SetDisableReplica (1)
or
nrs.SetDisableReplica (0)
And that's all
Jan 20, 2010
The Top 11 Tips for Keeping Your Servers Healthy
Have you ever wondered how healthy your servers are? Are you running with default settings on your production servers? Do maintenance tasks run when they should, or are they even running at all? Are you using appropriate database features, controlling log sizes, or leaving debug variables in the .ini? Have you implemented critical features that were introduced with the server software in your latest upgrade? This cross-platform session will shed light on a number of items most administrators overlook or simply do not understand the importance of implementing. Learn from real-world customer examples and see how to remedy the situations presented.**
Best practies in pillole:
- Pay attention to console errors!!
- Are you using default settings?
- Are your servers too open?
- Know your schedules
- Keep your servers clean
- Clustered server tips
- ID management
- New features not implemented
- Policies – are you using them?
- Maintenance tasks
- Get to the new ODS
Jan 19, 2010
What's New in Composite Applications in IBM Lotus Notes 8.5.1
Come and learn about whats new with composite applications in Lotus Notes 8.5.1. You'll see how you can leverage the new tooling in the Composite Application Editor (CAE) to quickly assemble applications and create new components using "point and click". We'll show how different components like Web, XPages, Java Views and Eclipse views can be assembled in a composite and on the side shelf within your application. You'll learn about the new container framework and what this means for your components. We'll cover the low level extensions to the CAE that allow you to add your own custom tooling for your components, and you'll learn all about custom actions and see how they can make your applications more powerful.**

Bob Balfe ha presentato due interessantissime CA realizzate con la versione 8.5.1 e illustrato i nuovi oggetti:
- Synphony Spreadsheet Container
- Web Browser container
- Host on Demand container
- Notes Document Container
- Notes View container
Ed inoltre, per il futuro:
- CAI URL enhancement - pagealias
- Role based access to components
Peccato per la scarsità dei talk riguardanti l'argomento, ma di sicuro Balfe, Guru assoluto in materia, ha alzato ai massimi livelli la qualità del suo intervento.
Jan 18, 2010
AD106 - XPages just keep getting better
Last year at Lotusphere, XPages burst onto the Lotus Domino application development landscape. Since then, the developer community has embraced XPages and delivered compelling Lotus Domino Web solutions. 8.5.1 delivered on the vision by providing the ability to build an application once for the Web, the Notes client or expose as an iWidget.Come hear about other 8.5.1 enhancements, what is coming in 8.5.2 and glimpse towards the future.**

Annunciate le novità per le XPages (nella 8.5.2)
- REST e nuovi advanced controls
- modalità off-line e repliche locali
- wiring con le composite applications
- Performance improvements
- iWidget mashup
- hidden field text control
- RichText editor migliorato
- riuso delle funzionalità esistenti: LS libraries, forms, vies
- utility per convertire vecchi form, viste in xpages
- nuovi DataSource (jdbc, db relazionali)
AD109 - XPages perfomance and scalability
Understanding the XPages architecture is key to building performant scalable enterprise-ready Lotus Domino web applications. We'll show how to go under the hood to discover functional features that help your application perform and scale well. You'll learn about design patterns and techniques that ensure your applications are optimally tuned for your business requirements, and we'll show how to integrate existing business logic -- without increasing performance cost.**

Tips&Tricks veramente utili per incrementare le performace
- i tool di monitoring consigliati: Firebug, YSlow, PageSpeed
- IBM Xpages Profiling tool: database per il tuning delle XPages in termini di CPU, cache ecc...
- consigli per il rendering delle pagine e per migliorare il JSF cycle lifecycle
- dataCache per le viste (nuovo nella 8.5.1)
- come usare Java nelle XPages per mantenere performance ridotte

