How to set 'date only' or 'time only' values in fields through XPages

XPages always save date and time in a field

When a form has the fields with "date only" or "time only", then the stored data format are different between Notes Client and XPages.

For example, I prepared the field with "date only" named "Date" as following (sorry, screenshots are all Japanese) :

年月日のみをもつフィールド

And also field with "time only" named "Time":

時刻の表示のみをもつフィールド

Now I saved a new document with this form from Notes Client (9.0.1 FP3), then I got following fields' data.

Notesクライアントで日付フィールドを保存

Notesクライアントで日付フィールドを保存

As you see, "Date" field has "2015/03/02", and Time field has"14:35:00"

As the next, I created the simple XPage to save a new document with same form and fields so that I can compare the data between Notes Client and XPages.

XPagesで日付フィールドの保存

Below is the source code for Date field and Time field in XPages.

Date Field

Time Field

Each inputText specify date, time to the Type attribute of convertDateTime.

After saving a new document from this XPage, below is the screenshot of stored field data:

XPagesから保存された文書のDateフィールド

XPagesから保存された文書のTimeフィールド

So both of fields have "yyyy/MM/dd hh:mm:dd ZZ" format.

Why you need to save "date only" or "time only" data from XPages?

I just don't post this blog to argue which format is proper way and why XPages behaves differently.

In the real world, I think you or your customers already have the NSF apps and you may want to improve them as the web application by XPages. In that case, especially you decide to keep using the NSF from both Notes Client and XPages, then I recommend to adjust the field format to Notes Client one instead of XPages one so that all existing documents are supported both Notes Client and XPages without changing data.

Use setAnyTime()、setAnyDate() of NotesDateTime class

Maybe there are a lot of way to achieve what I want below. But one of easy way is using NotesDateTime class of SSJS.

The SSJS above converts the DateTime field format by using setAnyTime()、setAnyDate() in PostSaveDocument event after saving the XSP document .

 


My Session Agenda for ConnectED 2015

This below is my session agenda I made for IBM ConnectED 2015.

For many of attendees, one of important session will be related about IBM Verse. My other buzzwords are bluemix integration, Domino API, Connections API, and of course XPages! like below:

  • IBM Verse: Deep Dive and Futures - ID114
  • IBM Domino Applications in Bluemix - AD201
  • Be Open - Use WebServices And REST In XPages Applications - BP108
  • There's an API for That! Why and How To Build on the IBM Connections Platform - BP205

 

This year also has a lot of great session as usual. I cannot wait! :-)


 

2015.01.25(Sun)

IBM Domino Applications on Cloud - MAS104

03:45 午後 - 04:45 午後 - Walt Disney World Swan, Swan 7-10

Pete Janzen (IBM), Christian Guedemann (WebGate Consulting AG)


2015.01.26(Mon)

IBM ConnectED - A New Way to Engage - OGS101

08:00 午前 - 09:30 午前 - Walt Disney World Swan, Swan 1-10

IBM Verse: Deep Dive and Futures (R1) - ID114

10:45 午前 - 11:45 午前 - Walt Disney World Swan, Swan 5-6

Andrew Davis (IBM)

IBM Domino - 2015 and Beyond (R1) - ID107

01:00 午後 - 02:00 午後 - Walt Disney World Swan, Swan 5-6

Scott Vrusho (IBM)

IBM Domino Applications in Bluemix - AD201

02:15 午後 - 03:15 午後 - Walt Disney World Dolphin, S. Hem 2

Martin Donnelly (IBM)

The Future of Web Development - Write Once, Run Everywhere with AngularJS and Domino - BTE102

03:45 午後 - 04:45 午後 - Walt Disney World Swan, Toucan 1-2

Mark Roden (PSC Group LLC)

IBM Verse AppDev and Extensibility - AD104

05:00 午後 - 06:00 午後 - Walt Disney World Swan, Swan 7-10

Andrew Davis (IBM)


2015.01.27(Tue)

ConnectED 2015 IBM Business Partner Kickoff Session - BPO101

08:00 午前 - 10:15 午前 - Walt Disney World Swan, Swan 5-6

Lou Sassano (IBM)

IBM Domino App Dev Futures - AD101

08:00 午前 - 09:00 午前 - Walt Disney World Swan, Swan 7-10

Eamon Muldoon (IBM)

There's an API for That! Why and How To Build on the IBM Connections Platform - BP205

09:15 午前 - 10:15 午前 - Walt Disney World Dolphin, S. Hem 2

Mikkel Flindt Heisterberg (OnTime by Intravision)

Take to the Cloud! Extend Your Applications with IBM Sametime APIs from IBM Connections Cloud - AD204

