breadcrumbs in XPages (non extension library style)

I have still got a question open on the XPages development forum regarding how to use the breadcrumb control from the Extension Library. In case you happen to have an answer on the question, please post  it there (or here…).

Previously I have written more on providing breadcrumbs in Domino and XPages. I overlooked the unshift JavaScript method which allows you to add items in the beginning of an array.

In combination with the getParentID function for a NotesDocument you can simply create an reversed array of all parents and use the array as data a repeat control. Within the repeat control you place a link control and populate the label and document reference.

Here is the code sample:

<?xml version=”1.0″ encoding=”UTF-8″?>
<xp:view xmlns:xp=”http://www.ibm.com/xsp/core”&gt;
<xp:this.data>
<xp:dominoDocument var=”doc” formName=”Document”></xp:dominoDocument>
</xp:this.data>
<xp:div styleClass=”lotusBreadcrumbs” role=”navigation”>
<xp:link value=”/” text=”${database.title}” />
 &gt;&gt; 
<xp:repeat var=”breadcrumbs”>
<xp:this.value><![CDATA[#{javascript:var result = [];
var ref = doc.getParentId();
while(ref){
var parent = database.getDocumentByUNID(ref);
result.unshift({
unid: ref,
label: parent.getItemValueString(“Tx_Document_Title”)
})
ref = parent.getParentDocumentUNID();
}
return result;
}]]></xp:this.value>
<xp:link value=”/0/#{breadcrumbs.unid}” text=”#{breadcrumbs.label}” />
 &gt;&gt; 
</xp:repeat>
<xp:text value=”#{doc.Tx_Document_Title}” />
</xp:div>
</xp:view>

Here is how a result could look like:

breadcrumbs

 

Not really exciting but hopefully helpful for you.

Job Wanted

Looking for a creative brain? Choose me!

job-wanted

Comments (1)

Navbar with dropdown menu from Notes view in Twitter Bootstrap (with XPages)

Introduction

Hey hey, sorry to bother you again with a post about using a Notes view in combination with Twitter Bootstrap.

In my previous post I was not sure about using nav-pills. I fear not all users will understand them. I assume that most users are common with a site header with navigational options. This navigation can be like tab bars (hihi watch some real old work) some with nested tabs in fancy drop down menus. Twitter Bootstrap have probably taken notice of this expected behavior and provided therefor the navbar component.

Implementation

