Use runtime optimzed JS and CSS resources in XSP Properties causes error - xpages

In XPages I have enabled the "Use runtime optimized JS and CSS resources" but it raises and error:
inputmask is not a function.
I have loaded the script as followed:
<xp:this.resources>
<xp:script
src="/inputmask/jquery.inputmask.bundle.js"
clientSide="true">
</xp:script>
</xp:this.resources>
It works fine when I have the XSP property disabled.
How can I solve this?

can you just add the library as a normal script reference? e.g.
<script src="inputmask/jquery.inputmask.bundle.js" type="text/javascript"></script>
then it will be loaded as a separate file

Related

Configuration of the javascript library docxtemplater in XPages

I'm trying to use the library docxtemplater in an XPages application.
Javascript library docxtemplater (https://docxtemplater.com/) use as a
dependency another library opensource jszip-utils.js
(http://stuk.github.io/jszip/) to zip and unzip the docx files.
The problem is that the javascript library jszip-utils.js in XPages is not
working .
I inserted javascript libraries in a folder (jslib) who is under the WebContent folder.
Here's my test page;
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<script src="jslib/main.min.js"></script>
<script src="jslib/angular-expressions.js"></script>
<script src="jslib/jszip.js"></script>
<script src="jslib/jszip-utils.js"></script>
<script src="jslib/FileSaver.min.js"></script>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[
var loadFile=function(url,callback){
JSZipUtils.getBinaryContent(url,callback);
}
loadFile("tagExample.docx",function(err,content){
doc=new DocxGen(content)
doc.setData( {"first_name":"Hipp",
"last_name":"Edgar",
"phone":"0652455478",
"description":"New Website",
"image":'image.png'
}
) //set the templateVariables
doc.render() //apply them (replace all occurences of {first_name} by Hipp, ...)
out=doc.getZip().generate({type:"blob"}) //Output the document using Data-URI
saveAs(out,"output.docx")
})]]></xp:this.script>
</xp:eventHandler></xp:button>
</xp:view>
Has anyone dealt with the problem?
It is an AMD loader issue. It conflicts with XPage's Dojo.
Use this XSnippet for workaround.
Your code would look like this then:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<!-- temporary redefine define.amd object (Dojo AMD loader) -->
<xp:script clientSide="true" type="text/javascript">
<xp:this.contents><![CDATA[${javascript:"if (typeof define === 'function' && define.amd) {if(define.amd.vendor =='dojotoolkit.org'){define._amd = define.amd;delete define.amd;}}";}]]></xp:this.contents>
</xp:script>
<xp:script src="jslib/jszip.js" clientSide="true"></xp:script>
<xp:script src="jslib/jszip-utils.js" clientSide="true"></xp:script>
...
<!-- restore define.amd object (Dojo AMD loader) -->
<xp:script clientSide="true">
<xp:this.contents><![CDATA[${javascript:"if (typeof define === 'function' && define._amd) {define.amd = define._amd; delete define._amd;}"}]]></xp:this.contents>
</xp:script>
</xp:this.resources>
...
When you look at firebug in your web page, you most likely will see 404 for the JavaScript. You need to either add them as script libraries into xpages and use the xpages script tag with the client attribute or you add them to the web-inf directory and load them using your script tags. You still will need an client side event to trigger them.
Just refer the below java script in your html page.
<script src="http://kendo.cdn.telerik.com/2016.1.112/js/jszip.min.js"></script>

Xpages Debug Toolbar overrides my bootstrap UI

I've just started using Mark Leuksink's XPages Debug Toolbar (along with his Bootsrap4Xpages plugin). The Toolbar works well, but my Bootstrap UI has been overridden.
I've tried setting disableTheme="true", but no bananas. I've inserted the debug Toolbar just under the resources tag of my appLayout Custom Control.
Is there something I can do about this?
I'm using OpenNTF Bootstrap Library for XPages 1.0.0.201407020945 and XPages Debug Toolbar 1.0.0.20143092102
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex"
xmlns:bx="http://www.openntf.org/xsp/bootstrap"
viewState="fulltree"
xmlns:xc="http://www.ibm.com/xsp/custom"
xmlns:debug="http://www.openntf.org/xsp/debugtoolbar">
<xp:this.resources>
<xp:script
src="/commonjavascript.jss"
clientSide="false">
</xp:script>
</xp:this.resources>
<debug:toolbar
defaultCollapsed="false"
collapseTo="left"
disableTheme="true"
autoRemove="true">
</debug:toolbar>
Ohhh. Duuh. Major Dunce Cap.
Under XSP Properties, Theme defaults, Application theme, the bootstrap theme was no longer correctly inputted.
Per and Oliver, sorry for that!
Feeling sheepish right now.

Has anyone successfully implemented the dojox.mobile.carousel in XPages

I have a requirement for an application in a Domino version 9.x deployment for a carousel like interface similar to what Netflix and others use to allow continuous scrolling. I got the jQuery jCarousel code working from here. But that lacks the pizzazz the user wants since the swiping feature is not available. I also used 100% computed HTML instead of being able to intersperse XPages controls within the carousel code.
So I found dojox/mobile/carousel (examples here) but all implementations, including the basic examples are not working well. The number of elements does not seem to be flexible and the positioning of them is much lower than I would think the should be. I fiddled with the CSS to see if I could fix things but have not found the right combination.
Here is the entire custom control I am using for this test (I captured the images from the demo and added them as image resources):
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
dojoParseOnLoad="true">
<xp:this.resources>
<xp:metaData
name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
</xp:metaData>
<xp:metaData
name="apple-mobile-web-app-capable"
content="yes">
</xp:metaData>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/mobile/themes/iphone/iphone.css">
</xp:styleSheet>
<xp:dojoModule
name="dojox/mobile"></xp:dojoModule>
<xp:dojoModule
name="dojox/mobile/parser"></xp:dojoModule>
<xp:dojoModule
name="dojox/mobile/Carousel"></xp:dojoModule>
</xp:this.resources>
<xp:panel>Above it</xp:panel>
<div
id="carousel1"
data-dojo-type="dojox/mobile/Carousel"
data-dojo-props='height:"150px", navButton:false, numVisible:2, title:"Category"'>
<!-- View #1 -->
<div
data-dojo-type="dojox/mobile/SwapView">
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"dish1.jpg", value:"dish", headerText:"dish"'></div>
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"glass1.jpg", value:"glass", headerText:"glass"'></div>
</div>
<!-- View #2 -->
<div
data-dojo-type="dojox/mobile/SwapView">
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"stone1.jpg", value:"stone", headerText:"stone"'></div>
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"shell1.jpg", value:"shell", headerText:"shell"'></div>
</div>
</div>
<xp:panel>Below it</xp:panel>
</xp:view>
in the sample in the documentation it has this comment followed by the inclusion of a JavaScript file.
<!-- Need to load the theme files for Carousel and PageIndicator as well as the base theme file -->
<script type="text/javascript" src="dojox/mobile/deviceTheme.js"
data-dojo-config="mblThemeFiles: ['base','Carousel','PageIndicator']"></script>
Not having this step done may be my problem but I cannot see how to do that within the XPages environment.
The dojo carousel exists since 1.7 Notes 8.5.3 comes with 1.6 (i dont know the dojo version of Notes9), so you maby have to update your dojo or implement a newer dojo lib in your application.
I did a short experiment on it, i disabled the build in dojo adding xsp.client.script.libraries=none to my xsp.properties and importet the dojo 1.9 in my application under WEB-INF/dojo/... then add the dojo to my xPage as ClientSide script resource. As soon i finished this the programatic Example from the dojo homepage worked immediately with out bigger errors (forgot to change the image sources =) ..).
The problem when adding xsp.client.script.libraries=none to your xsp.properties is that you also disable the XSP. library and some other xPage features wich you have to rebuild using the newer dojo version.
I realy prefer using dojo over jquery but in this case If you dont want to update your dojo i recomend you to maby stay at the jquery Library for this or look for other solutions.

