March 24, 2011

Error: Saving this document will change its format

I have an XPage that is used for editing news. Those news may be created from the Notes client and contain some Rich Text fields.

When editing the news I get an error like this:


Saying: Saving this document will change its format from native Notes rich text to HTML. This may cause a change or loss of formatting if opened again in the regular Notes client.

What "damage" might this inflict? And are there any way to avoid this smoothly?

March 10, 2011

Debugging tip: insertNotesClientLinks852

Today I got this fairly unknown error when trying to access a document with a XPage.

The runtime has encountered an unexpected error.

Error source
Page Name:/myXpage.xsp


Exception

java.lang.StringIndexOutOfBoundsException
java.lang.String.substring(String.java:1092)
com.ibm.xsp.model.domino.wrapped.DominoRichTextItem.insertNotesClientLinks852(DominoRichTextItem.java:387)


After doing a quick search on google I found a post on the IBM forums claiming this had to do with bad HTML markup within a Rich Text field.

Unfortunately this particular Document had tons of HTML, so it took some time narrowing it down. After some 30 mins I discovered the error was caused by a anchor tag where the href attribute was missing a " at the start...

Anyways.. problem solved!

March 9, 2011

Debugging tip:Error while executing JavaScript action expression

Occationally we stumble upon some "weird" errors on our xpages. Below is one such error:

Runtime Error

Error source

Page Name:/someXPage.xsp

Exception

Error while executing JavaScript action expression
Script interpreter error, line=385, col=20: 'someJavaScriptMethod()' is undefined and cannot be accessed as an array
at [/someJavaScriptFile.js].methodOne()
at [/someJavaScriptFile.js].methodTwo()
at [/someJavaScriptFile.js].methodThree()

In this specific example it is indeed possible to access the method as an array. The clue here is someJavaScriptMethod(), with no parameters. In my code, line 385(correctly pointed out), the methodcall has several parameters. When the exception is displayed as this, it usually means that at least one of the input parameters is null. This should narrow your scope when searching for the error!

Happy debugging!

March 1, 2011

Solved:Display picture from Rich Text Field with XPages


Im having a Form where I have a Rich Text Field(lets call it imageField) added there to hold an image. The user of the Form will directly copy an image into the imageField , not the location of the image, THE image will be copied into the field.

When I then later try to display this image on a Xpage nothing comes up..

Google wont help me with this particular problem either. Anyone out there know how to do this?

SOLVED:
As Ben over at My Comfy Chair pointed out this is in fact quite easy to solve.

Start by making the Rich Text Field save as HTML and MIME. After that you simply refer to the field in the src part of the img tag:
src=\"myView/"+itemInView.getDocument()+"/FieldName/M2?OpenElement"

Worked like a charm for me! Thanks alot Ben!