Archives for the ‘Tutorials’ Category

14 Mar 2013
0

Video Tutorial: Get up and running with Lotus Domino Designer 8.5.3

Hi everyone. So here’s my next Video Tutorial. I show you how to download Lotus Domino Designer 8.5.3 and I also give a quick demo on how to set up your first Notes Application.

I decided to go back to basics and assist those who are new to IBM (Lotus) Notes, especially those who want to get started on Notes/Domino and XPages Development. I end off the Video Tutorial showing you how easy it is to create a working CRUD Application (Create/Read/Update/Delete) in the Notes Client.

If you use iTunes, you can download this video via David Leedy’s NotesIn9 Podcast series.

Enjoy :)

John.

17 Jan 2013
2

XPages Tip: Pass NotesDateTime to the Javascript Date Object

Hi all.

I spent this morning creating a massive SSJS Validation Rule that had to do with Date and Time values that were provided by the User online. I think Date Objects will forever remain my Everest, because I just can’t seem to get it right without wasting hours on it.

In SSJS, the problem with the NotesDateTime Object is that properties like “getDateOnly”, “getTimeOnly” and “getLocalTime” return the values as strings. If you want to compare values, you’re in for a tough time.

Now the Javascript Date Object offers you way more in terms of comparing values. Click here to check an awesome function you can use in your code.

I had a scenario where I was using NotesDateTime Objects to manipulate Date/Time Values, but I wanted to pass these Date/Time Values to the JavaScript Date Object to perform compares, etc. My first attempt failed when I tried to use the “getLocalTime” property of the NotesDateTimeObject:

Note: This example is not best practice, but allows me to show you a function available in SSJS

var date1:NotesDateTime = session.CreateDateTime(“2013/01/17 06:00:00″);

var date2:Date = new Date(date1.getLocalTime());

The above-mentioned will fail because date1.getLocalTime() is an illegal Date value according to the JavaScript Date Object. Having said that, there is an awesome NotesDateTime Method called .toJavaData() that converts the value to a JavaScript Date Object:

var date1:NotesDateTime = session.CreateDateTime(“2013/01/17 06:00:00″);

var date2:Date = new Date(date1.toJavaDate());

From here use you can use the Date Object for comparing Date and Time Values.

I trust this helps :)

John.

9 Nov 2012
-

Use Dojo or jQuery to manipulate Printing of Web Pages

Hi everyone. Here’s a second post that was published by Johan Meyer, Ukuvuma’s senior Microsoft Developer.

Enjoy

John.

 

From Johan Meyer at Ukuvuma Solutions

Okay, this is a nice short tutorial where I will show you the following:

  1. How to create a print button on a web page.
  2. Use Firebug (Firefox), Developer Tools(IE) or any other developer tools available to identify what controls needs to be hidden or showed before the page gets printed.
  3. Show you what code is needed for jQuery or Dojo.

 

1. How to create a print button on a web page.
First off you need to create a Print button. Now normally when I create an image as a button on a web page I will use CSS for the style and a <div> for the button.

So first add a <div></div> tag to your Page and give it a class name, for this example I will be using “printButton” as the class name.
In your HTML file add this div:

<body> <div class="printButton"> </div> </body> 

Now that you have your div you need to create the Stylesheet that will style our print button.  Add a CSS file to your project and add the following to it.  The dot before printButton means that this style is applicable to the printButton Class.  If the printButton had a # before it would look for the div’s ID.

.printButton {

background-image: url(“printButton.jpg”);

background-repeat: no-repeat;

cursor: pointer;

cursor: hand;

height: 20px;

width: 20px;

padding: 5px;

}

 

This style will change your div however you want it.  The first two lines will show your image without repeating it.  Then we use two cursors, the first one works for IE and the second for Firefox (this is the code that will show the little hand when you hover over the image).  Then we set the fixed width of the div and the padding to make it look a bit nicer.

 

 

 

 

 

The image above shows how the button should look by now.  To create an actual print button we need to add the Javascript print command.  Add the following to your printButton div.

<html>

<head>

<script type=”text/javascript” language=”javascript”> function printDocument() { window.print(); } </script>

</head>

<body>

<div onclick=”javascript:printDocument();”> </div>

</body>

</html>

 

The onclick event fires a javascript function called printDocument().  Inside this function we call a JavaScript function that calls the browsers print class.  This will print the document but not always as the user would want it to print.

 

2.  Use Firebug to enhanced the nor window.print JavaScript function

For now I’m not going to go into depth of how firebug works but I will post on how to use it and all about what I know of firebug in one of my future posts.

Use Firebug and look through the website that you want to print and identify what controls you want to hide before printing, or what controls you want to modify in size before printing.

If you have a layout that looks like this, it is likely that you only want the content part of this layout.  So identify the controls by ID or by class and write them down.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The sections that we will want to hide are: LeftSide, Header, Footer and RightSide.

 

3.  JQuery and Dojo code