XPages Extension Library: namepicker not working

Is there any issue with namepicker of Extension Library version 9.0.0.v00_01_20130415-0518?
It does not display popup window for address book, here is my code:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:panel>
<xp:panel>
<xe:namePicker id="namePicker1" for="djName">
<xe:this.dataProvider>
<xe:dominoNABNamePicker addressBookDb="names.nsf" addressBookSel="all">
</xe:dominoNABNamePicker>
</xe:this.dataProvider>
</xe:namePicker>
<xp:br></xp:br>
<xp:br></xp:br>
<xe:djextNameTextBox id="djName" multipleSeparator="," multipleTrim="true">
</xe:djextNameTextBox>
</xp:panel>
</xp:panel>
</xp:view>
And also, I have manager's rights on names.nsf database.
Edit:
strange behavior! I change <xe:djextNameTextBox control to <xp:inputText and its works fine. How to debug xe:djextNameTextBox control to figure out the problem?
Edit 2:
Following error display when xsp page load:
Uncaught Error: Could not load 'dijit.form._FormValueWidget'; last tried '../dijit/form/_FormValueWidget.js' dojo.js:14
dojo._loadModule.dojo.require dojo.js:14
(anonymous function) #Fi&#Ez&#EOf&#Ek.js:107
Uncaught Error: Could not load class 'extlib.dijit.NameTextBox #Fi&#Ez&#EOf&#Ek.js:20
(anonymous function) #Fi&#Ez&#EOf&#Ek.js:20
$DBrH_ dojo.js:14
$DBpd_ #Fi&#Ez&#EOf&#Ek.js:20
$DBpe_ #Fi&#Ez&#EOf&#Ek.js:20
_4c #Fi&#Ez&#EOf&#Ek.js:20
dojo.loaded dojo.js:14
dojo._callLoaded dojo.js:14
dojo._modulesLoaded dojo.js:14
dojo._loadInit
After page load, when I click on name picker button another error display:
Uncaught TypeError: Object # has no method 'selectValue'
Your xe:djextNameTextBox control is not bound to a value. Try binding to e.g. a viewScope variable or a field on a document datasource:
<xe:djextNameTextBox id="djName" value="#{viewScope.nameField}" multipleSeparator="," multipleTrim="true">
</xe:djextNameTextBox>
Notes/Domino 9 now comes with Extension Library built in as standard. You do not need to install the extlib from OpenNTF.
I tested your source code in a default install of Notes 9. I get the following output:
Clicking the icon gets me this (I added the Admin + clicked OK).
The output of the page is now this:
My observation are below:
I uninstall Extension Library version 9.0.0.v00_01_20130415-0518 and upgrade to 900v00_02.20130515-2200, but the problem did not resolved. Then I install 8.5.3.20130315-0724 after uninstalling version 900v00_02.20130515-2200 and it works.
One more thing is that, at first after installing version 8.5.3.20130315-0724 it did not work in chrome browser (which was already opened on my laptop) then I open firefox and surprisingly it shows the address book, I mean that xe:djextNameTextBox control works with name picker control as expected. Then I switch to Chrome and clear all the history and reload the page .....!!! yes its work here too.
I repeat all the above stuff for Extension Library version 9.0.0.v00_01_20130415-0518 and Extension Library version 9.0.0.v00_01_20130415-2200 but xe:djextNameTextBox control not working with that versions.
-mak

