bookmark_borderJSF phases in XPages

I was trying to setup a system to handle “validation” via setup documents
the normal validators which can be set up directly on each field would not help much (or be too much work to implement)

I first tried a simple method: isDocValid returning true/false and adding JSF Messages like following:

String m1 = “summary: ups something went wrong”;
String m2 = “detail: ups something went wrong”;
msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, m1, m2);
facesContext.addMessage(field.getClientId(facesContext), msg);

I would call this methid in the querySaveEvent of the XPage, and it seemed (at least for new documents) to work well.. until I opened a document from a view, and oh wonder (maybe it’s a feature and not a bug) the querySaveDocument event was not even triggered…

That was bad news: I also had a “save as draft” button which would let the user return to the document, but if the validation then would fail?

nope.. I started looking for another way…

so I talked to a guy who has a LOT, I mean a LOOOOOOOOOOOOOT, of JSF experience.
With his help and some from my best friend (google) I did the following:

created a phase listener which logged all events (great for debugging, see those “immediate” events)
a very good article about the JSF phases can be found here:
http://www.ibm.com/developerworks/library/j-jsf3/
a MUST read for any serious XPages developer with little or no JSF experience!!

so then thanks to the phase listener I could see the how all phases process.

and now I immediately had also a way to “plugin” my custom validators properly (more on that in another post)

so here what I did for the phase listener:
Java class:

public class PhaseListener implements javax.faces.event.PhaseListener {

public void beforePhase(PhaseEvent event) {
// log your beforePhase with event.getPhaseId()
}

public void afterPhase(PhaseEvent event) {
// log your afterPhase with event.getPhaseId()
}
}

faces-config.xml:
  <lifecycle>
    <phase-listener>package.of.your.PhaseListener</phase-listener>
  </lifecycle>

now you can add simple additional code in any phase (before or after)
just use something like:

if (event.getPhaseId().equals(PhaseId.PROCESS_VALIDATIONS)) {
// run your code
}

PhaseId. (dot control space) will list all the CONSTANTS to check for any of the phases

bookmark_borderdon’t use “finally” in your Java code for XPages

since I have no started digging deeper into the XPages mysteries I want to share some of my learnings.

As most of you know: if you use Java in Lotus Notes/Domino you have to take care that you recycle the Notes objects you instantiated (session, database, document etc.)

Java has a nice feature called “finally”. If you use a try/catch block (which I do to log all errors happening, so that I can follow up and fix them) you can also add the “finally” block at the end..

It could serve pretty well for incinerating (I bought that term form some other blogger) the Notes objects…

But beware: I created a class which should be called upon the querySaveDocument event. As soon as I added the finally block the page would crash, most of the times so bad that my whole Notes/Designer went down too…

After hours (again hours!!! can you imagine what my week looks like???) putting log code moving it down one by one… until I reached the try block, nothing worked anymore…

but luck I figured: why not remove the finally block.. and miraculously the XPage could be displayed again

I don’t know what/why exactly it crashed and if you always should not use the finally block, try it.. if your system crashes, remove it and handle it in another way

bookmark_borderrequestScope mystery solved

again RTFM!!!! but hey… the FM not always tells you what you want to know!

Might that be the reason why we developers tend to NRTFM?

dunno..

anyhow… after DAYS of testing / searching (is it called googling nowadays?) / changing code and iterating a (felt) thousand times…

I finally came accross the solution how to “persist” the requestScope from one xPage to another…

First (I hope I am not wrong with this) a bit of background:

The parameters set in the requestScope would (normally) get submitted via the URL (in a GET request). As those JSF (and xPages) mostly work via POST request we (unless we use nice tools, such as the TCP Monitor in the designer!) never really see them. That’s one of the reasons so many Domino developers struggle to get the requestScope working. We cannot really debug it properly.

Thanks to TCP Monitor and a friend helping me, we finally figured:

After an xPage has been submitted and the navigation rule would redirect it to another page this redirection was a request to the client browser!

Imagine: The server tells the browser: please ask now for page xyz.xsp

And with the little background above you can understand that the server didn’t tell the browser which requestParameters it should transmit as well, alas they would be (ARE!!!) lost.

