Pages

Monday, November 1, 2010

Setting "Do not locally Encrrypt" by default

Copying Databases into our local file system with encryption is one of the head ache in most of the times when u really dont want any security to be associated with the database being copies, example POCs etc

Setting this property is some thing that I use time and again and forget where I did it.

Hope the following piece of info helps people recollect this stuff.

-->choose File
-->Security
-->User Security 
--> Notes Data 
--> Notes Databases 
--> select "Do not locally encrypt" 
--> click OK

It is as illustrated in the following image,



:)

Friday, October 22, 2010

Single Copy XPages Design - SCXD - Lotus Notes 8.5.2

I recently stumbled upon a brand new feature of Lotus Notes 8.5.2.

It is about Single Copy XPages Design. Following URL Has exhaustive description about the same and it seems quite interesting too...

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Single_Copy_XPage_Design

Hope this helps :)

Thursday, October 21, 2010

Opening Documents from Views in a different tab on the same XPage

I happened to perform an R&D on how to open up documents on new tabs with in the same XPage when you click on links in XPage views.

I searched for ideas over the net and I got the idea of using Dojo tabs as Dojo is shipped with XPages.

After an exhaustive search for the resources on web I arrived at the desired results.

Following is an abstract of how I got the same to work on XPages.

Create a Form, map it to a View and  create a few documents.
Now Create an XPage and bind the same to your form and map all the test fields that you have on your form to the xpage
Now Create an other XPage and put the following code into it

  Step 1: Enclose the following style imports to an XPage
        @import "../resources/dojo.css"; 
        @import "../dijit/themes/tundra/tundra.css";

  Step 2: Include the dojo.xd.js into the XPage using the following script tag
    <script type="text/javascript" src="dojo.xd.js"
        djConfig="parseOnLoad: true">
    </script>
   
  Step 3: Add the following scripts to the XPage
        dojo.require("dojo.parser");
        dojo.require("dijit.layout.ContentPane");
        dojo.require("dijit.layout.TabContainer");
        dojo.require("dijit.form.Button"); dojo.require("dojo.widget");       


Step 4: Put the following html on the page
    <h1>Tab Container </h1>
    <div id="mainTabContainer" dojoType="dijit.layout.TabContainer"
        style="width:500px;height:500px">
        <div id="tab1" dojoType="dijit.layout.ContentPane"
            title="Open Docs in New Tab" selected="true">
        </div>
        <div id="tab2" dojoType="dijit.layout.ContentPane"
            title="Normal Way">
        </div>
    </div>

Now DRAG AND DROP your View into the DIV WITH ID "tab1".



Now switch to the data tab of the same column and key in the following code, as shown in the following figure,

-----------------------------------
"<a href='#' onclick='addTab(\""+rowData.getColumnValue("Name")+"\",\""+
rowData.getUniversalID()+"\")'>"+rowData.getColumnValue("Name")+"</a>"

-----------------------------------

Now create a Server script library by the name, commonFunctions and include the same on to your XPage.
Put the following function into that script library and save the same.

------------------------------------

function addTab(tabTitle,unid){

    var url="http://andromeda/dojo/XPageDojoTabsTest.nsf/openform.xsp?documentId="+    unid +"&action=editDocument";
    var tabs = dijit.byId("mainTabContainer");
   
    var pane = new dijit.layout.ContentPane({
        title:tabTitle,
        content:"<iframe border='0px solid #ffffff' frameborder='0' src='"+url+"'> </iframe>",
        closable:true
    });
   
    tabs.addChild(pane);
    tabs.selectChild(pane);
}

------------------------------------

Once this is complete you are good to go... Preview your XPage on the Browser or the Notes Client and click on the links that appear in the view.
When you click on the links you can visuallize the documents getting opened on new tabs,
There you go, a POC...

Hope this helps :)

Tuesday, October 19, 2010

Binding Richtext Fields and File Upload Controls in XPages

The following is a simple POC that describes how file upload controls on XPages work when bound to Rich text fields in Notes Forms.

Create a Simple form with 2 Rich Text fields and bind them to two file upload controls respectively on a Xpage as shown in the following figure and save them.


Now Preview the XPage, add a couple of attachments and Save the XPage


The code that I used in the upload button here is - currXPDoc.save() where currXPDoc is my datasource's name

