Friday, 30 September 2016

Using Chosen a jQuery Plugin for more User-Friendly Select Boxes in XPages

As everyone knows I'm still a "cheer leader" when it comes to IBM Notes Domino. Although I sometimes have my doubts about the future of XPages given the current IBM Roadmaps hereby nevertheless a blog post on XPages.
Chosen is a jQuery plugin that makes long, unwieldy select boxes much more user-friendly. Chosen is an excellent alternative to Select2. Chosen has some great options as Hide Search on Single Select, Default Text Support, Limit Select Options in Multi-Select and Allow Deselect on Single Selects. It is also very simple to integrate into any XPages Application.
In order to use Chosen the JavaScript and CSS file(s) need to be included on the XPage / Custom Control. The latest version can be downloaded from GitHub: Chosen 1.6.2.

Adding the JS and CSS files
The JavaScript and CSS files must be added to the WebContent Folder in the Package Explorer.
In the example below a Folder Chosen has been added in the WebContent Folder.


Next the JavaScript and CSS files, chosen.jquery.js and chosen.css, must be included on the XPage or Custom Control. In this example I add the files to an XPage.

<script type="text/javascript" src="chosen/chosen.jquery.js"></script>
<link rel="stylesheet" href="chosen/chosen.css" />

Note: Not shown in the picture above is the required file chosen-sprite.png. This file should also be added to the WebContent Folder in the Package Explorer.

Adding the x$ jQuery selector for XPages
Furthermore I use the the great XSnippet by Mark Roden, x$ jQuery selector for XPages, to initialize the plugin and include it on the XPage. The XSnippet can be added to the Script Libraries. In this example the name of the Script Library is JQueryXSnippet.js.

<xp:this.resources>
<xp:script src="/JQueryXSnippet.js" clientSide="true"></xp:script>
</xp:this.resources>

The script itself can be made up as follows. The name of the id in the script must correspond with the id of the Combo Box / List Box. In the example below I used some extra options.

<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[
$(document).ready(
function() {
x$( "#{id:listBox1}" ).chosen({
disable_search_threshold: 10,
allow_single_deselect: true ,
max_selected_options: 2,
width:"100% !important;"
});
}
);
]]></xp:this.value>
</xp:scriptBlock>

Remark: When a placeholder is used for a non-multi-value select box such as a Combo Box, an empty tag is required as a first option. One possibility is to generate computed items, including an empty tag, as values for the Combo Box.

var arr = new Array("");
var res = @DbLookup("", "byKeyWord", "Category", 2);
var list = arr.concat(res);
return list;

Responsive design - Percent width
Chosen's width can be set to a percentage of its parent to support responsive design.
The best way to ensure that Chosen is using a percent based width is to add the width declaration into the scriptBlock of the listBox and comboBox, width:"100% !important;".

Basic Setup Combo Box in XPages
For using a place holder it is necessary to add the Attribute data-placeholder in the Properties of the Combo Box.
<div class="col-md-7">
<xp:comboBox id="comboBox1" >
<xp:this.attrs>
<xp:attr name="data-placeholder" value="Select a category...."></xp:attr>
</xp:this.attrs>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var arr = new Array("");
var res = @DbLookup("", "byKeyWord", "Category", 2);
var list = arr.concat(res);
return list;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>


Basic Setup List Box (multi value)
Chosen also supports multi-value select boxes.

<xp:listBox id="listBox1" multiple="true">
<xp:this.attrs>
<xp:attr name="data-placeholder" value="Select a category..."></xp:attr>
</xp:this.attrs>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript: @DbLookup("", "byKeyWord", "Software", 2);}]]></xp:this.value>
</xp:selectItems>
</xp:listBox>
</div>