I used the same conditions as in my previous post (Mark Leusink’s Bootstrap4XPages demo site and my Notes view:

notesview clean

 

Here is how the code on my XPage looks like:

<div class=”navbar navbar-inverse navbar-fixed-top”>
<div class=”navbar-inner”>
<div class=”container-fluid”>
<a data-target=”.nav-collapse” data-toggle=”collapse”
class=”btn btn-navbar”>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
</a>
<a href=”#” class=”brand”>
<xp:text escape=”true” id=”computedField1″ value=”#{javascript:@DbTitle()}”></xp:text></a>
<div class=”nav-collapse”>
<ul class=”nav”>
<li class=”dropdown”>
<a data-toggle=”dropdown” class=”dropdown-toggle” href=”#”>Site Index<b class=”caret”></b></a>
<xp:text escape=”false” disableTheme=”true” value=”#{javascript:getList()}” rendered=”true”></xp:text>
</li>
<li class=”active”>
<xp:link escape=”true” text=”Home” id=”link1″ value=”/index.xsp”></xp:link>
</li>
<li>
<a href=”#”>Static Link 1</a>
</li>
<li class=”divider-vertical”></li>
<li>
<a href=”#”>Static Link 2</a>
</li>
</ul>
<form action=”" class=”navbar-search pull-left”><input type=”text” placeholder=”Search” class=”search-query span2″ /></form>
<ul class=”nav pull-right”>
<li>
<a href=”#”>Static Link 3</a>
</li>
<li class=”divider-vertical”></li>
<li>
<a href=”#”>Static Link 4</a>
</li>
</ul>
</div><!– /.nav-collapse –>
</div>
</div>
</div>

Note: I had to set attributes for escape and disableTheme for the computed field otherwise the navbar would get messed up.

In the computed field I call a SSJS function that is similar to the one in the previous post:

function getList(){
var nav:NotesViewNavigator = database.getView(“$v-treeview-clean”).createViewNav();
var entry:NotesViewEntry = nav.getFirst();
if (entry !=null){
var countLevel:Integer = 0;
var curLevel:Integer;
var list = “<ul class=\”dropdown-menu\”>”;
while (entry !=null){
var edoc:NotesDocument = entry.getDocument();
entryValue = entry.getColumnValues().elementAt(1).toString();
var col:NotesDocumentCollection = edoc.getResponses();
curLevel = entry.getColumnIndentLevel();
if (col.getCount()>0){
//prep for new entry with response(s)
var difLevel = countLevel – curLevel ;
var closure = “”
for (var i=0; i<(difLevel); i++){
closure = closure + “</ul></li>”
}
list = list + closure;
list = list + “<li class=\”dropdown-submenu\”>”;
list = list + “<a href=\”#\”>” + entryValue + “</a>”;
list = list + “<ul class=\”dropdown-menu\”>”;
//increase counter
countLevel = curLevel + 1;
}
else{
if(curLevel==countLevel){
list = list + “<li><a href=\”#\”>” + entryValue + “</a></li>”;
}
else if(curLevel<countLevel){
var difLevel = countLevel – curLevel ;
var closure = “”
for (var i=0; i<(difLevel); i++){
closure = closure + “</ul></li>”
}
list = list + closure
countLevel = curLevel;
}
else {
//
}
}
var tmpentry:NotesViewEntry = nav.getNext(entry);
entry.recycle();
entry = tmpentry;
}
//final closure, last entry could be response doc
var closure = “”
for (var i=0; i<(countLevel); i++){
closure = closure + “</ul></li>”
}
list = list + closure
//closure nav nav-list
list = list + “</ul>”;
return list;
}
else{
return “no documents found”;
}
}

C’est tout!

Result

Here is how the result looks like for desktop:

navbar

 

Reflections

Not bad for something “out of the box”!

I placed the “Site Index” at the beginning because it appears that the expanding of the nested lists continues to the right, even when it has reached the end of your screen :-? There is the option to set the class for nested list to dropdown-submenu pull-left but I think it will be odd if you collapse one level open to the right and the next to the left.

Mobile users

Mobile users will find it difficult accessing the nested lists as the following image demonstrates:

mobilenavbar

 

Only the first 7 entries seem to become displayed, so when you open nested lists the items below just get pushed away. Luckily they return when you close the nested lists.

Alternative

The options for providing deep-level navigation seem to be a bit limited in Twitter Bootstrap. an alternative might be a collapsible tree menu for TB which you can find an example described here.

Job Wanted

Looking for a creative brain? Choose me!

job-wanted

Leave a Comment

Dropdown menu from Notes view in Twitter Bootstrap (with XPages)

Introduction

OK, so I was a bit unsatisfied with the navigation list in my previous post. The nav-list component seems not to be destined to contain too many category sub levels.

Dropdowns

Toggleable, contextual menu for displaying lists of links.

Pills

I am not sure how you would describe pills in Twitter Bootstrap but to me they look more like buttons you build a navigation with.

tb pills

Implementation

Again I used Mark Leusink’s Bootstrap4XPages demo site. As source for my documents I am re-using the same view from my previous post:

notesview clean

I found an example code for nesting lists on Fiddle and modified it a bit to my needs.

I display the results via a computed field that looks as followed:

<xp:text escape=”false” id=”computedField1″ value=”#{javascript:getList()}” ></xp:text>

The function getList() is very similar to the one in my previosu post and looks as followed:

function getList() {
var nav: NotesViewNavigator = database.getView(“$v-treeview-clean”).createViewNav();
var entry: NotesViewEntry = nav.getFirst();
if (entry != null) {
var countLevel: Integer = 0;
var curLevel: Integer;
var list = “<div class=\”dropdown\”>”;
list = list + “<ul class=\”nav nav-pills\”>”;
list = list + “<li class=\”dropdown active\” id=\”accountmenu\”>”;
list = list + “<a class=\”dropdown-toggle\” data-toggle=\”dropdown\” href=\”#\”>Home</a>”;
list = list + “<ul class=\”dropdown-menu\”>”
while (entry != null) {
var edoc: NotesDocument = entry.getDocument();
entryValue = entry.getColumnValues().elementAt(1).toString();
var col: NotesDocumentCollection = edoc.getResponses();
curLevel = entry.getColumnIndentLevel();
if (col.getCount() > 0) {
//prep for new entry with response(s)
var difLevel = countLevel – curLevel;
var closure = “”
for (var i = 0; i < (difLevel); i++) {
closure = closure + “</ul></li>”
}
list = list + closure;
list = list + “<li class=\”dropdown-submenu\”>”;
list = list + “<a href=\”#\” tabindex=\”-1\”>” + entryValue + “</a>”;
list = list + “<ul id=\”" + entryValue + “\” class=\”dropdown-menu\”>”;
//increase counter
countLevel = curLevel + 1;
} else {
if (curLevel == countLevel) {
list = list + “<li><a href=\”#\”>” + entryValue + “</a></li>”;
} else if (curLevel < countLevel) {
var difLevel = countLevel – curLevel;
var closure = “”
for (var i = 0; i < (difLevel); i++) {
closure = closure + “</ul></li>”
}
list = list + closure
countLevel = curLevel;
} else {
//
}
}
var tmpentry: NotesViewEntry = nav.getNext(entry);
entry.recycle();
entry = tmpentry;
}
//final closure, last entry could be response doc
var closure = “”
for (var i = 1; i < (countLevel); i++) {
closure = closure + “</ul></li>”
}
list = list + closure
//closure nav nav-list
list = list + “</ul></li></ul></div>”;
//closure well sidebar-nav

return list;
} else {
return “no documents found”;
}
}

Here is what the result looks like:

dropdowndemo

Alternative

The example above looks nice but I am not sure what the purpose of nav-pills are? (don’t ask a Dutch the pills Q)  I guess users would expect site navigation to be in a navigational bar, so expect another post on the nav-bar component.

Job Wanted

Looking for a creative brain? Choose me!

job-wanted

Comments (1)

Navigation list from Notes view in Twitter Bootstrap (with XPages)

Introduction

In my previous post I demonstrated how you create breadcrumbs from Notes view in Twitter Bootstrap. A typical Notes application contains an outline (I assume you don’t the Navigator design element anymore). In this post I demonstrate how to create something similar in Twitter Bootstrap, a Nav List.

navlist example

Nav Lists

A Nav list is a simple and easy way to build groups of nav links with optional headers. They’re best used in sidebars like the Finder in OS X. You can nest nav-lists and then they come quit close to categorized or hierarchical structured documents (e.g. parent & response).

Implementation

As  a start database I used Mark Leusink’s Bootstrap4Xpages demo site which you can download here.

As source I am also using a similar view as I used in my previous post. Here is how it looks like:

notesview clean

I found an example code for nesting lists on Fiddle. Note that you can extend nav-list with mouse over behavior but I fear for mobile phones and tablets this will be a crime.

I display the results via a computed field that looks as followed:

<xp:text escape=”false” id=”computedField2″ value=”#{javascript:getNavList()}”></xp:text>

The function getNavList() looks as followed:

function getNavList(){
var nav:NotesViewNavigator = database.getView(“$v-treeview-clean”).createViewNav();
var entry:NotesViewEntry = nav.getFirst();
if (entry !=null){
var countLevel:Integer = 0;
var curLevel:Integer;
var list = “<div class=\”well sidebar-nav\”><ul class=\”nav nav-list\”>”;
while (entry !=null){
var edoc:NotesDocument = entry.getDocument();
entryValue = entry.getColumnValues().elementAt(1).toString();
var col:NotesDocumentCollection = edoc.getResponses();
curLevel = entry.getColumnIndentLevel();
if (col.getCount()>0){
//prep for new entry with response(s)
var difLevel = countLevel – curLevel ;
var closure = “”
for (var i=0; i<(difLevel); i++){
closure = closure + “</ul></li>”
}
list = list + closure;
list = list + “<li>”;
list = list + “<a href=\”#\” data-toggle=\”collapse\” data-target=\”#” + entryValue + “\”>” + entryValue + “</a>”;
list = list + “<ul id=\”" + entryValue + “\” class=\”collapse in\”>”;
//increase counter
countLevel = curLevel + 1;
}
else{
if(curLevel==countLevel){
list = list + “<li><a href=\”#\”>” + entryValue + “</a></li>”;
}
else if(curLevel<countLevel){
var difLevel = countLevel – curLevel ;
var closure = “”
for (var i=0; i<(difLevel); i++){
closure = closure + “</ul></li>”
}
list = list + closure
countLevel = curLevel;
}
else {
//
}
}
var tmpentry:NotesViewEntry = nav.getNext(entry);
entry.recycle();
entry = tmpentry;
}
//final closure, last entry could be response doc
var closure = “”
for (var i=1; i<(countLevel); i++){
closure = closure + “</ul></li>”
}
list = list + closure
//closure nav nav-list
list = list + “</ul>”;
//closure well sidebar-nav
list = list + “</div>”;
return list;
}
else{
return “no documents found”;
}
}

In order to make it look nice embed the computed field in div element and give it a span class.

Below you see the final result:

result nav list

 

 

You notice directly an obvious problem: the long title references which are typical for Notes documents.

Alternative

Twitter Bootstrap offer other alternatives which might be more suitable for transforming Notes views. And example is the dropdown. This you can extend with the dropdown JavaScript plugin.

Point for improvement

A class I did not use for the LI element is nav-header. This gives a nice outstanding header, which are great for categorized views.

A class I did not use for the LI element is active which highlights a list item. When using the nav-list on documents opened via an XPage I guess it is best practice to add the class name when the document is ready on the client.

The HREF attribute is not computed but this can be extracted from the viewentry.

Performance. The view above contains very little documents. I still have to test it with larger databases. Some examples where I want to use the nav-list contain more than 15000 documents in the view. I wonder how much I can use sessionScope or place the HTML in a profile document. Any suggestions here are welcome.

Tools used

Beside DDE is used heavily NotePad++ to check the generated HTML.

Job Wanted

Looking for a creative brain? Choose me!

job-wanted

Comments (5)

Breadcrumbs from Notes view in Twitter Bootstrap (with XPages)

Long long long time ago I wrote how to create breadcrumbs in Notes and on the Web with help of JQuery. In case you are interested using Twitter Bootstrap with XPages chances are you want to provide similar navigational options for your beloved users.

The code below demonstrates how to achieve this.

<xp:this.data>
<xp:dominoDocument var=”currentDocument” formName=”Document”></xp:dominoDocument>
</xp:this.data>

<xp:text escape=”false” id=”computedField1″
value=”#{javascript:getBreadCrumb()}”>
</xp:text>

and the SSJS function looks like:

function getBreadCrumb(){
var nav:NotesViewNavigator = database.getView(“$v-treeview”).createViewNav();
var doc:NotesDocument = currentDocument.getDocument();
if (nav.gotoEntry(doc)) {
var entry:NotesViewEntry = nav.getCurrent();
var list = “”;
list = “<li>” + entry.getColumnValues().elementAt(1).toString() + “</li>” + list;
while (nav.gotoParent(entry)){
entry = nav.getCurrent();
list = “<li>” + entry.getColumnValues().elementAt(1).toString() + “<span class=\”divider\”>/</span></li>” + list;
}
return “<ul class=\”breadcrumb\”>” + list + “</ul>”;
}
return “no docs found”
}

The Notes view $v-treeview has already href references in the column where I collect the information from:

notes view

Don’t forget to set the Display options for Web for the form. I select the form that contains the computed text that calls the getBreadCrumb() function.

Here is how the view looks like in the browser:

Notes view for web

And here the result when I open a document:

breadcrumb tb

Please leave a note when you have suggestions for improvement OR if you have code to put view info into a nav list to create a collapsible menu.

Job Wanted

Looking for a creative brain? Choose me!

job-wanted

Comments (2)

Comparison between Extension Library (OpenNTF) and Upgrade Pack 1 (IBM) – You’re help is appreciated

Some days ago I posted a question on the XPages development forum: Comparison of functionality between Extension Library (OpenNTF) and Upgrade Pack 1 (IBM).

I work in a hosted environment and having a change applied (continue to work with extension libraries from OpenNTF via Update site instead of Upgrade Packs) is a complicated issue. Therefor I have wrote down some use cases where new functionality in the Extension Library which are not available in the Upgrade Pack can bring value to the organisation.

To save time I only did the comparison on paper, which means I have only looked in the “readme” files distributed which each new release and compared them the “What’s new in Domino Designer 8.5.3 Upgrade Pack 1” online document. I admit this is probably not the best research but it helps you to get started.

Below you will find the comparison. Please respond in case I have missed something or understood incorrect. The use cases are too sensitive so I will leave them out of this document. Thank you in advance for your assistance!

Package name

Extension Library

Upgrade Pack 1

 

Release date

2013 April

2011 December

 

Distributed by

OpenNTF

IBM

 

Controls

 

 

 

Area: Data Access

 

 

Expose data access services.

-
Document

þ

þ

 

-
View

þ

þ

 

-
Relational
Database Support

 

þ

 

Area: Dojo Form

 

 

Mimic components from the Dojo toolkit.

-
Dojo
Button

þ

þ

 

-
Dojo
Check Box

þ

þ

 

-
Dojo
Combo Box

þ

þ

 

-
Dojo
Currency Text Box

þ

þ

 

-
Dojo
Date Text Box

þ

þ

 

-
Dojo
Filtering Select

þ

þ

 

-
Dojo
Horizontal Slider

þ

þ

 

-
Dojo
Slider Rule

þ

þ

 

-
Dojo
Slider Rule Labels

þ

þ

 

-
Image
Select

þ

þ

 

-
Select
Link Select

þ

þ

 

-
Select
List Text Box

þ

þ

 

-
ListTextBox
Name Text Box

þ

þ

 

-
Dojo
Number Text Box

þ

þ

 

-
Dojo
Radio Button

þ

þ

 

-
Dojo
Simple Text Area

þ

þ

 

-
Dojo
Number Spinner

þ

þ

 

-
Dojo
Text Area

þ

þ

 

-
Dojo
Text Box

þ

þ

 

-
Dojo
Time Text Box

þ

þ

 

Area: Dojo Layout

 

 

Mimic components from the Dojo toolkit.

-
Accordion
Container

þ

þ

 

-
Accordion
Pane

þ

þ

 

-
Border
Container

þ

þ

 

-
Border
Pane

þ

þ

 

-
Dojo
Content Pane

þ

þ

 

-
Dojo
Data Grid

þ

þ

 

-
Dojo
Data Grid Column

þ

þ

 

-
Dojo
Data Grid Row

þ

þ

 

-
Stack
Container

þ

þ

 

-
Stack
Pane

þ

þ

 

-
Tab
Container

þ

þ

 

-
Tab
Pane

þ

þ

 

Area: Extension Library

 

 

Extend the capabilities of the Designer Core Controls.

-
Accordion

þ

þ

 

-
Application
Layout

þ

þ

 

-
Bread
Crumbs

þ

þ

 

-
Widget
Container

þ

þ

 

-
Data
View

þ

þ

 

-
Dialog

þ

þ

 

-
Dialog
Button Bar

þ

þ

 

-
DropDown Button

þ

þ

 

-
Dump
Object

þ

þ

 

-
Dynamic
View Panel

þ

þ

 

-
Dynamic
Content

þ

þ

 

-
Firebug
Lite

þ

þ

 

-
Form
Layout Column

þ

þ

 

-
Form
Layout Row

þ

þ

 

-
Forum
Post

þ

þ

 

-
Forum
View

þ

þ

 

-
Form
Table

þ

þ

 

-
Outline

þ

þ

 

-
Inline
List Container

þ

þ

 

-
In
Place Form

þ

þ

 

-
Keep
Session Alive

þ

þ

 

-
List
Container

þ

þ

 

-
List
of Links

þ

þ

 

-
List
Separator

þ

þ

 

-
Multi-image
Output

þ

þ

 

-
Name
Picker

þ

þ

 

-
Navigator

þ

þ

 

-
Pager
Add Rows

þ

þ

 

-
Pager
Expand/Collapse

þ

þ

 

-
Pager
Save State

þ

þ

 

-
Pager
Show/Hide Details

þ

þ

 

-
Pager
Sizes

þ

þ

 

-
PopupMenu

þ

þ

 

-
Redirect
control

 

þ

 

-
Sort
Links

þ

þ

 

-
Switch

þ

þ

 

-
Tag
Cloud

þ

þ

 

-
Toolbar

þ

þ

 

-
Tooltip

þ

þ

 

-
Tooltip
Dialog

þ

þ

 

-
Value
Picker

þ

þ

 

Area: iNotes

 

 

Support certain views, lists, and stores.

-
iCal
Store

þ

þ

 

-
iNotes
Calendar

þ

þ

 

-
iNotes ListView

þ

þ

 

-
ListView Column

þ

þ

 

-
Notes
Calendar Store

þ

þ

 

-
Notes
List View Design

þ

þ

 

-
Notes
List View Store

þ

þ

 

Area: Mobile

 

 

Support mobile applications.

-
Mobile
Page

þ

þ

 

-
Mobile
Switch

þ

þ

 

-
Page
Heading

þ

þ

 

-
Rounded
List

þ

þ

 

-
Single
Page Application

þ

þ

 

-
Static
line item

þ

þ

 

-
Tab
Bar

þ

þ

 

-
Tab
Bar Button

þ

þ

 

Domino Access Services

 

 

REST API that accesses databases on Domino servers.

-
Remote
Services

þ

þ

 

-
REST
Service

þ

þ

 

-
Domino
Mail service

 

þ

 

Updated templates

 

 

Skeleton that contains design elements, but no documents. You
use a template to create an application.

-
TeamRoom

þ

þ

 

-
Discussion

þ

þ

 

-
Document
Library

 

þ

 

Social Business Toolkit

 

 

Single source for developing integrations and leveraging IBM
Connections and IBM SmartCloud for Social Business.

-
Activity
Stream

 

þ

 

Social Enabler

 

 

Tools and controls for XPages to access information from other
social applications such as Facebook, Twitter, Dropbox, LotusLive, or IBM
Connections.

-
File
service

 

þ

 

-
Twitter

 

þ

 

-
Connections

 

þ

 

-
Sametime controls

 

þ

 

-
Facebook
controls

 

þ

 

-
Web
Security Store

 

þ

Storage of user credentials

when an application needs to connect to third party

servers.

Comments (3)

Is there any way to access user activity properties programmatically?

I was asked to create some reports on the activities on a set of applications. I wonder if you can access the user activity properties on a database programmatic-ally?

activity

Comments (9)

Older Posts »
Follow

Get every new post delivered to your Inbox.

Join 143 other followers