XPage 中的嵌套表达式语言语法
Nested Expression Language Syntax in XPages
我正在重构一个模仿 Notes Client 讨论数据库的 XPage。 (别问)
我创建了一个将所有导航信息加载到树中的托管 Bean,并创建了一组访问托管 Bean 的嵌套重复控件。
我在使用折叠和展开功能时遇到问题。原作者通过访问包含下一级条目的面板来使用客户端 JavaScript。他们通过对所有内容进行硬编码来做到这一点。 1000行XML,那是。
<xp:this.script><![CDATA[collapse("#{id:repeatcontrolpanel3}]}")]]></xp:this.script>
我正在努力使它通用;我在自定义控件中设置了一个 属性 NameNestedRepeatControl,其中包含我想要 collapse/expand 的嵌套重复控件的名称,我希望这个可行:
<xp:this.script><![CDATA[collapse("#{id:#{compositeData.NameNestedRepeatControl}}")]]></xp:this.script>
但我得到了一个
javax.faces.el.MethodNotFoundException: NameNestedRepeatControl: com.ibm.xsp.binding.PropertyMap.NameNestedRepeatControl()
错误。
是否有特殊的语法,即从自定义控件的属性中获取字符串值,然后使用#{id:} 评估该字符串,或者是否有我缺少的更优雅的方法?
感谢您的帮助。
我终于通过在外面构建必要的脚本解决了这个问题。这里我有一个导航条目自定义控件,它有两个字符串属性 script_expand 和 script_collapse。
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:panel
id="outerpanel"
styleClass="NavLeftRow"
style="#{compositeData.node.styleShowOnFirstLoad}">
<xp:panel
id="innerpanel">
<xp:this.styleClass><![CDATA[#{compositeData.node.inBreadCrumbPath ? compositeData.panelStyleWhenActive : compositeData.panelStyleWhenInactive}]]></xp:this.styleClass>
<xp:image
id="imgCollapsed"
url="/xpSectionCollapsed_oneUI.gif">
<xp:this.style><![CDATA[#{compositeData.node.styleHideIfInBreadCrumb}]]></xp:this.style>
<xp:this.rendered><![CDATA[#{compositeData.node.hasChildren}]]></xp:this.rendered>
<xp:eventHandler
event="onclick"
submit="false">
<xp:this.script><![CDATA[#{javascript:compositeData.script_expand}]]></xp:this.script>
</xp:eventHandler>
</xp:image>
</xp:panel>
</xp:panel>
然后从外部调用脚本函数;我正在通过手动执行来缓解计算相关 ID 的问题。
<xp:repeat
id="repeatfourthlevelnodes"
rows="200"
var="fourthlevelnode"
value="#{thirdlevelnode.children}">
<xc:ccPanelNavigation
node="#{fourthlevelnode}">
<xc:this.script_expand>
<![CDATA[expand("#{id:repeatfifthlevelnodes}");]]>
</xc:this.script_expand>
</xc:ccPanelNavigation>
</xp:repeat>
虽然没有我希望的那么优雅,但比未分解的代码好很多。
Sven 的回答 Pass javascript code to Custom Control 真的很有帮助所以这真的应该给他!
我正在重构一个模仿 Notes Client 讨论数据库的 XPage。 (别问)
我创建了一个将所有导航信息加载到树中的托管 Bean,并创建了一组访问托管 Bean 的嵌套重复控件。
我在使用折叠和展开功能时遇到问题。原作者通过访问包含下一级条目的面板来使用客户端 JavaScript。他们通过对所有内容进行硬编码来做到这一点。 1000行XML,那是。
<xp:this.script><![CDATA[collapse("#{id:repeatcontrolpanel3}]}")]]></xp:this.script>
我正在努力使它通用;我在自定义控件中设置了一个 属性 NameNestedRepeatControl,其中包含我想要 collapse/expand 的嵌套重复控件的名称,我希望这个可行:
<xp:this.script><![CDATA[collapse("#{id:#{compositeData.NameNestedRepeatControl}}")]]></xp:this.script>
但我得到了一个
javax.faces.el.MethodNotFoundException: NameNestedRepeatControl: com.ibm.xsp.binding.PropertyMap.NameNestedRepeatControl()
错误。
是否有特殊的语法,即从自定义控件的属性中获取字符串值,然后使用#{id:} 评估该字符串,或者是否有我缺少的更优雅的方法?
感谢您的帮助。
我终于通过在外面构建必要的脚本解决了这个问题。这里我有一个导航条目自定义控件,它有两个字符串属性 script_expand 和 script_collapse。
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:panel
id="outerpanel"
styleClass="NavLeftRow"
style="#{compositeData.node.styleShowOnFirstLoad}">
<xp:panel
id="innerpanel">
<xp:this.styleClass><![CDATA[#{compositeData.node.inBreadCrumbPath ? compositeData.panelStyleWhenActive : compositeData.panelStyleWhenInactive}]]></xp:this.styleClass>
<xp:image
id="imgCollapsed"
url="/xpSectionCollapsed_oneUI.gif">
<xp:this.style><![CDATA[#{compositeData.node.styleHideIfInBreadCrumb}]]></xp:this.style>
<xp:this.rendered><![CDATA[#{compositeData.node.hasChildren}]]></xp:this.rendered>
<xp:eventHandler
event="onclick"
submit="false">
<xp:this.script><![CDATA[#{javascript:compositeData.script_expand}]]></xp:this.script>
</xp:eventHandler>
</xp:image>
</xp:panel>
</xp:panel>
然后从外部调用脚本函数;我正在通过手动执行来缓解计算相关 ID 的问题。
<xp:repeat
id="repeatfourthlevelnodes"
rows="200"
var="fourthlevelnode"
value="#{thirdlevelnode.children}">
<xc:ccPanelNavigation
node="#{fourthlevelnode}">
<xc:this.script_expand>
<![CDATA[expand("#{id:repeatfifthlevelnodes}");]]>
</xc:this.script_expand>
</xc:ccPanelNavigation>
</xp:repeat>
虽然没有我希望的那么优雅,但比未分解的代码好很多。
Sven 的回答 Pass javascript code to Custom Control 真的很有帮助所以这真的应该给他!