11:15 午前 - 12:15 午後 - Walt Disney World Swan, Swan 1-2

Brendan Arthurs (IBM)

IBM Notes Applications to the Web: IBM Notes Browser Plug-in - ID106

01:00 午後 - 02:00 午後 - Walt Disney World Dolphin, S. Hem 1

Rajesh Patil (IBM)

Adding Two Factor Authentication to IBM Connections Cloud - BTE202

02:30 午後 - 03:30 午後 - Walt Disney World Swan, Swan 7-10

Stephen McDonagh (AVX Limited)

Practical IBM Notes and Domino Internet Security - BP102

03:45 午後 - 04:45 午後 - Walt Disney World Swan, Swan 1-2

Daniel Nashed (Nash!Com)

Be Open - Use WebServices And REST In XPages Applications - BP108

05:00 午後 - 06:00 午後 - Walt Disney World Swan, Toucan 1-2

Bernd Hort (assono GmbH)

OpenNTF Domino API: The Community API - CHALK102

06:15 午後 - 07:00 午後 - Walt Disney World Swan, Swan 1-2

Paul Withers (Intec Systems Ltd)


2015.01.28(Wed)

XPages and Java: Share your Experience - CHALK405

07:15 午前 - 08:15 午前 - Walt Disney World Dolphin, S. Hem 2

Bernd Hort (assono GmbH)

From XPages Hero To OSGi Guru: Taking The Scary Out Of Building Extension Libraries - BP106

08:30 午前 - 09:30 午前 - Walt Disney World Swan, Swan 3-4

Paul Withers (Intec Systems Ltd), Christian Guedemann (Webgate)

Responsive Application Development for XPages - AD302

11:45 午前 - 12:45 午後 - Walt Disney World Swan, Mockingbird 1-2

Brian Gleeson

Build Your Own Apps in Minutes Leveraging IBM Bluemix and IBM Connections - AD202

01:30 午後 - 02:30 午後 - Walt Disney World Dolphin, S. Hem 2

Miguel Estrada (IBM)

ConnectED Closing Session: A New Way to Engage - CGS102

03:15 午後 - 04:00 午後 - Walt Disney World Swan, Swan 1-10


Expand Specific View in XPages

XPages - How to expand a specific category in the view as default

Control Expand/Collapse of the category view

To control Expand/Collapse status of the view in XPages, you just have to use [ExpandLevel] in view data source.
For example, Set "0" to expand, "1" to collapse as default.

Then Is it possible if you want to collapse the view as default except the specific category like below?

Expand Specific View in XPages
Expand Specific View in XPages

Expand only the specific category as default by SSJS

Use the following Serverside Javascript code in afterPageLoad event to expand the specific category.


In the above case, the last line(L4) specifies the first category to expand.

Like this sample code, you can control more if you use SSJS. In this case, I use DominoViewDataModel object. If you are interested in this object, you can see more detail from this link.

You might be able to get more ideas to control view data source directly.


[A 3]SSJSでも使える!Javascriptでオブジェクト指向プログラミング入門

XPagesDay 2014 「SSJSでも使える!Javascriptでオブジェクト指向プログラミング入門」スライド公開

XPagesDay 2014 (2014/11/18) 【A-3】「SSJSでも使える!Javascriptでオブジェクト指向プログラミング入門」で使用したスライドを公開しました。


XPagesDay 2014 イベントの申込開始!

XPagesDay 2014

XPagesDayの熱い二日間が今年もやってきます!

2013年も大成功に終わったXPagesDayが今年もやってきました。

今回は全てオンラインセッションとなっているので日本全国どこからでも参加できるイベントになっています。

当日は、自分も若輩ながらセッションを一つ講演させていただきます。

【A-3】「SSJSでも使える!Javascriptでオブジェクト指向プログラミング入門」

皆様、是非ご参加ください。

日時: 
    11 月 18 日(火)、19 日(水)の2日間

場所:
    すべてオンラインのセッション

主催:
    チームスタジオジャパン株式会社

参加費:
    無料 / 事前登録制

詳細、申込みはこちらから » http://www.xpagesday.com/xpagesday.nsf/sessions.xsp

 


2014/10/3、ノーツコンソーシアム 大阪地区研究会にてXPages事例紹介をさせて頂きます。

弊社のソリューションよりNotes/DominoとXPagesを用いたBtoC、BtoB 事例を開発者の方向けにご紹介致します。

当日はご来場の皆様に弊社作成のXPagesサンプルアプリケーションの無料配布を予定しております。

日時: 10月3日(金) 13:00-17:30
場所: IBM大阪事業所