But as i said.. I did a lot of research on this and I found the following setting: (You find it under the “Package explorer” view in the designer

if you turn this feature off the server does not ask the browser for asking the new page but the server actually redirects himself to the new page and hence will preserve the requestScope values….

So you can actually have the dimmwitted example of two xPages where on one page you enter the name and submit it, and the second page will greet you with “Hello yourname” works!

I for myself will use this feature to tell my xpView.xsp (the one which handles all views in my db) will know which view it has to display after a document has been submitted (at least if nothing else has been defined)

bookmark_borderhave you ever wondered if i might be possible to make a custom control look nicer in the xPage design view?

It can be done! And it’s actually not even that complicated.

Find the instructions here:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/16102009115724SCAEXA.htm

or read on…

there is this nice Design Definition property on all custom controls (starting 8.5.3 I think):

if you add some xPage source code to it (tip: create a new xpage the way you would like to look this custom control in the design view and copy & paste its source code here)

it will later on in the actual xPage look like this:

in this example i used is as a way to “document” some settings required to make it work properly.

But of course you could, if you have, for a company framework, also paste in a picture of a standard menu, the footer or the header of your pages.

then while designing the xPage you get a better feeling on how the page will look like later.

and it gets even better.. just read an article, that this design definition is “dynamic”, means you can actually have the custom control look different, ie. depending on custom properties you set.
Read this article: http://dontpanic82.blogspot.ch/2010/01/xpages-using-powerful-design-definition.html

bookmark_borderExtension Library installation pains

okay okay.. I know.. RTFM

but hey.. we are developers, we know what we are doing, right? 😉

How it all began:
I was first trying to install the Extension Library on my desktop manually. and of course I installed the Domino part instead of the Designer part 🙁

I then considered following those instructions here:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Installing_the_upgrade_pack_on_Domino_Designer_and_Notes_ddxl853

but again RTFM…

I mean c’mon… can’t be that complicated.

It can!!! After 2 days of trying (installing/uninstalling both LN/FP/UpgradePack)  to get this upgrade pack installed I almost gave up.

But then I took a quiet moment and told me: one last time.

Interestingly the modules had been installed in previous attemps, only I could not load any xPage with modules from the extension library as something didn’t install 100% correctly! I always got the Error 500 command not handled exception.

With those features installed… I could finally figure out the exact filenames to check and remove manually any directory/file which was still in the mentioned (see link above) directories. If Windows 7 search would have done a better job I wouldn’t have needed those exact filenames though, maybe some of my anger goes to MS.

so here is how I found the exact names:

Files searched:
  • org.apache.wink…
  • com.ibm.domino.das…
  • com.ibm.wink…
  • com.ibm.xsp.extlib…

directories searched:

  • frameworksharedeclipsefeatures
  • frameworksharedeclipseplugins
  • datadominoworkspaceapplicationseclipsefeatures
  • datadominoworkspaceapplicationseclipseplugins
  • dataworkspaceapplicationseclipsefeatures
  • dataworkspaceapplicationseclipseplugins

So after I had figured out the names I had to look for and manually deleted them (also in the DataWorkspace and DataDominoWorkspace directory), the upgrade pack installed just fine…
yours
Michael

bookmark_borderever wondered how to toggle single-sign on feature?

If you did install the single-sign-on feature with Lotus Notes and you got it working, fine.

But what if for some reason you want to disable this feature?

And you find unluckily it’s grayed out and thus cannot be disabled?

help is around the corner…

run Notes as “Administrator”

and you happily find this feature “active” (ie. not grayed out anymore), thus you can now disable it

bookmark_borderdid you know about all those “undocumented” features LN offers?

following this link you will find a lot of really cool stuff which is hidden underneath, ie. undocumented

http://www.devinolson.net/devin/SpankysPlace.nsf/d6plinks/DOLN-8G4NBJ

IBM: please make those features “documented”!

do you personally use “undocumented” stuff in the LN world? did you ever face challenges?

bookmark_borderdo you ever read “release notes”?

it’s been a while since my last post here.

i usually don’t really read release notes, do you?

but did you know those cool features about the new table edititing possibilities in the LN8.5 client?

  • Drag column or row margins to resize
  • Drag the margins of the entire table to resize it
  • Drag the contents from one cell to another
  • Set the table width when creating a fixed width table
  • Easily insert a new row or column by holding down the Shift key and double-clicking the common border

or these ones:

  • a new Folder column in the mail All Documents view displays any mail folders that a document is in
  • From any mail view, right-click on the Trash folder and select Empty Trash.
  •  Back by popular demand, you can use red text to indicate unread documents. Click File > Preferences, and then click the Fonts and Colors preference. For the field Unread mail indication, select Plain red text. Also note that this preference provides you with an easy way to enlarge the text in the data areas of Notes, such as the Inbox and messages.
  • To select an alternate email address, when you begin typing a name, select Other email Addresses from the menu that appears. The more frequently used addresses display at the top of the list.
looking forward to more exciting features

bookmark_borderovercome designer sluggishness to open design elements

If you are a Domino designer I am 100% sure you are as frustrated as me when you double click any design element and it takes for ages for it to open.

Solution:
1. double click the design element
2. click on any other tab of a view..

usually the design element then opens immediately

BUT: be aware that you didn’t “single-click” first on another design element, cause that would cause that element to be opened 🙁

yours

iPinky7

bookmark_borderupdate on “easiest way to open design elements”

Hi again

Here is an update on “easiest way to open design elements” which seemed to be very obvious..

In the other post (see link above) I wrote that the keyboard shortcut <ctrl><shift><r> does not always work when the focus is wrong.

but you can easily change the focus to the “Applications” view with another shortcut: <ctrl><F7>.
Actually <ctrl><F7> is the same used to switch focus in the client (see here)

So in the designer you would get a popup menu something like this:

You then can simply choose the db you are working on to get the focus (in this example iPinky) and then continue with <ctrl><shift><r> to find the design element you want to open