Server independent reference in an XPages theme

2019-01-27 14:20发布

I have the following in the theme but I want to make it server independent so that it can be moved seemlessly from deve to test to prod.

how do I genericize http://www.devserver.com?

<resource>
    <content-type>text/css</content-type>
    <href>http://www.devserver.com/CommonElements.nsf/commonMAX.css</href>
</resource>

I would assume the following - but doesn't work as it makes the reference relative to the current .nsf

<resource>
    <content-type>text/css</content-type>
    <href>/CommonElements.nsf/commonMAX.css</href>
</resource>

标签: xpages
4条回答
兄弟一词,经得起流年.
2楼-- · 2019-01-27 15:00

From an article on the Notes & Domino App Dev wiki:

"When the XPages runtime emits a URL, it assumes that the root "/" is the root of the application (e.g. /mydb.nsf). But as this notion doesn't exist in the browser, this is added by the JSF runtime. To work around this add the syntax "/.ibmxspres/domino" to the beginning of the path to set the root as the Domino data directory."

查看更多
唯我独甜
3楼-- · 2019-01-27 15:00

This works if your application is in root. ./commonMAX.css

查看更多
【Aperson】
4楼-- · 2019-01-27 15:14

In Chapter 14 of Mastering XPages there is a discussion of Themes. Beginning on page 597 there is a discussion of "Resource Paths" and the Path Aliases for three key paths:

/.ibmxspres/domino points to: /data/domino/html/

/.ibmxspres/global points to: /data/domino/java/xsp/

/.ibmxspres/dojoroot points to: /data/domino/js/dojo-1.4.3/ (or the current version of dojo)

So your block is:

<resource>
   <content-type>text/css</content-type>
   <href>/.ibmxspres/domino/CommonElements.nsf/commonMAX.css</href>
</resource>

Happy coding

/Newbs

查看更多
家丑人穷心不美
5楼-- · 2019-01-27 15:15

Another option is to investigate the XSP Starter Kit on OpenNTF.org

This will allow you to build an OSGi plugin library for XPages and one of the starter examples that you can extend in the library shows you how to create your own resourceProvider service.

Depending on how you refactor the XSP Starter Kit to your own name space you would be able add your css and other files ( common icons, logos etc ) and then you can access them using your own file path of /.ibmxspres/.yourNameSpace/file.ext. You can even build your own directory structure in the library to make managing the files easier.

One big advantage of this over storing them in a NSF is that they are cached by the end users browser whereas files served via nsf are not always cached.

Also, if the library is set as a global library on the server then you don;t need to add a dependency to the calling application, the resource provider will be available for anything that needs it.

查看更多
登录 后发表回答