Posts Tagged ‘ssjs’

18 Aug 2016
0

XPages Tip: Populating Date/Time fields in Notes Docs with Date or Time Only

In your XPages app, you can use an EditBox control and set it’s display type to be a Date/Time control with certain formats. 2 examples are Date only or Time only. This all works great, except when you want to save these values to a Notes Document either via SSJS or Java. The saved values are definitely stored correctly in a Date/Time field, but always contain both a date and time value.

Example

Below is a snippet of an EditBox control set up as a Date Only component in an XPage or Custom control, bound to a Java bean of object type “Date”:

XPage Snippet for Date Only

Your Java logic to save this value to a NotesDocument will look something like this:

DateTime tempDate = null;
tempDate = session.createDateTime(bean.dateOnly);
doc.replaceItemValue("DateOnly", tempDate);

Sadly, in the NotesDocument Field Properties tab, the saved value contains both a date and time:

XPages Date Time Value

 

Solution

Thankfully, the solution is very simple. When you create your DateTime object in either Java or JavaScript, before adding it to the doc.replaceItemValue, do the following:

To remove the time from the Date/Time value:

tempDate = session.createDateTime(bean.dateOnly);
tempDate.setAnyTime();//This removes the time value
doc.replaceItemValue("DateOnly", tempDate);

To remove the date from the Date/Time value:

tempDate = session.createDateTime(bean.timeOnly);
tempDate.setAnyDate();//This removes the date value
doc.replaceItemValue("TimeOnly", tempDate);

The above java example is very similar to what you would do in SSJS as well.
As simple as that :)

10 Feb 2016
0

The XPages Knowledge Base gets 2 new articles on day 1

Thanks to Paul Withers and Fredrik Norling, the XPages Knowledge Base grew by 2 articles in day 1 of the official launch.

Article: Dialog Control, SSJS and Refreshing an Area of the Page

Link: Click here to view article
Author: Paul Withers
Knowledge Base Space: XPages Extension Library
 
Short Description
Get an understanding of what happens behind the scenes when performing an SSJS .show() or .hide() on a Dialog Control.
 

Article: Adding excel exporting to XPages using POI4XPages

Link: Click here to view article
Author: Fredrik Norling
Knowledge Base Space: POI4XPages
 
Short Description
This article will show you how to create and run a simple view to excel export using POI4XPages, which is an OSGI Plugin that adds Apache POI support to your XPage Project. This marks the first article for POI4XPages on the XPages Knowledge Base and officially takes it out of the “Coming Soon” status.

 

Closing

Just a final thanks to Paul and Fredrik for being the first 2 contributors to the Knowledge Base. I know both of you are already digging out more articles to contribute and I speak on behalf of the community when I say that we really appreciate it.

For those out there that also want to contribute, I recommend reading this post I submitted on what to expect and the necessary steps to take to become a contributor.

Cheers for now
John :)
7 Dec 2015
1

John Jardin’s 2nd Session at IBMConnect 2016: Optimus XPages

IBM-Connect-2016

So, to my utter surprise, my second Abstract for IBM Connect 2016 was approved. It’s titled “Optimus XPages: An Explosion of Techniques and Best Practices“. For a reference to my first Abstract, click here. Just so everyone knows, IBM Connect takes place at “The Hilton” in Orlando, Florida. My session “Optimus XPages” is scheduled for Monday the 1st February 2016 at 3:30pm.

I am extremely excited to be presenting this session. Over the past year I have implemented a number of solutions running on XPages, and I got to experience first hand the improvement in performance and overall user experience when comparing these solutions to ones I developed in the past. I feel I have come up with some serious practices that anyone can easily apply to make their applications work and feel fast and responsive, whether running on a local network or in the cloud.

Below is a rundown of my session:

TITLE:

AD-1074 – Optimus XPages: An Explosion of Techniques and Best Practices

SESSION SUMMARY:

Starting a new XPages project but not sure it’s going to be done right the first time? Do you have an existing application that doesn’t seem to have that “X” Factor? In this session John will demonstrate how XPages developers can apply proven techniques and best practices to take their applications to a game changing level.

WHAT WILL ATTENDEES LEARN:

  1. Rapidly develop responsive applications
  2. Improve user experience and response times with background and multi threaded operations
  3. Keep your XPages lightweight with code injection
  4. Create scheduled tasks the XPages way
  5. and much more.

I hope to see you all there :)

Cheers for now :)
John
19 May 2014
0

Quick Tip: Lessen your JavaScript code with 1 liner IF Statements

Not many people know this, but for simple JavaScript “If” Statements, there’s a Syntax that allows you to write out the entire condition on one line.

Let’s take a quick If Statement and type it out the most common way:

1
2
3
4
5
6
7
8
var whatAreMondays = "";
var areMondaysBlue = false;
 
if(areMondaysBlue){
   whatAreMondays = 'Blue';
}else{
   whatAreMondays = 'Awesome';
}

Behold…the 1 liner Syntax:

variable = (condition) ? 'value if TRUE' : 'value if FALSE';

By using a question mark and a colon, we can convert the above If Statement to the following:

1
2
3
4
var whatAreMondays = "";
var areMondaysBlue = false;
 
whatAreMondays = (areMondaysBlue) ? 'Blue' : 'Awesome';

Simple, but effective :)

8 Nov 2013
0

Live chat assist about searching for data in a NotesView via XPages

Summary

This live chat got me thinking that it’s not a good idea to assume that people asking for help are seasoned Domino Developers who have moved to XPages. You’ll see towards the middle of the chat how I finally realized this.

Click here to view the Blog Post I submitted related to this query.

Enjoy :)

Live Chat – 25th October 2013

John Jardin:
Good day. How can I help :)
 
Guest:
Hello. How do I compare stored values in JavaScript?
 
John Jardin:
When you say stored values, are you referring to a Notes Document or a Document Data Source?
 
Guest:
Data Source. I store values in a Database.
 
John Jardin:
So let’s say you have a Document Data Source called “doc1″, and you want to compare 2 string values in that Data Source. In Server Side JavaScript, it would be something like….
 
1
2
3
if(doc1.getItemValueString("Field1") === doc1.getItemValueString("Field2")){
   //Do Something
}
Guest:
Ok but how will that access data from a Database? How do I check it with a list of values?
 
John Jardin:
So, do you understand and have you worked with LotusScript in the past?
 
Guest:
no…
 
John Jardin:
OK. So I will do you a favor. I will publish a blog post with a detailed example of how to achieve this. But I want to just make double sure I’m understanding you correctly. You want to take a value in one of the fields in your XPage and compare it to a list of values stored in the Notes Database in a View?
 
Guest:
Yes exactly.
 
John Jardin:
OK great. Please allow me a few hours to publish this.
 
Guest:
Yea sure n thank you.