XPage 中的嵌套表达式语言语法 [英] Nested Expression Language Syntax in XPages

查看:21
本文介绍了XPage 中的嵌套表达式语言语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重构一个模仿 Notes Client 讨论数据库的 XPage.(别问了)

I'm refactoring an XPage which mimics the Notes Client discussion database. (Don't ask)

我创建了一个托管 Bean,它将所有导航信息加载到树中,并创建了一组访问托管 Bean 的嵌套重复控件.

I've created a Managed Bean which loads all the navigation information into a tree, and created a set of nested repeat controls that access the managed bean.

我在折叠和展开功能方面遇到了问题.原作者通过访问包含下一级条目的面板来使用客户端 JavaScript.他们通过对所有内容进行硬编码来做到这一点.1000 行 XML,就是这样.

I'm having issues with the collapse and expand functions. The original authors use Client Side JavaScript by accessing the panel containing the entries which are one level under. They did this by hardcoding everything. 1000 lines of XML, that was.

<xp:this.script><![CDATA[collapse("#{id:repeatcontrolpanel3}]}")]]></xp:this.script>

我正在尝试使这个通用;我在自定义控件中设置了一个属性 NameNestedRepeatControl,其中包含我想要折叠/展开的嵌套重复控件的名称,我希望这会起作用:

I'm trying to make this generic; I've set up a property NameNestedRepeatControl in the custom control which contains the name of the nested repeatcontrol which I want to collapse/expand, and I was hoping that this would work:

<xp:this.script><![CDATA[collapse("#{id:#{compositeData.NameNestedRepeatControl}}")]]></xp:this.script>

但我得到了一个

javax.faces.el.MethodNotFoundException: NameNestedRepeatControl: com.ibm.xsp.binding.PropertyMap.NameNestedRepeatControl()

错误.

是否有一个特殊的语法,即从自定义控件的属性中获取一个字符串值,然后让该字符串使用#{id:} 进行评估,或者是否有我缺少的更优雅的方法?

Is there a special syntax for this, i.e. get a string value from the custom control's properties, then let that string be evaluated with #{id:}, or is there an even more elegant method that I'm missing?

感谢您的帮助.

推荐答案

我最终通过在外部构建必要的脚本解决了这个问题.这里我有一个导航条目自定义控件,它有两个字符串属性:script_expand 和 script_collapse.

I finally solved this issue by constructing the necessary script outside. Here I have a Navigation Entry Custom Control which has two String properties of script_expand and 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 的问题.

And the script function gets called from outside; I'm alleviating the problem of calculating the relevant ID by just doing it manually.

<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>

不像我希望的那么优雅,但比未分解的代码要好得多.

Not quite as elegant as I had hoped, but a lot better than the unfactored code.

这是 Sven 的回答 将 javascript 代码传递给自定义控件,这确实有帮助这真的应该给他!

It's Sven's answer Pass javascript code to Custom Control which really helped so this should really go to him!

这篇关于XPage 中的嵌套表达式语言语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