Now that you know what controls you don’t want to show, you need to hide them before calling the printing function and show them again after printing.

In the printDocument function add the following code for jQuery:

<script type=”text/javascript” language=”javascript”>

function printDocument() {

jQuery(“.LeftSide”).hide();

jQuery(“.Header”).hide();

jQuery(“.Footer”).hide();

jQuery(“.RightSide”).hide();

window.print();

jQuery(“.LeftSide”).show();

jQuery(“.Header”).show();

jQuery(“.Footer”).show();

jQuery(“.RightSide”).show();

}

</script>

 

And this if you want to use Dojo:

<script type=”text/javascript” language=”javascript”>

function printDocument() {

dojo.query(“.LeftSide”).style(“display”, “none”);

dojo.query(“.Header”).style(“display”, “none”);

dojo.query(“.Footer”).style(“display”, “none”);

dojo.query(“.RightSide”).style(“display”, “none”);

window.print();

dojo.query(“.LeftSide”).style(“display”, “block”);

dojo.query(“.Header”).style(“display”, “block”);

dojo.query(“.Footer”).style(“display”, “block”);

dojo.query(“.RightSide”).style(“display”, “block”);

}

</script>

 

If you need to call some of the controls on the ID instead of Class, you can change the jQuery to “#Header” and the dojo you need to remover the string with the dot and add dojo.byId(“Header”) instead.

You can manipulate the page as you like, just return everything back to normal after the user has printed or redirect them to a new page.

Hope you enjoyed this tutorial.

18 Sep 2012
3

TUTORIAL: Integrating XPages with DB2 – Part 2

Hi everyone. So, just 2 things firstly:

1. This is an extended Post to David Leedy’s NotesIn9 Posting of “Intro to XPages and Relational Data – Part 2“.

2. I do apologize that this took a while to publish. This is one of the more challenging years to find some free time to contribute to the Domino and XPages community. Having said that, I have quite a few Video Tutorials planned before this year ends, so stay tuned :)

 

Now that that’s out the way…..this post is Part 2 to the “Integrating XPages with DB2 – Part 1“. In this Video I show you how to Create/Read/Update/Delete DB2 Data using XPages. More importantly, I show you how to empower the User to perform all these functions via a User Interface. It’s usually easy to write this logic in the back-end, but a little more involved when handing that power over to the User.

 

The good news is that it’s fairly straightforward. I show you some quick functions that will get you up and running in no time. As I explained in the Video though, there are much more advanced ways of integrating to DB2. This will involve some knowledge of DB2 itself. The keyword is…..”Stored Procedures“. This is where the power lies. A Stored Procedure is very much like a Sub Routine in LotusScript or a Function in Java or JavaScript, but you code in SQL Language. You can pass the Stored Procedure parameters, have all your logic neatly set out in a central place in DB2 and return values from the Stored Procedure which will allow you do things like create Child Documents, etc.

Later on in the near future, I will think up a straightforward Tutorial which will show you how this all works.

I hope you enjoy this Video. I really enjoyed making it. It was one of my smoothest recordings where everything went right the first time.

I want to thank David Leedy as always for adding this to his NotesIn9 Series. You da man :)

Cheers.

John

 

IMPORTANT NOTE: If you are not able to view this Video in HD, please Click Here to open this video up in a different Player.

15 Mar 2012
2

Use YSlow to measure your Site’s performance and more

Hi Everyone.  Here’s a quick post that I’m sure will make all the difference in your Web Dev Life.

There is a Browser plug-in called YSlow. You can install it on Firefox, Chrome, Safari, Opera and more. I’m going to use the Firefox plug-in for this example.

NOTE: For Firefox, you need to install Firebug to use this plug-in, as it’s an extension to Firebug.

Once you’ve installed the Firebug and YSlow plug-in, and restarted your Browser, do the following:

1. Open your Website. In my example I’m using my XPages Showcase for this example.

2. Push F12 on your keyboard. This will open the Firebug Window at the bottom of the Browser.

3. Click on the YSlow Tab. You’ll see an introduction Page, and a button at the bottom that says “Run Test”. This takes about 2-5 seconds to run.

 

 

4. Once completed, YSlow returns a set of results. You’ll get an overall Grade with a Performance score. (Please don’t judge me for getting a C. YSlow’s moaning at me for not optimizing CSS and JS files,  but there’s a reason for that…)

5. If you take a look at the 3rd Red Arrow on the Image, you’ll see it’s pointing to the Ruleset List. This is pretty awesome, because you can set the rules and benchmark for how your site should be measured. There is a YSlow Add-On called Web Metrics Framework, which is a ruleset that measures your Website according to Google’s Standards.

6. If you go into each of the sections that’s returned….e.g. Content…..you’ll get a second set of Tabs that Score you according to individual operations….See image below.

 

 

7. YSlow also comes with quite a bit of useful Hints, Tips and supporting documentation.

This add-on is easy to navigate, and very very useful. I hope it helps. Thanks Yahoo.

 

Cheers for now.

John