Pages

Thursday, November 28, 2013

Roles in XPages - Part ||

I have tried obtaining user roles using different methods before. I think the following way is pretty simple to obtian an array or user roles and a comma separated string of user roles

var userRolesArray=database.getACL().getRoles().toArray()

var userRolesString="";

for (itr=0;itr
{ userRolesString+=userRolesArray[itr]+",";
}

userRolesString;

My previous post on this topic can be navigated to by clicking on the following link

Monday, November 25, 2013

Could not open the editor: An unexpected exception was thrown - xpages

I was working with editable area controls and custom controls and for the first time, I used them together to find a time saver. Life(may be God) has its own way of playing with you. Rather I would call it insanely teasing you.

When I opened my XPage in the designer, I encountered the following error message



I felt like I was doomed. All my hard work for the day has went in vain as I did not take any backups :(

Eventually I started preparing my curse list starting with *hi**p Ri**d. No offense, just kidding. I closed down my Lotus Notes and opened it back again and the error vanished phew.... That was a silly damn thing to do. Saved me lot of hits against the wall with my head.

Also I found a post in the stackoverflow forum which gave me more ideas about why and how to handle this issue :)

Friday, November 22, 2013

A nice text font for websites


This post speaks nothing about any other technical stuffs. It is supposed to help me/ remind me with a the fact that the following combination of font-families and font sizes makes the page appear decent and good

font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;

A link like the following - XPages Extension Library - seems to be very neat too :)

I like the fonts used in the site Naveegator and also you can take a sneak peak at one of my post where I have some what ruined the UI

The styles for these links are pretty complex

color: #0077cc; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none;

Installing and running XPages Extension Library in your local machine

Shamelessly copy pasted from Naveegator

I had been hearing a lot about XPages Extension Library and finally got to try it out in XPages code-a-thon held at Mumbai. So I decided to try it on my local machine along with little help from experts on StackOverflow. Its a simple two-step procedure - install extension library and run extension library.

Install XPages Extension Library

First of all get the latest release of extension library from OpenNTF. Unzip the file and find "updateSiteOpenNTF-designer.zip". Unzip it and you will get two folders of "features" & "plugins" and a file "site.xml". In Lotus Notes sidebar, go to My Widgets and select "Options > Configure a Widget from... > Features and Plugin on an Update Site". If you are unable to see My Widgets in your sidebar then click here.


Now enter the URL for the update site as: file:///C:\updateSiteOpenNTF-designer.zip>\site.xml. Click on load button and you will get all the features in the extension library. Select all of them and click on Next and follow the instructions.

After you are done installing restart the Notes client. Then you would be able to see the extension library components in your Controls tab in Domino Designer.


Running XPages using Extension Library components

If you try to preview any XPage which uses extension library components then you would get an error as Cannot find the library com.ibm.xsp.extlib.library, required by the application . This is because the above procedure only installs the extension library only in Domino Designer, not in the local preview engine.

For that go to /domino/workspace/applications/eclipse and copy-paste the files from features and plugins extracted from updateSiteOpenNTF-designer.zip into their respective locations. Give Notes client a restart and you are ready to run XPages Extension Library.

onClick event not working in XPage Link Control - A work around


I have had issues with XPage Link Controls in the past, especially with the onClick events of the links. I was under an impression that I had a work around to solve it. Unfortunately I rediscovered that I still have issues with the same and my work around from the past failed.

It was because, I had a link with my known work around inside a table cell whose onClick event was coded.
My previous solution was for 8.5 version and with all of the new nice features in 8.5.3 I thought its time for me to go for a more stabler solution. And ended up with a better work around lol, may not be a perfect solution

In respect to my analysis, following is a possible list of reasons that your onClick event of XPage Link Controls would fail in 8.5.3

1. The onClick event of your Link Control might fail if you had associated a url to your link. Refer to the following image


2. When both URL and onClick events are provided on the XPage Link Controls, Page gets redirected to the linked url before its onClick event gets executed properly. Its a wild guess. Please check for its authenticity your self

3. The onClick event might fail on the wonderful IE browser if a parent container like a div or a table cell which contains the Link Control has code on its onClick event or other events like onMouseover etc

In order to over come all still be able to use both "link" and onclick event, remove the url mapping to the link control and use call a button controls onclick event on the client side onclick event of the link. And code all you want in the button both client and server side. This seems to remove alot of problems and has worked for me. I know that I am complicating stuffs with my words here, so take a look at the following image. Probably you would understand stuffs better.


And dont even think about screaming something like "HEY, THATS CHEATING. ITS NOT A FAIR SOLUTION". As I said earlier, this is a possible work around that has worked for me. I dont mean this to be a final solution :P

Friday, November 8, 2013

"last" link in Xpage pager control not working

I recently had to work with pager controls in Xpages.  I used to work with the default “Sample 1″ style for “Pager style” and this time I had to go for other styles that displays the "last" link in the pager. For some reason it did not render and instead I had to see a few dots instead of the "last" link.
It was as if some thing like "to be continued...." . Damn IBM walas... that was very good way to mock me :P
Eventually got my heart in mouth lol as I was under a lot of pressure to get it to work. With some research I found a post somewhere in the ibm developer works were a like minded person (may be) was enjoying this funny joke by IBM. One of the replies to that post suggested a work around hack to calculate total view entries count, divide it by number of documents being displayed and associate it with view control display etc...
I short I wanted my pager to look something like the following :
|< >| 
But it was looking something like the following
|< ..
I tried inspecting the pager and to my astonishment, it was never there. It was really something like "to be continued..." , I mean it was never calculated by the XPage
After some poking around and some more google searches, I found “alwaysCalculateLast” in the All Properties tab for the pager control. I set it to true and it works like charm :)

Thursday, November 7, 2013

Get label of link in XPages

In order to get value from a component like Edit box control etc in an XPage I use

getComponent("ControlName").getValue()

When it comes to a link it will give you the URL Value that the XPage link control has been mapped. In order to obtain the Label or the Name of the link (and not url) you got to use the getText() method.

Following is a brief illustration of what I am talking about


Following is the result obtained on the browser


Get class name of Components in XPage

Its very easy to obtain the class name of components in Xpages. The only issue is that, its difficult if you dont know how :P

Well for starters (like me) drag and drop a control on to an XPage. Give it a name say "MyControl"

Now add a label to the XPage where you performed the above mentioned difficult steps and use the following code to compute its label

getComponent("MyControl").getClass().getName()

In my case I tried it with a link object and got the following stuffs on my screen




If you feel curious about understanding (most likely about simply knowing) controls better you can refer to the control documentation. Following post speaks about its where abouts.

http://xcellerant.net/2013/09/17/tip-finding-all-properties-and-methods-available-for-xpages-components/