Genii Weblog

Method to the Madness: More Resources for the XPage

Thu 10 Feb 2011, 12:09 PM



by Ben Langhinrichs
As I prepare for the EntwicklerCamp conference in Germany, I have been describing Midas Rich Text LSX methods that I am using along with XPages and web editors for an interesting technology fusion.  Not saying what the project is yet, although guess if you like. Those at EntwicklerCamp will have an opportunity to see the project working, but soon after that, I should have a demo for others.  This is a follow up to my earlier two Method to the Madness posts, Connecting to an XPage with Midas and Custom XHTML input for XPage field.

As I continue to develop the project (hint: it has a slight connection to my IdoSphere post), I have discovered that my database is missing some resource files I will need.  I'll need a CSS style sheet and at least a couple of JavaScript files.  Since I won't know exactly which ahead of time, our third method will be GeniiSession.CreateFileResource. As before, I have included much of the general help, as well as an example.  Please note that in the example, if the file has a .css extension, it is automatically added as a Stylesheet resource, while other files are added as regular File Resource files.

Are you starting to see how many different things the Midas Rich Text LSX can, aside from just "manipulating rich text"?

CreateFileResource method  

Version added: 3.50

Creates a new style sheet or file resource design element and returns a GeniiRTItem class object connected to the file resource data. 
Defined in
GeniiSession class
Syntax
Call geniiSession.CreateFileResource(server$, filepath$, resourcename$, properties$)
Parameter
server$
String.  The server for the database in which the file resource will be created.  This should be a blank string, "", for a local database.  If a NotesDatabase object is instantiated, this is the Server property.
filepath$
String.  The pathname of the database, relative to the Notes data directory.  If a NotesDatabase object is instantiated, this is the FilePath property.
resourcename$
String.  The name of the file resource to be created.  If this name ends in a .css, the file resource will be created as a style sheet resource, and otherwise it will be a regular file resource.
properties$
String.  Optional.  Various property pairs which effect the creation of the file resource. Possible property pairs are below:

Overwrite=Yes/No (defaults to No)
SourceFile=filename (If no source file is specified, the file resource could be added other ways, but for now this should always be used)

Example:
Dim s As New NotesSession
Dim db As NotesDatabase
Dim gSession As New GeniiSession
Dim rtitem As GeniiRTItem

Set db = s.CurrentDatabase

' *** Create a style sheet
Set rtitem = gSession.CreateFileResource(db.Server,
                                         db.FilePath,
                                         "alltogether.css")

' *** Create a file resource
Set rtitem = gSession.CreateFileResource(db.Server,
                                         db.FilePath,
                                         "glasnost.js")

Copyright 2011 Genii Software Ltd.

What has been said:


974.1. Ulrich Krause
(11.02.2011 07:57)

You want to paste images from the clipboard into an Richtext item in an XPage in the browser and save the images as file resources, do you ??