How can I add locale to a resource in an XPages theme? - xpages

I am trying to add a local for the date picker and I have the following code in my XPages theme
<resource>
<content-type>application/x-javascript</content-type>
<href>#{javascript:return "js/jquery-ui.datepicker_"+view.getLocale()+".js"}</href>
</resource>
unfortunately this gets passed straight through to the browser as a string
< script type="text/javascript" src="whatever.nsf/#%7Bjavascript:return%20%22js/jquery-ui.datepicker_%22+view.getLocale()+%22.js%22%7D" >
How can I get the EL to work? And for that matter because it is in the theme can it even tell at that point what the locale() is ?

First, I'd recommend using the <resources/> syntax instead. Secondly, instead of a single SSJS expression, try a mixed expression using just standard EL:
<resources>
<script clientSide="true" src="/js/jquery-ui.datepicker_#{view.locale}.js" />
</resources>

Related

XPages - Bootstrap Customization Affects valuePicker Behaviour

Without Customization - valuePicker works fine
https://serveragi12.agi-imc.de/BootstrapTest.nsf
With Customization (modified bootstrap.min.css as resource in Theme) - valuePicker not working
https://serveragi12.agi-imc.de/BootstrapTestCustomized.nsf
Compare the button appearance for the two cases, background-color for btn-warning modified and taking effect.
MORE INFO:
The only difference is that in the customized case the backround-color of a button was modified in the bootstrap.min.css, and that bootstrap.min.css was then referenced as a resource in the theme.
It is strange that changing of a background-color can affect the functioning of a valuePicker.
THEME CODE (for BootstrapTestCustomized):
<theme extends="Bootstrap3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="platform:/plugin/com.ibm.designer.domino.stylekits/schema/stylekit.xsd">
<resource>
<content-type>text/css</content-type>
<href>/css/bootstrap.min.css</href>
<media>screen</media>
</resource>
</theme>

XPages favicon with oneui theme

