The following lotusscript command gives a very good way of obtaining a the current time alone.
Format(Now, "Long Time")
hope this helps :)
Share your thoughts and find that its getting better every day. This work of mine helps me realize that.
Thursday, February 10, 2011
Wednesday, February 9, 2011
agent.runWithDocumentContext(NotesDocument) not working in XPages
If you attempt to execute a Lotus Script agent from the server side script in the XPages and get the following error,
1. Sign the agent, XPage and the associated elements. Better sign the database with the server id.
2. Ensure that you have sufficient access to execute agents
3. Ensure the "Run as Web User" and "Allow Restricted Operation" are selected on the agent
4. Ensure that the type of the agent is "Agent List Selection" with target "None"
Hope this helps :)
Labels:
Lotus Notes,
Server Side Javascript,
XPages
Friday, February 4, 2011
How to capture orientation change event using Sencha Touch
One of the classy/awesome feature of an iPad, is the way the screen changes resolution/orientation as and when you rotate the iPad physically. The pages that you see on the screen switches between landscape to portrait mode just like that in a nice smooth continuous fashion.
Hence it becomes important for a iPad application developer to ensure that the page we develop for the iPads, looks good in all orientations and hence we definitely have to know where and when to change the application's styles.
For a simple panel created using using Sencha Touch, add the following property to capture the orientation changing event and you are set to go. Hope this is applicable to all components in sencha touch.
listeners: {
orientationchange : yourCustomFunction
}
Hope this helps :)
Hence it becomes important for a iPad application developer to ensure that the page we develop for the iPads, looks good in all orientations and hence we definitely have to know where and when to change the application's styles.
For a simple panel created using using Sencha Touch, add the following property to capture the orientation changing event and you are set to go. Hope this is applicable to all components in sencha touch.
listeners: {
orientationchange : yourCustomFunction
}
Hope this helps :)
How to get the current node/leaf selected in a NestedList - Sencha Touch Framework
The following code fragment will help you alert the text that is present in the leaf/node of a nested list which is being clicked. The nested list one which is created using sencha framework
activeListItem = yourNestedList .getActiveItem(),
associatedRecord = activeListItem t.getSelectedRecords()[0];
alert( record.get('text'))
Hope this helps :)
activeListItem = yourNestedList .getActiveItem(),
associatedRecord = activeListItem t.getSelectedRecords()[0];
alert( record.get('text'))
Hope this helps :)
OnClick event for list items in NestedList - Sencha Touch Framework
Following is a fragment of code that builds a plugin to listen to the click events on the leaf/list items in a NestedList created using the Sencha Touch Framework. This is already present in the Kitchen Sink example provided in the Sencha Touch's Site
---------------------------Block A---------------------------
/**
* @class Ext.LeafSelectedPlugin
* @extends Object
*
* A simple plugin for a NestedList which adds a "leafselected"
* event which accounts for cardswitching and selectionchange.
*
* This is useful when you want to enable editing of all leaf items.
*/
Ext.LeafSelectedPlugin = Ext.extend(Object, {
init: function(nestedList) {
this.nestedList = nestedList;
nestedList.addEvents('leafselected');
nestedList.on('cardswitch', this.onCardSwitch, this);
nestedList.on('selectionchange', this.onSelectionChange, this);
},
onCardSwitch: function(ct, newCard, oldCard, newIndex, animated) {
var nestedList = this.nestedList;
if (newCard.getSelectedRecords) {
var record = newCard.getSelectedRecords()[0];
if (record) {
nestedList.fireEvent('leafselected', record.node.isLeaf());
} else {
nestedList.fireEvent('leafselected', false);
}
} else {
nestedList.fireEvent('leafselected', false);
}
},
onSelectionChange: function(selModel, records) {
var nestedList = this.nestedList,
subList = selModel.view;
if (nestedList.getActiveItem() === subList) {
if (records[0]) {
nestedList.fireEvent('leafselected', records[0].node.isLeaf());
} else {
nestedList.fireEvent('leafselected', false);
}
}
}
});
---------------------------Block A---------------------------
Add the above mentioned code to a script library
Include your script library into the XPage or your HTML file and do the following
---------------------------Block B---------------------------
var yourNestedList =new Ext.NestedList({
plugins: [new Ext.LeafSelectedPlugin()],
//your other parameters
});
---------------------------End of Block B---------------------------
Now call the following function to trigger the onclick or onselected event of the leaf/item of the nestedList
---------------------------Block C---------------------------
yourNestedList .on('leafselected', function(enabled) {
alert('I am on the onclick event of the leaf/item of your nested list');
---------------------------Block A---------------------------
/**
* @class Ext.LeafSelectedPlugin
* @extends Object
*
* A simple plugin for a NestedList which adds a "leafselected"
* event which accounts for cardswitching and selectionchange.
*
* This is useful when you want to enable editing of all leaf items.
*/
Ext.LeafSelectedPlugin = Ext.extend(Object, {
init: function(nestedList) {
this.nestedList = nestedList;
nestedList.addEvents('leafselected');
nestedList.on('cardswitch', this.onCardSwitch, this);
nestedList.on('selectionchange', this.onSelectionChange, this);
},
onCardSwitch: function(ct, newCard, oldCard, newIndex, animated) {
var nestedList = this.nestedList;
if (newCard.getSelectedRecords) {
var record = newCard.getSelectedRecords()[0];
if (record) {
nestedList.fireEvent('leafselected', record.node.isLeaf());
} else {
nestedList.fireEvent('leafselected', false);
}
} else {
nestedList.fireEvent('leafselected', false);
}
},
onSelectionChange: function(selModel, records) {
var nestedList = this.nestedList,
subList = selModel.view;
if (nestedList.getActiveItem() === subList) {
if (records[0]) {
nestedList.fireEvent('leafselected', records[0].node.isLeaf());
} else {
nestedList.fireEvent('leafselected', false);
}
}
}
});
---------------------------Block A---------------------------
Add the above mentioned code to a script library
Include your script library into the XPage or your HTML file and do the following
---------------------------Block B---------------------------
var yourNestedList =new Ext.NestedList({
plugins: [new Ext.LeafSelectedPlugin()],
//your other parameters
});
---------------------------End of Block B---------------------------
Now call the following function to trigger the onclick or onselected event of the leaf/item of the nestedList
---------------------------Block C---------------------------
yourNestedList .on('leafselected', function(enabled) {
alert('I am on the onclick event of the leaf/item of your nested list');
});
---------------------------End of Block C---------------------------
---------------------------End of Block C---------------------------
iPad Detection Using JavaScript
Following fragment of code helps in detecting whether an application is being previewed in a iPad or a normal web client.
// For use within normal web clients
var isiPad = navigator.userAgent.match(/iPad/i) != null;
// For use within iPad developer UIWebView
var ua = navigator.userAgent;
var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua)
For more info take a look at http://davidwalsh.name/detect-ipad
Hope this helps :)
// For use within normal web clients
var isiPad = navigator.userAgent.match(/iPad/i) != null;
// For use within iPad developer UIWebView
var ua = navigator.userAgent;
var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua)
For more info take a look at http://davidwalsh.name/detect-ipad
Hope this helps :)
Labels:
IPad,
Javascript,
Mobile Application Development
Monday, January 31, 2011
Xpages - How to dynamically add client side script library? (xp:headTag)
The following is a way using which u can include client side javascript libraries into xpages in a dynamic fashion. Yes it lets you compute javascript library's URL in the XPage.
Note the usage of the scoped variables along with custom text in constructing the url of the script library
<xp:headTag tagName="script" rendered="true" loaded="true">
<xp:this.attributes>
<xp:parameter name="clientSide" value="true"></xp:parameter>
<xp:parameter name="src">
<xp:this.value>
<![CDATA[#{javascript:return applicationScope.get("senchaSourceBase")+"sencha-touch-debug.js"}]]>
</xp:this.value>
</xp:parameter>
</xp:this.attributes>
</xp:headTag>
Note the usage of the scoped variables along with custom text in constructing the url of the script library
<xp:headTag tagName="script" rendered="true" loaded="true">
<xp:this.attributes>
<xp:parameter name="clientSide" value="true"></xp:parameter>
<xp:parameter name="src">
<xp:this.value>
<![CDATA[#{javascript:return applicationScope.get("senchaSourceBase")+"sencha-touch-debug.js"}]]>
</xp:this.value>
</xp:parameter>
</xp:this.attributes>
</xp:headTag>
How To Add Style Sheet URL Dynamically To XPages? (xp:headTag)
The following is a way using which u can include style sheets into xpages in a dynamic fashion. Yes it lets you compute style sheet URL in the XPage.
Note the usage of the scoped variables along with custom text in constructing the url of the style sheet
<xp:headTag tagName="link" rendered="true" loaded="true">
<xp:this.attributes>
<xp:parameter name="rel" value="stylesheet"></xp:parameter>
<xp:parameter name="type" value="text/css"></xp:parameter>
<xp:parameter name="href" >
<xp:this.value>
<![CDATA[#{javascript:return applicationScope.get("scopeVariableNameContainingURL")+"leftouturl/filename.css"}]]>
</xp:this.value>
</xp:parameter>
</xp:this.attributes>
</xp:headTag>
To know about including client side script libraries in a similar fashion click here
Hope this helps :)
Note the usage of the scoped variables along with custom text in constructing the url of the style sheet
<xp:headTag tagName="link" rendered="true" loaded="true">
<xp:this.attributes>
<xp:parameter name="rel" value="stylesheet"></xp:parameter>
<xp:parameter name="type" value="text/css"></xp:parameter>
<xp:parameter name="href" >
<xp:this.value>
<![CDATA[#{javascript:return applicationScope.get("scopeVariableNameContainingURL")+"leftouturl/filename.css"}]]>
</xp:this.value>
</xp:parameter>
</xp:this.attributes>
</xp:headTag>
To know about including client side script libraries in a similar fashion click here
Hope this helps :)
Thursday, January 27, 2011
View All Design Elements in a Lotus Notes Database in a Single View ($FormulaClass)
The design properties of View Consist of a item named "$FormulaClass".
It is the value on this item that decides the boundaries on what a view can display. By Default the value on this is "1". And this means a lotus notes view with "$FormulaClass" item set to 1 can display only documents present in a database, which is again governed by the view's selection formula.
But when we change this particular value to a set of predefined values, it works wonders.
The following table would give you a glimpse of what it is capable of.
Value of $FormulaClass Viewing Elements
Yes changing the view's $FormulaClass item value to one of the above mentioned values will help you display design docs too...(And that can be controlled/manipulated) in a lotus script agent
It is the value on this item that decides the boundaries on what a view can display. By Default the value on this is "1". And this means a lotus notes view with "$FormulaClass" item set to 1 can display only documents present in a database, which is again governed by the view's selection formula.
But when we change this particular value to a set of predefined values, it works wonders.
The following table would give you a glimpse of what it is capable of.
Value of $FormulaClass Viewing Elements
1 Documents
4 Forms and Subforms
8 Views, Folders and Navigators
16 Database Title
32 Design Collection
64 ACL Note (in compiled format)
512 Agents (Shared)
1024 Shared Fields
1548 Forms, Sub-forms, Views, Folders,
Navigators, Agents(Shared),
Navigators, Agents(Shared),
Shared Fields
Yes changing the view's $FormulaClass item value to one of the above mentioned values will help you display design docs too...(And that can be controlled/manipulated) in a lotus script agent
I have checked with 8.5.2 and the value "1548" in "$FormulaClass" of the view also displays XPages and CustomControls.
Seems like a visual equivalent of NotesNoteCollection.
Caution :
I copied paste all the documents in a view with "$FormulaClass" set to "1548". And it did duplicate my design elements. So be careful when you perform any tests with this concept
A working illustration is found in the following page:
Hope this helps:)
Filter HTML/XML tags from a text
function filterHtmlTags(source) {
var result=source.replace(/(<([^>]+)>)/ig,"");
result=trim(result, "\n");
return result;
}
//function to trim of leading and trailing spaces
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}
//function to trim of white spaces on the left
function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
//function to trim of white spaces on the right
function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
var result=source.replace(/(<([^>]+)>)/ig,"");
result=trim(result, "\n");
return result;
}
//function to trim of leading and trailing spaces
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}
//function to trim of white spaces on the left
function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
//function to trim of white spaces on the right
function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
Labels:
HTML,
Javascript,
XML
Subscribe to:
Posts (Atom)