xapges navigator not showing

Another hopefully simple issue from an xpages beginner.
I am trying to use the Navigator control from the Extension Library. No matter what I do with it, I cannot get it to render on any of the pages I try it on. Code is below. Thanks for any assistance.
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xe:navigator id="outline" expandable="true">
<xe:this.treeNodes>
<xe:pageTreeNode page="/bcbsarequirements.xsp" selection="/bcbsarequirements" label="BCBSA Requirements" role="navigation"/>
<xe:pageTreeNode page="/compliance.xsp" selection="/compliance" role="navigation" label="Compliance"/>
<xe:pageTreeNode page="/finance.xsp" selection="/finance" label="Finance" role="navigation"/>
</xe:this.treeNodes>
</xe:navigator>
</xp:view>
This will happen at least if your view tag is missing the extension library attribute. Make sure the view tag looks like this: <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">. If the attribute is missing there is an error visible in the source.
Make sure there is no error in XPage source.
Make sure the application is built (sometimes project -> clean is needed).
Make sure extension library is checked in application properties (you should get errors if not).
Check for any error messages in the server console/log when loading the XPage on browser.
Do other extension library controls render for you? If not there is a problem in ExtLib installation.
Make sure your Designer and server have the same and preferably the latest (20121217) ExtLib version.
If you are using the Upgrade Pack then you can open an SPR with IBM.

Resources