I want to set a favicon in XPages. I am using Domino 8.5.3 with the latest 8.5.x version of the extlib. As application theme oneuiv2.1 is used.
I tried setting the pageIcon attribute in the XPage without success. Adding a link attribute to the header using
<xp:this.resources>
<xp:headTag tagName="link" rendered="true" loaded="true">
<xp:this.attributes>
<xp:parameter name="rel" value="icon"></xp:parameter>
<xp:parameter name="href" value="favIcon.png">
</xp:parameter>
<xp:parameter name="type" value="image/png">
</xp:parameter>
</xp:this.attributes>
</xp:headTag>
</xp:this.resources>
did not change the favicon. I found in various blogs, that I have to add a control to the application theme, for example:
<control>
<property>
<name>pageIcon</name>
<value>favicon.ico</value>
</property>
</control>
However I use the provided oneUi theme and do not want to create a custom theme. Is there a way to either set the favicon directly or modify the theme without creating a complete new one?
I think you are missing the control name in your theme rule.
Here is the syntax of the theme rule that works for me. (Taken from Tim Tripcony's HowYaBean demo application referenced on NotesIn9 and downloadable from here). I use it a ton. It takes the icon from the NotesDatabase (remember the one from the old Notes workspace that has not yet been pried out of my cold dead fingers). It also works with image or file resources.
<control override="false">
<name>ViewRoot</name>
<property>
<name>pageIcon</name>
<value>/$icon</value>
</property>
<property>
<name>pageTitle</name>
<value>#{database.title}</value>
</property>
</control>
This works for me - icon shows in tab bar and shortcut created from application URL.
Image resource (PNG image) with name img_ApplicationIcon16. The name is generic for every application, but each NSF contains different image.
Every XPage has property pageIcon="/img_ApplicationIcon16"
It renders as <link rel="SHORTCUT ICON" href="/path/database.nsf/img_ApplicationIcon16">
In my case, I did not want to use theme, too.
Import the favicon.ico file as file resource instead of image resource
Add the following code to the selected theme:
<control>
<name>ViewRoot</name>
<property>
<name>pageIcon</name>
<value>/favicon.ico</value>
</property>
</control>
Set up the application to use the theme containing the reference for the favicon.
Create a new xpage for testing, or delete the browser cache.
This works for me properly. In the browser window you should see the folloving source:
<link rel="SHORTCUT ICON" href="/db.nsf/favicon.ico">
(db.nsf is your database.)
If still not work check the xpage: "All properties-styling-disableTheme" should not be enabled.

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 theme add script library to a scpecific XPage

All my XPages apart from "DefaultLogin.xsp" have a resource of xpServerSide added to them, but wondered if there was a way to add this resource via the theme?
you can add resources to your theme like this:
<theme extends="whatever">
<resources>
<bundle src="prop.properties" var="strings"></bundle> <!-- propertie example -->
<dojoModule name="extlib.dijit.ExtLib"></dojoModule><!-- dojo module example -->
<script src="/whatever.js" clientSide="true"></script><!-- scriptlibray example -->
</resources>
....
...
</theme>
This will add your script, properties or dojoModule to all your XPages if this theme is selected.
You can also extend this by adding a rendered attribute to the <resource> tag. to load it only on special conditions. e.g.:
<resource rendered="#{javascript:context.getUserAgent().isFirefox()}">
<content-type>text/css</content-type>
<href>stylesFF.css</href>
</resource>

SharePoint DelegateControl Render Order

I have two SharePoint features, each implemented identically (see below), that add controls to a delegate control in the header of my pages. One of the controls depends on the other (one is the jQuery library, and the other depends upon jQuery), however, when the controls are rendered, the order of the controls is incorrect. How do I specify the order that these controls are rendered in?
The control (both are identical, except that they reference a different .js file):
<%# Control ClassName="MyScriptControl" %>
<script type="text/javascript" src="/_layouts/MyScript.js"></script>
feature.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="AA9D59AC-D53E-4338-9B52-CD39F2A8C31A"
ActivateOnDefault="true"
Title="My Feature"
Description="Does something."
Scope="Site" Version="1.0.0.0"
Hidden="FALSE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="MyFeature\Elements.xml" />
</ElementManifests>
</Feature>
Elements.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"
Id="24A4BB9A-9636-4a73-B3A5-35661DE19902">
<Control Id="AdditionalPageHead"
ControlSrc="~/_controltemplates/MyControl.ascx" />
</Elements>
The output on the page (jQuery is deployed before DependsOnjQuery):
<script type="text/javascript" src="/_layouts/DependsOnjQuery.js"></script>
<script type="text/javascript" src="/_layouts/jQuery.min.js"></script>
I want MyControl1.js to render before MyControl2.js.
I was able to get this to work by adding a second DelegateControl to the header of my masterpage, and adding jQuery to that delegate. This way, I can make sure that jQuery will always load before everything else, without having to write some logic to delay the loading of my dependant libraries.
<SharePoint:DelegateControl runat="server" ControlId="jQueryDelegate" AllowMultipleControls="true"/>
<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>
It looks to me like the Sequence attribute can be used to control the order in which these guys are rendered. Give your jQuery control a sequence of 50 and your DependsOnjQuery control a sequence of 100 and you should be good.
See the Delegate Control documentation on MSDN for more info.
did you try and set the DEFER="DEFER" attribute on the script.
that would tell the user agent that the script should wait for the page to load and render before it loads the script.
Else you could hack it by setting a variable at the one script, that is set to true when script is loaded. In the other you placed logic that tested (think loop and timeout method) if the script was loaded and then calls your logic when both scripts are loaded.
not very nice, but you need some kind of logic to handle execution, and not just run the methods inline in your script.
To nathan: sequences in delegates are used to determine which of the delegate controls to load. This should have nothing to do with the issue in question. As i understand it the JS files just set the value on a script that just happens to be a delegate control.

Resources