Xpages: Picklist Views and the pager

On May 19, 2009, in xpages, by Mark Hughes

If you create a picklist from a view like i posted yesterday, make sure you set the pager to partial refresh on your views, or else it will refresh the entire page and your dialog will go back to being hidden.

 

Xpages: How to create a view picklist!!

On May 18, 2009, in xpages, by Mark Hughes

So i finally figured it out, by piecing many sources of code from around the internet.

Updated to say go get the custom control on Openntf.org!!!

It is much easier to use and set up.  It is also reusable.

link

 

Step 1. create a custom control.

Create a custom control and put your view on it, and put a search bar and a select button above it like this, make the first column have a check box option

Configure this for searching…. click here if you do not know how to do this.

On the select button “on click” event put this code in, it gets the selected documents, then it gets a value from the document and then adds it to the field on my main form. I got this code form the developer wiki

<span style="color: #0000ff;">function</span> printToLog(stuff) {
_dump(<span style="color: #006080;">"\r\nPRINT START\r\n"</span>);
_dump(stuff);
_dump(<span style="color: #006080;">"\r\nPRINT END\r\n"</span>);
}

<span style="color: #0000ff;">var</span> database = session.getDatabase(<span style="color: #006080;">"notes1"</span>, <span style="color: #006080;">"applications\\viewpoint.nsf"</span>)
<span style="color: #0000ff;">var</span> viewPanel=getComponent(<span style="color: #006080;">"viewPanel1"</span>); <span style="color: #008000;">//get the componet of viewPanel</span>
<span style="color: #0000ff;">var</span> docIDArray=viewPanel.getSelectedIds(); <span style="color: #008000;">//get the array of document ids</span>
printToLog(<span style="color: #006080;">'got ids'</span>)

<span style="color: #0000ff;">for</span>(i=0;
i  &lt;  docIDArray.length;
i++){
<span style="color: #0000ff;">var</span> docId=docIDArray[i];
printToLog(docId)
<span style="color: #0000ff;">var</span> doc=database.getDocumentByID(docId);
printToLog(doc)
<span style="color: #0000ff;">if</span>(doc != <span style="color: #0000ff;">null</span>){
<span style="color: #0000ff;">var</span> pickthis1 = doc.getItemValueString(<span style="color: #006080;">"projectnum"</span>)
printToLog(pickthis1)
}
}

<span style="color: #0000ff;">if</span>(pickthis1 != <span style="color: #0000ff;">null</span>){
dominoDocument1.replaceItemValue(<span style="color: #006080;">"job"</span>, pickthis1)
}

 

On the client side of the select button js on click event, enter this in 

dijit.byId(‘Dialog3’).hide();

This closes the dialog we will create in a moment. Save and close that custom control.

On your main form you need to add this client side javascript function, i found this on the forum, unless you use this you can not click any buttons on your dialog or search or update.

 

/** 

<span style="color: #008000;">* Creates a dijit dialog box based on a div content</span>
<span style="color: #008000;">* @param id div identifier</span>
<span style="color: #008000;">*/</span>

<span style="color: #0000ff;">function</span> dialog_create(id, title1) {
<span style="color: #0000ff;">var</span> dialogWidget = dijit.byId(id);
<span style="color: #0000ff;">if</span>( dialogWidget )
dialogWidget.destroyRecursive(<span style="color: #0000ff;">true</span>);
dialogWidget = <span style="color: #0000ff;">new</span> dijit.Dialog(
{ title: title1, duration:600},
dojo.byId(id));

<span style="color: #0000ff;">var</span> dialog = dojo.byId(id);
dialog.parentNode.removeChild(dialog);

<span style="color: #0000ff;">var</span> form = document.forms[0];
form.appendChild(dialog);
dialogWidget.startup();
}

Next add this to the source of your page, notice the<> is the picklist custom control we just created

 

At the top of the XPage in source view, you need to add the onload function to call the function to create the dialog

Then we create a button to show the dialog with client side javascript.

dijit.byId(‘Dialog3’).show()

Then you will have something that works like a picklist, once you do it once it gets much easier.

moz-screenshot

example

 

Xpages: Has anyone created a picklist yet?

On May 14, 2009, in xpages, by Mark Hughes

I was wondering because it would be nice to have a button to pop up a dialog with a view in it, have check boxes and be able to return values back to the underlying webpage when done.

I have created a dialog inside an iframe for a simple pop up form, so i am familiar with that step. I guess i could put an xpage view inside the dialog and then when the select button is pushed, transfer the values, but how would one get the values of the selected document?

Any help is appreciated, this seems to be the only big thing missing from xpages, and maybe they will add an @picklist function in the future