Xpages and nice buttons using css

On February 20, 2009, in Uncategorized, by Mark Hughes

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

 

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”})

 

Xpages, hide whens formulas, and user roles

On February 20, 2009, in Uncategorized, by Mark Hughes

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

 

here is the serverside script i run to send the email from a button, wouldnt it be great to be able to use @mailsend and return a http link? The plus side is i can put in html content this way and format it to my hearts content.

db1 = session.getDatabase(“notes1/rcc”,”Applications\\database.nsf”)
doc1 = db1.createDocument()
doc1.appendItemValue(“Form”,”Memo”)

var1 = “Employee: ” + @Text(dominoDocument1.getItemValueString(’employeename’))

var2 = “Craft: ” + dominoDocument1.getItemValueString(‘craft’)

var3 = “html tags” +
var1 + “breaktag” +
var2 + “breaktag” +
“a reflink tag + link ” +
dominoDocument1.getDocument().getUniversalID()+”‘> Link

+ “close html tags”


body = doc1.createMIMEEntity()
subject = body.createHeader(“Subject”)
subject.setHeaderVal(“subject”)

stream = session.createStream()
stream.writeText(var3)

body.setContentFromText(stream, “text/html; charset=iso-8859-1”, 0)

doc1.send(“group or persons name”)

 

I needed a type ahead for a field and needed it to work for about 6400 items in a view in another database. @DbColumn would return the value “Infinity” in a combobox, it would return nothing in the type ahead computed area. I am guessing the 64kb thing, but dont know for sure. So i decided to filter of a filter.

in the computed value of the type ahead i get the current field value

key1 = dominoDocument1.getItemValueString(‘vendor’)

Then i do a lookup on that value with a @dblookup command with partial match turned on.

db1 = new Array(“notes1″,”Applications\\vendors.nsf”)

@DbLookup(db1, “PickList”,@UpperCase(@Text(key1)), 1 ,”[PARTIALMATCH]”)

I am guessing this has to do with how this function is implemented, getting the entire column and then doing a lookup on it, instead of doing a lookup on the column to begin with.