SSJS用于主题中的资源href

时间:2012-08-16 03:43:25

标签: themes xpages

我们有多个应用程序共享主题的单个css。因此,我们希望将这些常见的CSS和资源移动到公共数据库中,并动态地在主题中引用它们。

我可以使用以下硬编码路径来引用这些css:

<resource>
    <content-type>text/css</content-type>
    <href>/.ibmxspres/domino/common/designstore.nsf/custom_layout.css</href>
</resource>

这种方式工作正常。但我们想从配置中获取数据库路径。因此'/common/designstore.nsf'路径不必在主题中进行硬编码。

我尝试将sessionstore数据库路径放在sessionScope变量的XpageRenderResponse之前。并在主题中引用范围var。

<resource>
    <content-type>text/css</content-type>
    <href>#{sessionScope.commonCSSPath}</href>
</resource>

其中sessionScope.commonCSSPath =“/。ibmxspres / brain /common / designstore.nsf / custom_layout.css”

如果我们可以使用计算路径计算资源中的数据库路径或任何其他方式从其他数据库引用CSS文件,请告诉我。

提前谢谢。

1 个答案:

答案 0 :(得分:1)

尝试使用Javascript而不是EL来计算href值:

<resource>
    <content-type>text/css</content-type>
    <href>#{javascript:sessionScope.commonCSSPath}</href>
</resource>

我不确定beforeRenderResponse的时间和主题何时启动,可以引用sessionScope变量。让我们知道它是怎么回事。

-

更新:

我在主题中使用以下内容来确定字段的呈现属性并且它可以工作:

<control>
    ...
    <property>
        <name>rendered</name>
        <value>#{javascript:document.isEditable()}</value> 
    </property>
</control>

我还使用一个函数来确定value属性,其中函数是一个SSJS函数,用于在配置文件中查找值:

<control>
    ...
    <property>
        <name>value</name>
        <value>#{javascript:getNecessaryValue("SetupProfile", "fieldWithValue")}</value> 
    </property>
</control>

希望这可以激励你实现你想要的目标。