Lotus Component Designer
PermaLink Lotus Component Designer - enhancing the sample discussion component03/31/2007 08:16 AM
Lotus Component Designer
I needed to enhance the sample discussion component that ships with LCD 6 to have similar features as the discussion portlet that shipped with Workplace Services Express.  Many customers are upgrading to Portal 6 from WSE and one of the widely used features was Team spaces.   Users are able to create a team space for their teams/projects and WSE would create a new composite page with instances of these portlets.  The more popular portlets are the discussion, team calendar, and document manager portlets.
 
One of the features that the users liked and we needed to add were the locking of topics and their related threads.  They were able to check off the topic from the main view and click a "Lock Topic" button.  Lotus Component Designer provides the ability to add a checkbox on a view for the purpose of deleting documents.  There is a simple action provided to perform that task from a button or link.  I needed a way to collect what records were checked off in my Lock Topic button.

I posted the question to the LCD forum and Mark Wallace created a sample component for collecting the document IDs that were checked off.  He posted that sample to the Lotus Sandbox, here's a link to it.  The functions that he uses for the viewPanel are not in the LCD help.

Here's the code I generated for the Lock Thread button:

db=database;
var viewPanel = getComponent("viewPanel1");
var dataModel = viewPanel.getDataModel();
var docIdIter = dataModel.getSelectedIds();  //provides the a collection of docIds that are checked off

while (docIdIter.hasNext()) {  //iterate through the collection
        docId = docIdIter.next();
        print("<<< docId="+docId);
        doc=db.getDocumentById(docId);  //get the document
        if (doc!=null){
                doc.setStringValue("/schemaTopic/threadLocked","Locked");  //update the threadLocked field
                doc.save();
        }
}

Here's a screen shot of the enhanced portlet:
"discussion_lock_thread.JPG"

I added the "/schemaTopic/threadLocked" as a column in the view query.  Also, when the user opens the topic I hide the edit/reply links if the topic is locked.

Another enhancement I made was to allow a copy of the same portlet to be used on multiple portal pages but to simulate that the database was unique to the instance of the portlet.  This feature simulates the use of Team Spaces or composite applications.  LCD does support this feature on composite pages, but I wanted to provide this feature on a regular portal page.

I added a parameter called "instanceID" to the component that can be set per portlet instance.  Then in each view I use a filter to only show records for that instance.  This way the discussion portlet only needs to be rolled out once and each copy shares a single database.

Here's a screen shot of the filter.  I place the InstanceID in a session variable on the beforePageLoad event just for convenience.

"Discussion_instanceID_filter.JPG"

John
Technorati:
(3)

PermaLink Formatting dates in Lotus Component Designer02/22/2007 08:39 AM
Lotus Component Designer
Ok, this is not the most exciting topic to write about.  The formatting of dates in LCD has just come up a number of times over the past week with a number of different developers.  So I figure there are many other people with the same issue.  

Each developer has tried various techniques without success and left it to come back to later.  The issue seems to be that the date/time value is stored or translated into the "International" format within XML.  When using an Edit Box control or Date Time Picker control, the data is then translated based on the selections on the properties page for that control.  When using a javascript formula to create text to display that contains a date, you need to format the date yourself.  I've tried the old @Text() formula, but no luck.

Here's the solution I have used for formatting dates in javascript.  There is a class that contains methods for internationalization.  Most people overlook this in the help.  Actually, no one I know has found this class on their own.  The class name is "I18n"...sounds so obscure so no one seems to click on it to see what it does.  

I use the I18n "toString" method to format my dates.  It works great.  Here is what the help says about this method:

Produces a string value that represents the date formatted according to the given pattern and according to the conventions of the given locale. The pattern may be one of the six predefined patterns represented by i18n constants (DATE_FORMAT, LONG_DATE_FORMAT, etc. )

toString(date:Date, pattern:string) : string

I put together a small helper method for the most common date/time format.  I am using the standard DATETIME_FORMAT which would display the date and time such as "2/22/2007 1:58 PM".

formatDT(theDate){

return I18n.toString(theDate,I18n.DATETIME_FORMAT);

}

If anyone has come across any other solutions, please share it by adding a comment.

John
Technorati:
(0)

PermaLink Lotus Component Designer - binding to multiple datasources01/29/2007
Lotus Component Designer
I'm home now in Pennsylvania.  I miss the warmer weather already.  It's 15 degrees here.  My presentation went well and I enjoyed it.  I participated in the Gurupalooza afterwards.  It was alot of fun to be a part of.

I worked on the plane on a Lotus Component Designer technique for updating multiple documents within a single document.  I demoed a similar technique in my lotusphere session by using XML child elements within a document.  The issue here is how to do the same thing except with any collection of documents.  It could be response documents, or documents that meet some criteria.  The problem is that these documents come from various data sources.  When using XML child elements they are from the same datasource, the current document.

 I met with the LCD dev. team in the "meet the developers" room and they showed me an example of how to do this.  By using the Repeat control and repeating the Panel control, you can bind your data to multiple datasources.  Your fields would then be placed within the panel control.  The Panel control has properties for data sources the same as a page does.  Then by issuing  a "save()" to save all datasources, as opposed to a "document.save()",  the tool collects all the data and updates the appropriate bound documents.  You can also use the "Save Data Sources" simple action.  

Here's some screen shots.  You can download this sample LCD component from here:

Portlet screen shot:
"LCDRepeatScreenShot.GIF"

Repeat control settings:
"lcdrepeat1.gif"

Panel control settings:
"lcdpanel1.gif"

Technorati:
(0)

Search
Partner with us
Need help on your XPages projects?

Talk to the experts! Read more...
XPage Examples
By Category
About Me
Downloads
My Links
Monthly Archive
Powered by
Blogsphere
Lotus Domino ND7 RSS News Feed RSS Comments Feed Geo URL netcraft RSS Validator Lotus Geek Chris. A. Brandlehner OpenNTF BlogSphere