Saturday, July 30, 2011

XPages Domino Object Map 8.5.2

I recently happened to come across a page where I was able to find this
XPages Domino Object Map 8.5.2. It reminds me of old times when I used to work with version 7. And I really missed the hirerachy map in later versions though I had them byhearted. This one seems to be pretty similar and is a good one. You get to click on the map to see the details associated with them.

I know many would have known it already, but still there must be people who would seek this. So this is my turn to share my discovery :)

Hope this helps :)

Wednesday, July 27, 2011

Regular expression to remove all numbers from a string

This is in continuation to my previous post where I posted the code to remove characters that are not digits. This case is vice versa.

var pattern=/\d/g;
var myString="80AlphaDog55";
alert(myString.replace(pattern,""));

The result is AlphaDog

hope this helps :)

Regular expression to remove all alphabets in a string

Regular expressions are very handly when it comes to working with patterns. In my case working with patterns in javascript. It saves me pile of code that needs to be written in javascript to do pattern based validations.

Following is a simple line of code that helps me to replace all the non digit characters from a string

var pattern=/\D/g
var myStr="80Alpha5Dog5"
alert(myStr.replace(pattern,""))

The answer would be BOSS :)

Hope that helps :)

Thursday, July 14, 2011

"Automation server can't create object" - Occuring with "ActiveXObject('Word.Application')"

This specific error occurs when your browser does not support ActiveXObjects or it does support ActiveX but the security features configured does not allow it to proceed.

Hence to fix this issue ActiveX controls must be allowed in the browser


Go to Tools -> Internet Options -> Security -> Custom Level and make the following changes under the ActiveX Controls and plug-ins section




1. Enable - Allow prompting for ActiveX controls   (optional/probable)

2. Enable - Download signed ActiveX controls

3. Enable - Initialize and script ActiveX controls not marked as safe for scripting


Hope this helps :)

Try catch doesnot catch ActiveXObject errors

I had been thinking about making a post on this for a very long time. Unfortunately for some reason , I kept forgetting about it from time to time. And at last I have even forgot that I faced such an issue in the past until recently.

As per my understanding errors that occur due to automation object creation failures when attempting to create ActiveX Objects can't be handled by try catch block. Instead, one must check it right up front to give the desired error message to the user.

the following is a simple illustration of what i am speaking about,

try{
...
var obj=new ActiveXObject("Blah blah blah");   // suppose error occurs in this statement
...
} catch (activeXError) {
  // the error that occured due to active x object creation failure does not get captured here and hence any
  //code that you exectute here does not get executed. Rather you can find an abrupt error message in the
  //console
}

So in order to handle it, you must check it upfront,

if (window.ActiveXObject) {
  ... blah blah blah....
} else {
  // report error
}

Hope that helps :)

Thursday, July 7, 2011

Regular Expression to filter HTML Tags

Following is a simple way by which one can filter out the html tags say from ajax responses etc…


normalString=htmlString.replace(/<\/?[^>]+(>
$)/g, "");

inorder to filter out carriage returns one can use

String. replace(/\n/g, "");

AJAX Post Request in Lotus Notes

Following is a short abstract of how you can create AJAX POST request.


One can always find a way to create an XMLHTTPREQUEST and many cross browser solutions are available across the internet. eg w3schools. So if leave the function call in the very first line for you to code.



var mypostrequest=new ajaxRequest()

//handle the response

mypostrequest.onreadystatechange=function(){

if (mypostrequest.readyState==4){

if (mypostrequest.status==200

window.location.href.indexOf("http")==-1){

//handle your response here

}

}

}

//open a post request

mypostrequest.open("POST", “your agent url", true);

mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

//sample parameter

Var parameters = “label=value&process=post”

//send in the parameters to be processed in the lotus script agent

mypostrequest.send(parameters);

Friday, July 1, 2011

Eclipse Plugin for Tomcat Server with Hello World

The following site seems to be a good source for downloading and installing a Tomcat Server plugin for Eclipse.
All you got to do is download this plugin and proceed with the following procedure to install them
  • This plugin does not contain Tomcat.
    (Download and install Tomcat before using this plugin).
    This is a design choice not to include Tomcat in the plugin distribution, this way the same plugin version can works with any Tomcat version.
  • Download tomcatPluginVxxx.zip
  • Unzip it in :
    - Eclipse_Home/dropins for Eclipse 3.4, 3.5 and 3.6
    - Eclipse_Home/plugins for Eclipse 2.1, 3.0, 3.1, 3.2 and 3.3
  • Plugin activation for Eclipse 3.x :
    - launch eclipse once using this option :
     -clean
    - if Tomcat icons are not shown in toolbar : select menu 'Window>Customize Perspective...>Commands', and check 'Tomcat' in 'Available command groups'
  • Set Tomcat version and Tomcat home : Workbench -> Preferences, select Tomcat and set Tomcat version and Tomcat home (Tomcat version and Tomcat home are the only required fields, other settings are there for advanced configuration).
  • This plugin launches Tomcat using the default JRE checked in Eclipe preferences window.
    To set a JDK as default JRE for Eclipse open the preference window : Window -> Preferences -> Java -> Installed JREs.
    This JRE must be a JDK (This is a Tomcat prerequisite).
The plugin sets itself Tomcat classpath and bootclasspath. Use Preferences -> Tomcat ->JVM Settings, only if you need specific settings.

 
The following site contains an awesome example/illustration that will help you get started with the plugin on eclipse
Once you have installed the plugin, the following are the things that you need to have a closer look at.
You would be able to see 3 icons added to the eclipse tool bar which is as illustrated in the following image . And these are  self explanatory

Go to Windows->Preferences. This will bring up the Preferences dialog box, that will contain a whole new section as highlighted in the navigation section.  And on the right side you have to choose your Tomcat version and provide its installation path as Tomcat home

Specifying the tomcat home helps the plugin assume the path of the server.xml file which in my case is as follows

Well you may not do much with this one for the time being, but its always good to know right J
Once that’s done, Navigate to the Tomcat Manager App option available in the left menu of the preferences window as illustrated by the following image

Now when you provide a ManagerApp username and ManagerApp password, and click on “Add user to tomcat-users.xml”, this will update the corresponding xml file as illustrated by the following image


As you can see, the username and password are abruptly visible and hence exercise caution in handling these files to avoid security breaches
Once the above stuffs are complete now create a new project by right clicking the navigator as illustrated in the following images
 
So create a new tomcat project as mentioned above and now name them as per your requirement and in this case it is “HelloWorld” and create your servelet classes as illustrated in the following image. Mind the folder structure :)
 

Now create your web.xml file in the same WEB_INF folder and not in the src folder that is highlighted above with servelet mappings to class file and url, in my case the web.xml file contains
DOCTYPE web-app PUBLIC
  '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
  'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
  <servlet>
    <servlet-name>helloservlet-name>
    <servlet-class>HelloServletservlet-class>
  servlet>

  <servlet-mapping>
    <servlet-name>helloservlet-name>
    <url-pattern>/hellourl-pattern>
  servlet-mapping>
web-app>
Now save all your work. Start your tomcat server and check out the following url,
In my case the pages looks like the following


The materials contained here are more exhaustive than the one posted here.

Hope this helps :)