Code XPage
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.resources>
<xp:script src="/JQueryXSnippet.js" clientSide="true"></xp:script>
</xp:this.resources>
<script type="text/javascript" src="chosen/chosen.jquery.js"></script>
<link rel="stylesheet" href="chosen/chosen.css" />
<xp:scriptBlock id="scriptBlock2">
<xp:this.value><![CDATA[
$(document).ready(
function() {
x$( "#{id:comboBox1}" ).chosen({
disable_search_threshold: 10,
allow_single_deselect: true,
width: "100% !important;"
});
}
);
]]></xp:this.value>
</xp:scriptBlock>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[
$(document).ready(
function() {
x$( "#{id:listBox1}" ).chosen({
allow_single_deselect: true ,
max_selected_options: 2,
width:"100% !important;"
});
}
);
]]></xp:this.value>
</xp:scriptBlock>
<xc:ccLayout>
<xp:this.facets>
<xp:panel xp:key="facetMiddle">
<div class="col-md-7">
<h3>Chosen</h3>
</div>
<div class="col-md-7">
<xp:comboBox id="comboBox1">
<xp:this.attrs>
<xp:attr name="data-placeholder" value="Select a category....">
</xp:attr>
<xp:attr name="no_results_text" value="No results found!">
</xp:attr>
</xp:this.attrs>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var arr = new Array("");
var res = @DbLookup("", "byKeyWord", "Category", 2);
var list = arr.concat(res);
return list;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:listBox id="listBox1" multiple="true">
<xp:this.attrs>
<xp:attr name="data-placeholder" value="Select a category...">
</xp:attr>
</xp:this.attrs>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript: @DbLookup("", "byKeyWord", "Software", 2);}]]></xp:this.value>
</xp:selectItems>
</xp:listBox>
</div>
</xp:panel>
</xp:this.facets>
</xc:ccLayout>
</xp:view>

For more information about Chosen : Documentation Chosen

Quick IBM Notes Tip: Administrative LotusScript Agent to Update Field Values on Selected Documents in View


Lately I focus particularly on LotusScript, Java and NodeJS and no longer on XPages. XPages has as it looks in all the recent IBM Roadmaps not a real future anymore. More on this subject in my next blog post.
In my daily work I frequently encounter request to customize field values in selected documents. One of the most frequently used administrative LotusScript Agents I use fot this purpose is an Agent from Breaking Par Consulting, Inc. to update Field Values in selected documents in a Notes View.
At the moment the agent is executed the person running the Agent will be prompted for the Field Name, the (New) Field Value and a Field Type. All the selected documents in the Notes View will be updated. As shown in the third image it is also possible to delete a Field with this Agent. The Agent Properties I use for this Agent are Trigger - Action Menu Selection and Target - All Selected Documents.


Sub Initialize
   Dim ws As New NotesUIWorkspace
   Dim session As New NotesSession
   Dim prompt As String
   Dim fieldName As String
   Dim fieldValue As String
   Dim dataTypes As Variant
   Dim thisDataType As String
   Dim fieldValues As Variant
   Dim newFieldValues As Variant
   Dim db As NotesDatabase
   Dim coll As NotesDocumentCollection
   Dim i As Integer
   Dim doc As NotesDocument
   Dim item As NotesItem

prompt = "Please enter the name of the field to be updated"
   fieldName = ws.Prompt(3, "Enter Field Name", prompt, "")
   If fieldName = "" Then Exit Sub
   If Instr(fieldName, " ") <> 0 Then
      prompt = "Error! Field Names can't have spaces!"
      Msgbox prompt, 16, "Error"
      Exit Sub
   End If

prompt = "Please enter the new value. For multiple values, separate with a colon."
   fieldValue = ws.Prompt(3, "Enter Field Value", prompt, "")

Redim dataTypes(5) As String
   dataTypes(0) = "Text"
   dataTypes(1) = "Number"
   dataTypes(2) = "Date"
   dataTypes(3) = "Readers"
   dataTypes(4) = "Authors"
   dataTypes(5) = "DELETE THIS FIELD"
   prompt = "Choose the data type of the value(s)"
   thisDataType = ws.Prompt(4, "Choose Data Type", prompt, dataTypes(0), dataTypes)
   If thisDataType = "" Then Exit Sub