13:00-15:00 研究会メンバーの話 (困っていること、SKILLなど)
15:30-16:30 事例 XPages事例(ケートリック 田付氏)
16:30-17:00 EXCITE Autumn のフィードバック(IBM)
17:00-17:30 次回開催について討議(全員)

XCITE Autumn 2014

来る2014/9/12、XCITE Autumn 2014 セッション(K-2)で講演致します

XCITE Autumn 2014

XCITE Autumn 2014 セッション(K-2)で講演

2014年、春に開催され大盛況だった日本IBMのイベントXCITE

今回、秋のイベント XCITE Autumn 2014のセッション「XPagesで革新!これからのNotes/Dominoアプリケーションの新常識」(K-2)IBM 佐藤 淳様と一緒に講演をさせて頂きます。

当日は、弊社のソリューションよりNotes/DominoとXPagesを用いたBtoC、BtoB によるコラボーレーション事例をご紹介致します。

皆様、是非ご参加ください。

日時:
    Business Partner Day  -  2014年 9月11日(木) 13:00-18:00    (受付開始:12:00)
    XCITE Autumn 2014  -   2014年 9月12日(金) 10:00-18:45    (受付開始:9:00)

場所:
    ザ・プリンス パークタワー東京
    (東京都港区芝公園4-8-1)

主催:
    日本アイ・ビー・エム株式会社

参加費:
    無料 / 事前登録制

詳細、申込みはこちらから » https://ibm-xcite.jp/

 


リッチテキストエディタのカスタマイズ

XPagesリッチテキスト CKEditorツールバーをカスタマイズ

XPages リッチテキスト コントロール

XPagesのリッチテキストコントロールはDomino 8.5.2からCKEditorが採用されるようになりました。

デフォルトでのリッチテキスト コントロールは以下の様なレイアウトになります。

デフォルトのXPages リッチテキストコントロール

デフォルトでは文字の修飾など基本的なことしか出来ないようになっています。

今回はこのCKEditorをカスタマイズする方法をご紹介します。

toolbarTypeを指定してカスタマイズ

以下の用にDojo属性を追加し、名前を「toolbarType」にし値を指定します。

値には

  • Slim
  • Medium
  • Large

を指定することができます。

リッチテキスト コントロールのプロパティ
リッチテキスト コントロールのプロパティ

それぞれのレイアウト

XPages リッチテキストコントロール Slim
「Slim」を指定
XPages リッチテキストコントロールMedium
「Medium」を指定
XPages リッチテキストコントロール Large
「Large」を指定

Javascriptを使ってフルカスタマイズ

dojo属性に「toolbar」を作り、ツールバーの項目をJavascriptの配列で指定することでリッチテキストコントロールのツールバーをフルカスタマイズすることが可能になります。

XPages リッチテキストコントロールをtoolbar属性でカスタマイズ
リッチテキストコントロールのプロパティ

値の部分にサーバーサイドJavascriptでツールバーの項目を以下のようにセットします。

全てのツールバーの項目を表示させたい場合、

のようになります。

このように、フルカスタマイズすることで、今までになかったHTMLソースコードでの編集等も可能になります。

XPages リッチテキストコントロール ツールバーのフル機能を表示
XPages リッチテキストコントロール ツールバーのフル機能を表示

CKEditor 3.X Developer's Guide も参考にしてください。

 


【XPages】 xe:jsonRpcService の使い方と考察

xe:jsonRpcServiceってなにやつ?

今回はExtension Libraryに搭載されている xe:jsonRpcServiceに関して日本語で解説がほとんど見当たらなかったのでブログに書いてみます。

xe:jsonRpcServiceはDomino Designerの右コントロールの「データアクセス」 →「リモートサービス」をXPagesにドラッグしてやることで作成することが出来るコントロールです。

jsonRpcService

とても軽量、シンプルな通信プロトコル JSON-RPC

でも使い道がいまいちよく分からないDomino技術者の方も多いと思います。そしてよく分かっていない内の1人だった自分が今回、jsonRpcServiceについて調べてみました。

まず、jsonRpcServiceはRPCの名が入っている通り、クライアントとサーバー間でリモート処理を実行したりするんだろう、と推測できます(RPC=リモートプロシージャコールの略)

そしてJSON-RPCはそれ自体が新しい規格であり、そのデータの受け渡しにJSONを利用したプロトコル(現行バージョンは2.0)ということです。

実際にはJSON-RPCでは以下の様なデータがやり取りされます。

とてもシンプルで軽量なプロトコルというのも納得ですね。

XPagesのjsonRpcServiceコントロールも同様に、できる限り軽量な構成になるようにデザインされており、クライアント・サーバー間で呼び出されたデータのみを送信し、返信されたデータのみを受信するといった軽量な処理が行えるコントロール、ということです。

