XPage Dialog List Value

Hi There,

Looking for a little help…I have an XPage with a dojo dialog box for selecting multiple values. The code it uses to put the selected values into the field is :

//function printToLog(stuff) {

// _dump(“\r\nPRINT START\r\n”);

// _dump(stuff);

// _dump(“\r\nPRINT END\r\n”);

//}

var viewPanel=getComponent(“viewPanel1”); //get the componet of viewPanel

var docIDArray=viewPanel.getSelectedIds(); //get the array of document ids

//printToLog(viewPanel.getSelectedIds())

for(i=0;

i < docIDArray.length;

i++){

var docId=docIDArray[i];

//printToLog(docId)

var doc=database.getDocumentByID(docId);

//printToLog(doc)

if(doc != null){

var pickthis1 = doc.getItemValueString("PmpType");

//printToLog(pickthis1);

//printToLog(lKey);

//printToLog(circ);

if(pickthis1 != null){

if (@Contains(SOP.getValue("PumpType"),pickthis1)){

	SOP.setValue("PumpType",SOP.getValue("PumpType"));

}else{

	if(SOP.getValue("PumpType") == null || SOP.getValue("PumpType") == '')

	{

		SOP.setValue("PumpType",pickthis1);

	}else{

		SOP.setValue("PumpType",SOP.getValue("PumpType") + ", " + pickthis1);

	}

}

}

}

}

SOP.setValue(“PumpOK”,“OK”);

As you can see, I am appending the value onto existing values (if they exist) using a ", ". On the form in the backend, the field is a Dialog List box, which uses the same separator. I have a view which “displays multiple values as separate entries”. This works for docs created in the client, but not the docs created in the XPage. But when i open the one cretaed by the xpage in the client and save it, the view then shows them as separate.

Am I missing something here? Is there something i need to do to get it showing as separate entries?

Thanks very much.

Subject: Multi-values

When you update your document via the XPage, when you look at the document properties, are the results really stored as separate entries? If they’re just stored as 1 comma-delimited string then maybe using a Custom Converter can remedy that.

What I’ve found is that the “multiple separator” property doesn’t seem to work as expected (for me anyway). What I’ve done with fields that are multi-value is to set them up on the Notes form to use whatever separator you want (comma in your case). Then on the XPage, I DON’T say the input box has a multiple separator, but use a Converter to translate back & forth from the Notes field to the XPage Input box (or multiline box or whatever). The getAsString is to go from Notes > XPage & the getAsObject is to then store XPage > Notes.

xp:this.converter

xp:customConverter

<xp:this.getAsString><![CDATA[#{javascript:@Implode(@Name("[Abbreviate]", value), ", ")}]]></xp:this.getAsString>

<xp:this.getAsObject><![CDATA[#{javascript:@Name("[Canonicalize]", @Explode(@Trim(value),","))}]]></xp:this.getAsObject>

</xp:customConverter>

</xp:this.converter>

Maybe this will work for you. I’ve found converters work pretty well.

Another suggestion might be to do some machinations on the field in the querySaveDocument event – I’ve seen some sample code that does that.

Subject: Brilliant!

Many, many thanks for that code…it works a treat!

I have found that it only works on fields that do not have their “Read Only” property set (as I was wanting the user to have to use the dojo list box rather than type in values)

But, I have easily got around this, by setting the onFocus property of the field to popup the dojo box - I actually its better! :slight_smile:

Thanks again!