Set db = session.CurrentDatabase
   Set coll = db.UnprocessedDocuments
   fieldValues = Evaluate({@Explode("} & fieldValue & {"; ":")})
   Select Case thisDataType
   Case dataTypes(0) : Redim newFieldValues(Ubound(fieldValues)) As String
   Case dataTypes(1) : Redim newFieldValues(Ubound(fieldValues)) As Double
   Case dataTypes(2) : Redim newFieldValues(Ubound(fieldValues)) As Variant
   Case dataTypes(3) : Redim newFieldValues(Ubound(fieldValues)) As String
   Case dataTypes(4) : Redim newFieldValues(Ubound(fieldValues)) As String
   End Select
For i = Lbound(fieldValues) To Ubound(fieldValues)
      Select Case thisDataType
      Case dataTypes(0) : newFieldValues(i) = Trim(fieldValues(i))
      Case dataTypes(1) : newFieldValues(i) = Val(fieldValues(i))
      Case dataTypes(2) : newFieldValues(i) = Cdat(fieldValues(i))
      Case dataTypes(3) : newFieldValues(i) = Trim(fieldValues(i))
      Case dataTypes(4) : newFieldValues(i) = Trim(fieldValues(i))
      End Select
   Next
Set doc = coll.GetFirstDocument
   While Not doc Is Nothing
      If thisDataType = "DELETE THIS FIELD" Then
         If doc.HasItem(fieldName) Then Call doc.RemoveItem(fieldName)
      Else
         Call doc.ReplaceItemValue(fieldName, newFieldValues)
         If thisDataType = dataTypes(3) Or thisDataType = dataTypes(4) Then
            Set item = doc.GetFirstItem(fieldName)
            If thisDataType = dataTypes(3) Then item.IsReaders = True
            If thisDataType = dataTypes(4) Then item.IsAuthors = True
         End If
      End If
      Call doc.Save(True, False)
      Set doc = coll.GetNextDocument(doc)
   Wend
End Sub

As in almost all situations, there are of course other possibilities to update Field Values in all (selected) documents in a Notes View. Below a basic eample I use for updating Field Values in all documents in a specific Notes View.

Sub Initialize  

Dim s As New NotesSession 
Dim db As NotesDatabase 
Dim doc As NotesDocument 
Dim view As NotesView 

Set db = s.CurrentDatabase 
Set view=db.GetView("VIEWNAME")
Set doc = view.GetFirstDocument 
view.AutoUpdate = False

While Not (doc Is Nothing)  
If doc.FIELDNAME(0) = "CURRENTVALUE" Then 
doc.FIELDNAME = "NEWVALUE" 
End If 
Call doc.Save(True, False) 
Set doc=view.GetNextDocument(doc)  
Wend 
End Sub

Monday, 26 September 2016

OpenNTF Contributor Director

Today I received and email from OpenNTF concerning the election for Contributor Directors OpenNTF. As you may now I made me eligible this year for election for OpenNTF Contributor Director. Good news today, I have been elected for the position of Contributor Director OpenNTF for the next year.
I would like to thank all the Contributors who have voted for me. Thank you!!
Also my congratulations to Padraic Edwards and Fredrik Norling!
Along with Padraic Edwards and Fredrik Norling I will do my utmost to contribute as much as possible to OpenNTF, the mission of OpenNTF and to the Community in genreal.
Let's make it a great year!


Friday, 23 September 2016

Installing IBM Client Application Access (ICAA) - Presentation and Video

IBM Client Application Access (formerly known as IBM Notes Browser Plug-in) offers a lightweight solution for accessing your IBM Notes and IBM Domino applications. It also integrates seamlessly with IBM Verse and IBM SmartCloud Notes web for mail. This session will provide an overview of ICAA along with details for installation and configuration.

The video below will guide you through the installation of ICAA on the Windows, Citrix and Mac operating systems, including the directories created as well as additional steps that you may need to complete the installation.



More information on the Open Mic Webcast, including the presentation, full audio and video, can be found at the Webcast document for the event: IBM Client Application Access (ICAA) - 14 September 2016 [presentation, video + audio attached].
See also my previous blog post IBM Client Application Access 1.0.1 (ICAA) Enhancements for more information about the ICAA Client.

Thursday, 22 September 2016

