Tuesday, May 19, 2009
Monday, May 18, 2009
Xpages: How to create a view picklist!!
Posted by
Mark Hughes
at
3:24 PM
So i finally figured it out, by piecing many sources of code from around the internet.
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
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.

Updated to say go get the custom control on Openntf.org!!!
It is much easier to use and set up. It is also reusable.
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
function printToLog(stuff) { _dump("\r\nPRINT START\r\n"); _dump(stuff); _dump("\r\nPRINT END\r\n"); } var database = session.getDatabase("notes1", "applications\\viewpoint.nsf") var viewPanel=getComponent("viewPanel1"); //get the componet of viewPanel var docIDArray=viewPanel.getSelectedIds(); //get the array of document ids printToLog('got ids') 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("projectnum") printToLog(pickthis1) } } if(pickthis1 != null){ dominoDocument1.replaceItemValue("job", 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.
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.
/**
* Creates a dijit dialog box based on a div content * @param id div identifier */ function dialog_create(id, title1) { var dialogWidget = dijit.byId(id); if( dialogWidget ) dialogWidget.destroyRecursive(true); dialogWidget = new dijit.Dialog( { title: title1, duration:600}, dojo.byId(id)); var dialog = dojo.byId(id); dialog.parentNode.removeChild(dialog); var 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.
Thursday, May 14, 2009
Xpages: Has anyone created a picklist yet?
Posted by
Mark Hughes
at
8:16 AM
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
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
Tuesday, March 31, 2009
Xpages, file download control problems, work around
Posted by
Mark Hughes
at
8:05 AM
It seems that if you put a file download control on an xpage, and that application is in a sub folder,
ie. data\applications\application.nsf
then you will receive an error trying to open the files. The developer evidently forgot to get the path of that database when creating the link.
Work Around:
It you put the same database in the data directory it works great.
Don't know why this has not been fixed seems like it would be simple, with a feature release.
ie. data\applications\application.nsf
then you will receive an error trying to open the files. The developer evidently forgot to get the path of that database when creating the link.
Work Around:
It you put the same database in the data directory it works great.
Don't know why this has not been fixed seems like it would be simple, with a feature release.
Friday, February 20, 2009
Xpages and nice buttons using css
Posted by
Mark Hughes
at
8:36 AM
I saw a post recently about how to use dojo themed buttons on your xpages, but they only seemed to work on forms, not views, at least i was having trouble making them consistent across all of my pages.
So i took some screen shots and created a css file and applied them to all the buttons, i guess i should create a them to do that for me.
Here is what it looks like finished..

here is the css code
.button {
background-image:url(button2.png);background-repeat:repeat-x
height:30px;
margin-bottom:3px;
padding-left:0px;
font-weight:bold;
font-family:Arial,serif;
font-size:9pt;
color: rgb(14,94,152);
border-color:#C0C0C0 #9B9B9B #9B9B9B #C0C0C0;
border-style:solid;
border-width:1px;
padding: 0.2em;
}
.button:hover{
background-image:url(button2over.png);background-repeat:repeat-x;
border-color:#A5BEDA #5C7590 #5C7590 #A5BEDA;
color:#000000;
}
here are the images
So i took some screen shots and created a css file and applied them to all the buttons, i guess i should create a them to do that for me.
Here is what it looks like finished..

here is the css code
.button {
background-image:url(button2.png);background-repeat:repeat-x
height:30px;
margin-bottom:3px;
padding-left:0px;
font-weight:bold;
font-family:Arial,serif;
font-size:9pt;
color: rgb(14,94,152);
border-color:#C0C0C0 #9B9B9B #9B9B9B #C0C0C0;
border-style:solid;
border-width:1px;
padding: 0.2em;
}
.button:hover{
background-image:url(button2over.png);background-repeat:repeat-x;
border-color:#A5BEDA #5C7590 #5C7590 #A5BEDA;
color:#000000;
}
here are the images
Xpages, formmating currency client side for multiplication
Posted by
Mark Hughes
at
8:27 AM
I needed to multiply a qty times a value and get a total on an xpage, sounds easy until you start getting nan, so i learned a little dojo to convert to and from currency.
On the onblur event of the field i put this on the client side of both the qty field and amount field.
//get the string values
qty1 = XSP.getElementById('#{id:qty1}').value
amount1 = XSP.getElementById('#{id:amount1}').value
//get the dojo currency code
dojo.require("dojo.currency");
//get the numeric value using parse
amount2 = dojo.currency.parse(amount1, {currency: "USD"})
//multiply
total1 = qty2 * amount2
//set total value as currency using format
XSP.getElementById('#{id:total1}').value = dojo.currency.format(total1, {currency: "USD"})
//make sure the amount is in currency format using format
XSP.getElementById('#{id:amount1}').value = dojo.currency.format(amount2, {currency: "USD"})
On the onblur event of the field i put this on the client side of both the qty field and amount field.
//get the string values
qty1 = XSP.getElementById('#{id:qty1}').value
amount1 = XSP.getElementById('#{id:amount1}').value
//get the dojo currency code
dojo.require("dojo.currency");
//get the numeric value using parse
amount2 = dojo.currency.parse(amount1, {currency: "USD"})
//multiply
total1 = qty2 * amount2
//set total value as currency using format
XSP.getElementById('#{id:total1}').value = dojo.currency.format(total1, {currency: "USD"})
//make sure the amount is in currency format using format
XSP.getElementById('#{id:amount1}').value = dojo.currency.format(amount2, {currency: "USD"})
Xpages, hide whens formulas, and user roles
Posted by
Mark Hughes
at
8:21 AM
I needed to hide a button and since you cant simply put in @isnotmember("[Admin]";@userroles)
i had to find a different way to find out if the user was a member of that role, here is what i came up with.
//get the database
db1 = session.getDatabase("server1","database.nsf")
//get the acl
acl1 = db1.getACL()
//get the current users access
personalentry = acl1.getEntry(session.getEffectiveUserName())
//check if role is enabled
personalentry.isRoleEnabled("Admin")
this will return a true or false and calculate the hide when
i had to find a different way to find out if the user was a member of that role, here is what i came up with.
//get the database
db1 = session.getDatabase("server1","database.nsf")
//get the acl
acl1 = db1.getACL()
//get the current users access
personalentry = acl1.getEntry(session.getEffectiveUserName())
//check if role is enabled
personalentry.isRoleEnabled("Admin")
this will return a true or false and calculate the hide when
Subscribe to:
Posts (Atom)