XPages - the most basic of help

I’m trying to get into XPages development. A huge thank you to all the big brains out there blogging amazing examples of what is possible. I’m having ridiculous trouble even getting started. I have a document with a multi value field on it, and I would like to display those values in an XPage, with a new line for a seperator. I won’t entertain you with my struggles so far, but I have an XPage with a Domino Document Data Source, and all the drag and drop stuff seems to work great. But when I try to customize anything, it’s like trying to pilot an alien spacecraft for me, learning the new IDE and referencing sparse documentation. I think what I want is a Computed Field Core Control, then Bind data using: Javascript (server side), then something with NotesXspDocument.getItemValue, then profit? Or is there some other way I should go about it?

I can get this:

[value1, value2, value3…]

when what I want is this:

value1

value2

value3

Even the slightest nudge in the right direction would be hugely appreciated, a working snippet of code and I might start crying. I had the feeling that a breakthrough would come eventually and it would all start making sense to me, but that feeling is slowly fading :frowning:

Subject: try multipleSeparator property

know what you mean, documentation and help is really poor so far!

Anyways, regarding multi value fields (sorry: edit boxes…): highlight your field / box then open “Properties - All Properties - basics”. Here you find a property “multipleSeparator” (along with another interesting one called “multipleTrim”). I haven’t trierd, but since JavaScript is the language of choice in XPages I would assume that “\n” would be the separator you’re looking for…

Please let me/us know whether I was right :wink:

Subject: nope, that wasn’t it

multipleSeparator is for ENTERING mulitple values not for displaying them (should have tried before, sorry).

Subject: Have you tried exploding the array?

Hi Mike,Firstly, welcome to XPages.

I’m not exactly what you’re trying to do here but maybe try exploding the array…

var arr = [value1, value2, value3…]

@Explode(arr, “,”)

Or using a convertor on the computed field.

If all that doesn’t help send me ( paul_hannan@ie.ibm.com ) on your app (wide open ACL and no encryption) for a better look.

Regards,

Paul.

Subject: If I can expand On Paul’s response

I have done something similar with a Computed field control set as Display type “HTML”. Here’s the formula:

@Implode(@Explode(SurveyQuestion.getItemValueString(“AnswerChoices”),“,”),“,
”);

Subject: some questions on your solution

John,thanks (again) for your input. I tried it and - of course - it worked. But two questions remain:

  1. I’m not too happy with the appearance:

my computed field now displays the multiple values each on its own line. But the list itself is enclosed in square brackets:

[value1

value2]

I take it that those brackets are an indication that an array is being displayed

  1. Before I had read your response I had played around with several other solutions, but none really worked. One attempt was to read the source field’s value using

.getItemValueArray()

I would have expected that I could save the extra @Explode, as in

@Implode(dataSource.getItemValueArray(“fieldName”), “
”);

But No: the result still appears to come out as a string, displaying the values as

[value1,value2]

(Square brackets again!)

Since I didn’t think about rendering the ComputedField as HTML I tried to @Implode the value using @NewLine(), but again no success. Result here is:

[value1 value2]

(no comma between the values, but still the square brackets…)

Next thing I played around with were the converters that also got mentioned by Paul, But I don’t really get it how I’m suposed to work with those.

And yes, I also tried to use a list box control reading in the source field’s content as-is. And hey, that worked (but I know, that’s not really good coding…)! So again: if the source already does contain an array, why would I have to @Explode it then?