Interim Fix and Workarounds iNotes - Users receive 'Formula Error' when accessing Domino 9.0.1 Fix Pack 7 Server

When an iNotes user opens their mail file on a Domino 9.0.1 Fix Pack 7 server, a "Formula Error" appears. This issue is known to occur on servers with non-English OS Regional Settings.

Diagnosing the problem
1. Upgrade server to 9.0.1FP7
2. iNotes user logs in (using any browser)
3. User is authenticated, opens mail file, and then the "Formula Error" appears.

An Interim Fix for this issue is in progress and will be released shortly (by end of September at the latest). This issue is tracked as SPR MBLTADSK8M.

Workarounds
Option 1
Revert to a prior version Forms9.nsf and Forms9s.nsf (e.g., from 901FP6).

Option 2
Change the decimal separator from a comma to a period in Control Panel -> Clock Region and Language -> Formats -> Additional settings -> Numbers.


Option 3
  1. Change the server's OS Regional Settings to English
  2. Stop Domino 
  3. Set Regional Settings to English as default 
  4. On the Advanced tab, set Regional Settings to English 
  5. Click the setting for "Apply all settings to the current user account and to the default user profile." 
  6. Restart the system 
  7. Start Domino
More info: IBM Technote (troubleshooting)

Wednesday, 21 September 2016

Securing Connections for IBM Traveler Mobile Applications - IBM Verse - IBM Notes Traveler

Yesterday I retweeted the message below, Securing connections for IBM Traveler mobile applications. Below is a summary of the IBM Flash Alert.


In the coming months, IBM will be enhancing the IBM Verse for iOS, IBM Verse for Android, IBM Notes Traveler Companion and IBM Notes Traveler To Do mobile apps to require that a secure connection is used between the mobile app and the endpoint used for connecting to the IBM Traveler server. This article provides the security requirements and step by step instructions for ensuring that your on-premises IBM Traveler environment has adequate connection security in place in order to support these updated apps. If your mobile users connect to IBM SmartCloud Notes for Traveler and the Verse Mobile service, these steps do not apply, since this environment is already prepared for these updates. If you have deployed an IBM Traveler server on your own premises, then please continue reading.
IMPORTANT: You must ensure that your IBM Verse Mobile and Traveler connections are secure and compliant with these requirements by January 1, 2017.

These requirements only apply to the server to which the Verse mobile apps are directly connecting. This may be the IBM Traveler server running on a Domino instance, or some other intermediate reverse proxy, such as an F5 or IBM Mobile Connect. When you enter the host name into your Verse mobile application to connect to your Traveler service, this host name represents the server with which the mobile app is directly connecting, and this is the connection that must be secured.

Requirements
Mobile apps must connect using HTTPS and not the unsecured HTTP protocol.
The server certificate cannot be expired or invalid.
The server certificate common name (CN) or a name from the server certificate’s Subject Alternate Name (SAN) list must match the hostname of the server. A wildcard certificate is allowed but the domain from the wildcard must match the server’s domain.
The negotiated Transport Layer Security version must be TLS 1.2. Since devices running Android prior to version 4.1 do not support TLS 1.2, they can no longer be supported.
The server certificate must be trusted and either issued by a certificate authority (CA) whose root certificate is incorporated into the device operating system or is a trusted root CA that has been installed by the user or a system administrator on the device.
The negotiated TLS connections cipher suite must support forward secrecy and be one of the following:

TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA

The leaf server certificate must be signed with one of the following types of keys:
- Rivest-Shamir-Adleman (RSA) key with a length of at least 2048 bits
- Elliptic-Curve Cryptography (ECC/ECDSA) key with a size of at least 256 bits
The leaf certificate hashing algorithm must be Secure Hash Algorithm 2 (SHA-2) with a digest length of at least 256 (SHA-256 or greater).

Failure to meet all of these requirements may result in your Verse for iOS, Verse for Android, IBM Notes Traveler Companion and IBM Notes Traveler To Do apps being unable to connect to your Traveler servers.

For detailed information: Securing Connections for IBM Traveler Mobile Applications

Monday, 19 September 2016