ただ正直なところ、XPagesには部分更新イベントという便利な機能があるので、結果だけを見ると同等な実装が出来てしまうと思います。ではなぜjsonRpcServiceが必要になるのか?恐らくリモート処理がとても軽量に作られているということが一番の特徴だと思います。

例えば、株価の値を刻一刻と自動更新するようなアプリケーションを作りたいといった場合、XPagesの部分更新イベントを一分おきに発生させるというのはちょっと大掛かりな気がするのでもっと軽量な処理で実装したい、といったケースで役に立つのではないでしょうか。

 実際に使ってみた

jsonRpcService を使ったとってもシンプルなサンプルはこんな感じです。

6~10行目でJSON-RPCの関数を定義しています。ここではgetUserName()。処理内容はサーバーサイドJavascriptで記述できます。
そして13行目にボタンを配置してonclickイベントでクライアントJavascriptを書いていますが、service.getUserName();とすることでJSON-RPCのリモート関数を呼び出しを行っています。

このようにxe:jsonRpcServiceでリモート関数を定義すると自動でクライアントJavascipt関数が用意されているというところが肝ですね。

上記のサンプルでは関数の引数は使っていませんが、もちろん引数を持たせることも可能です。
引数を持たせて足し算の計算をさせたサンプルがこちらです。

ハイライトしている7,9,10,18行目を見て頂くとわかると思います。

 

どれだけ軽量なの?

それでは、実際にjsonRpcServiceがどれほど軽量か上記のコードをFirefox Firebugを使って確認してみます。jsonRPCService_add

上記のXPagesをFirefoxで読込み、Firebugを起動、「Net」のタブを開いておきます。そして「足し算」ボタンを押した時に追加される通信データを確認します。

 

 

 

以下の画像がその時のFirebugの表示結果です。

jsonRPCService Firebug

おぉ、データサイズわずか44バイト!! 軽っ!

実際にどのようなデータがやりとりされたのかもFirebugで確認してみます。

まずはPostデータ

jsonRpcSercie Post Param

ふむふむ、「"jsonrpc": "2.0"」 というようなプロトコル情報も省略されており本当に必要な情報のみがPostされています。

つぎにResponseデータ。

jsonRcpSercie Resqonse Param

やはり必要な結果のみがResponseデータとして返ってきています。

ちなみに同等の処理をXPages 部分更新で行いましたが、Postデータ、Responseデータ共にこれほど軽量な処理をさせることは出来ませんでした。また、XPagesの部分更新では”計算結果フィールド”のみを部分更新させるといった場合でも<span>タグ付きで値が返ってきたりと、クライアント側でのデータ再加工を行いたいというような場合、値だけを返すjsonRpcServiceのほうがプログラミングが楽になりそうです。

 jsonRpcServiceを利用する時の注意点

以下のサンプルコードをみてください。

上記のコードはこちらのStackoverflow で質問と一緒に公開されたコードです。
ハイライトされた9,10,20行目を見て頂くと、このコードの作成者はjsonRpcServiceのリモート関数を使ってXPagesで読み込んでいる文書を保存、返り値にTrueを返す、という処理を行いたいのだろうと推測できます。

ただ、このコードは意図した動きをしません。

今回の記事をここまで呼んで頂いた方々にはすでに察しが付いていると思いますが、jsonRpcSerivceはあくまでJSONによってデータをやり取りしていますので、9行目のgetComponent("inputText1").getValue() というのは解決が出来ない情報になってしまいます。

同様にXPages上に存在するdocument1というデータソースも取り扱うことができません。引き渡したいデータがあれば、xe:remoteMethodArg 引数を使って明示的にJSONデータに含めないといけないということです。

このように、jsonRpcServiceはXPagesで読み込んでいるデータソース文書を保存したりする処理には向いていないように思います。(出来ないことはないはずです)

jsonRpcServiceはデータの読み出し専用が得策?

このstackoverflowの回答者も言っていることですが、上記の理由からjsonRpcServiceはデータの読み出し専用として利用することが最良であるかもしれません。

以下、jsonRpcServiceを利用したらいいかもしれないシチュエーションとして

  • 会社の株価を定期的に自動更新するようなプログラム
  • 新しいユーザーを登録する際にすでに同じユーザー名、Emailがないかどうかを問い合わせるプログラム
  • サーバーからのレスポンスデータをクライアントサイドJavascriptで操作、加工したい場合

などに適していると思われます。

いかがでしたでしょうか?

jsonRpcSerivceの特徴を把握してXPages開発の選択肢の1つとして覚えておいてもらえればと思います。