Thus a document gets saved in the back end. Opening the same will help you find the attachments embedded into their respective richtext fields as follows,

Hope this helps :)



Wednesday, October 6, 2010

Running Scheduled Agents from Server Console

When working with scheduled agents, we often tend to run the agent by right clicking it and clicking on run or calling it on a button click before we schedule it. It may not work always, cos scheduled agents will have a lot of issues that are not associated with a normal agent which may run properly with your security permissions when you run it.

For example you may have a role enabled for you on the ACL where as your server may not.
So Scheduled when they run automatically will run with server rights over the database and hence may result in different results.

So the best way I know to test the working of a scheduled agent is by running it through the following command,

Tell Amgr Run "DatabasePath" 'AgentName'

Mind the usage of the single and the double quotes. They must not be changed.

Hope this helps :)

Monday, October 4, 2010

Expanding and Collapsing Categories in a XPage View

For expanding and Collapsing category entries in an XPage,
   Go the all properties section of the XPage, Navigate to Data -> Data -> Expand Level as illustrated in the following figure

Specifying 0 here will collapse all entries and 1 will expand the same.

Also in case of a view containing multiple category columns, 1 will expand the first level categories with the other levels like 2nd or 3rd or so on collapsed.

Like wise specifying 2 here will expand the first category as well as the second category where as the 3rd or 4th or so on will be collapsed

Using a session scoped variable or a request scoped variable we can probably compute this on button clicks which might be handy for the end users...

Hope this helps :)



Tuesday, September 28, 2010

OnUnload event in XPages

Add the following script block to your xpage. Preview the same and  close it. Once you close your XPage you will get a prompt which depicts the triggering of the onUnload event in xpages.

 <xp:scriptBlock>
<xp:this.value escape="false">
window.onunload=function() {
alert('I run on window unload');
}
</xp:this.value>
</xp:scriptBlock> 

A little bit of client techniques to include server side scripts will also work here.

Hope this helps:)


Monday, September 20, 2010

Getting User's Name on the XPage

The content that I am trying to describe on this particular post is fairly simple. Many of you guys out there would have faced it and solved it. But still I would like to share this cos, really XPages are stupid at times.

I had the formula session.getCommonUserName() on a lable which worked for me through out the period I was developing my last application. When I moved the same to a test server to test the same, to my astonishment I found that the label with the above mentioned code displaying my test server's name.

I opened up the XPage in designer, saved it manually,
Signed the database using server id,
compacted the database ,
Restarted my test server etc etc...

All of the above steps failed and it still kept displaying my server name

Later I changed the code to @Name("[CN]",@UserName()), the formula eqivalent in server script.
OOPS that failed tooo...

And after a few brief moments of frustrations, I got the following idea,
@Name("[CN]",session.getEffectiveUserName())

And that eventually saved me.

Feels strange aaha...

Hope this helps :)

Roles in XPages

I had a hard time working with user roles in XPages.

  I used to the following procedure which is a server script equivalent of the lotus script equivalent of the @UserRoles which wont work on server side javascript :) (confusing aaha...)

var acl:NotesACL= database.getACL();
var entry:NotesACLEntry = acl.getEntry(@Name("[CN]",@UserName()))
if (entry==null)    {
    entry = acl.getEntry(session.getUserName())
}
 
if (entry==null)    {
    return "";
}

entry.getRoles();


It did work to some extent. But I really had a very tough time with this. It seemed to work fine for a while but to my astonishment it started showing only my server's role enabled on the database . It was very irritating and I felt ridiculous about it.

Later I explored the web to arrive at the fairly simple decent solution as follows,

context.getUser().getRoles();

Yes the above mentioned line did the job for me. Hope this helps some one :)

Tuesday, September 14, 2010

Recover a corrupted archive of the Excel format

One of the readers suggested the following tool for recovering corrupted excel files.

It feels like a handy tool to help in case of excel file corruptions. Also it covers a wide variety of files like *.xls, *,xlt, *.xlsx, xlsm, *.xltm, *.xltx, *.xlam.

I haven't had a chance yet to use it 'cos i dont have a corrupted excel file for the time being (but yes of course have gone through its features :)


Wish I could have had it few months back :).

For more details about the recovery tool click here
 Not feeling patient.... K download it directly



Hope this Helps :)