Posted in XPages

Use Keyboard Right/Left to Navigate pager in xPages

add this scriptblock in your page to enable the keyboard left and right keys when you want to move around the view.

<xp:scriptBlock>
<xp:this.value><![CDATA[var pagerID = “#{id:pager1}”; // <– Enter the ID of the pager control here which would change based on left / right arrow keys

pagerID = pagerID.replace(/:/g, “\\3A”);
dojo.connect(document.body, “onkeydown”,
function(evt) {
switch (evt.keyCode) {
case dojo.keys.LEFT_ARROW:
evt.preventDefault();
var previousLink = dojo.query(“#” + pagerID + ” .xspPagerNav.xspPrevious a”)[0];
if (previousLink != null) {
previousLink.click();
}
break;
case dojo.keys.RIGHT_ARROW:
evt.preventDefault();
var nextLink = dojo.query(“#” + pagerID + ” .xspPagerNav.xspNext a”)[0];
if (nextLink != null) {
nextLink.click();
}
break;
}
}
);]]></xp:this.value>
</xp:scriptBlock>

Posted in XPages

How to Append and Prefend using Javascript in xPages

create a function like this on your page

function addToList(thisdoc:NotesXspDocument, fieldname:string, newVal:string, atype:string) {
var newArr = new Array(thisdoc.getItemValue(fieldname));
switch (atype) {

case ‘append’:
newArr.push(newVal);
break
case ‘prepend’:
newArr.unshift(newVal);
break
}
thisdoc.replaceItemValue(fieldname, newArr);
return true;
}

And to use the function:

addToList(document, “foo”, “blah”, “append”)