Sorry, I don’t seem to get it… :-(((

Subject: Ok, got the solution

Ok, I think there is a bug with the NotesXspDocument class. It seems to return the field value as a string with the brackets around it when you expect it to be an array. The way you can test this is try to return the “length” property, which will always be 1, indicating a single element.

So even if you explode the values or use a javascript split() and then @Implode them, the brackets are part of the first and last elements because they were appended to the string. So it looks like an array is being returned.

The solution is to use the NotesDocument class instead:

doc=document.getDocument(); //get the backend doc

@Implode(doc.getItemValue(“fieldname”),“
”);

I’ll throw out another option too. You can use a repeat control on a multi-value field and then use an Editbox in readonly mode to display each item in the list.

John

Subject: baby steps

Display type options are String, Mask, Number, and Date/Time. Mask sounded promising, but after digging for documentation, nope not what I’m looking for.

It’s Content type I want, Text or HTML, that’s on the Computed Field tab of the properties box, not the Value tab where the JavaScript goes and where the Display type is. And yes my code ended up looking pretty much like yours, thank you :slight_smile:

@Implode( DataSourceName.getItemValue( “FieldName” ), ‘
’ );

It’s almost funny when I look at the things I had tried.

Now, about tables. How do you set a cell to come out as a ? How long did it take to get that option in regular Notes, and now I can’t find it anywhere again? And how come you get controls for Font, Background, and Margins, but nothing for borders? And how come the All Properties tab of the Properties box disappears with multiple selections? I still have to put a CSS class in one table cell at a time?

And I want to put in an embedded view with show single category. It’s probably easy, if I could find somewhere to start. What happened to the Key property from the beta?

http://www-10.lotus.com/ldd/nd85forum.nsf/4b9931b774db788c85256bf0006b5e6d/0161778c49c6fc9f852574e90032ce4d?OpenDocument

I have to roll my own now?

http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/091ffd16f489f27d8525753f005d0182?OpenDocument

And no @WebDBName???

Xpages are definitely better result wise, and have possibilities way beyond anything we had before. But for day to day bread and butter stuff, it just hasn’t hit me yet how they make everything easier. It’ll take me more than few days to get to the point where I can do the things I’ve always been able to do in a comparable amount of time never mind quicker, and never mind learning about possibilities to do more. I think for now I’ll just go back to 8.0 and stick to the kludges I’m used to. The CSS editor is the only other thing I noticed so far that I will miss. Maybe someday some fancy requirements will come along that make me take another look at this, but for now I have to get things done :frowning:

I still have motivation, and will try poking around in my own time. I think I’m more dissapointed in my own ability to dive in and get things done than I am with the work that’s gone into XPages. The view stuff is fantastic, that will probably be the first thing that I try to squeeze in somewhere. The documentation, well I guess it will mature with time. I think the best thing to focus on with the documentation would be simple “this is how you used to do it, this is how you do it now” stuff as opposed to diving right in to the “could you ever have imagined that you could do this!” stuff that’s all over the blogosphere. Great work everyone involved, sorry I’m not up to it.

Subject: don’t have all the answers…

Just the original issue…

Subject: OK field is working now, but what about a column value?

Thanks once more John,

with your code I’ve got it to work now; I’m far from being able to tell if this would be a bug or if it’s just my limited understanding of the concepts (and in that point I do agree with Mike: currently I’m in the comfortable situation of having time to play, but that’ll end soon…).

But now I see that my multivalue field’s content is displayed in a view as

[value1,value2]

I think I have a few ideas how I could tweak those column values to show their contents the way I want them to be shown.

What I don’t get is whether I’m really suposed to tweak the column values here, or whether there is some standard way to have them display my Domino data in a standard way?

Subject: Have you found a solution?

Hello Lothar,

Today I’ve spend the whole day seeking for soltuion that will allow me to show multiple values in a view separated by a new line.

Seems that you faced the same situation a while ago. Did you managed to find something (either a solution or a workarround)?

Subject: a possible solution

Hi,

Define rowData as your variable for view entries, mark your column’s content type as html and add something like the following formula to the value of the viewColumn (in this example for the second column of the view):

@Implode(rowData.getColumnValues().get(1), “
”);

Source:

	<xp:viewColumn columnName="Values" id="viewColumn2"

		contentType="HTML">



		<xp:this.value><![CDATA[#{javascript:@Implode(rowData.getColumnValues().get(1), "<br>");}]]></xp:this.value>

		<xp:viewColumnHeader value="Values"

			id="viewColumnHeader2">

		</xp:viewColumnHeader>

	</xp:viewColumn>

Tibor