将节点引用传递给 orbeon 中的模式对话框

发布于 2024-11-03 10:19:43 字数 248 浏览 0 评论 0原文

我正在尝试拥有一个 RTE 实例,并将其重用于页面上需要富文本编辑的所有控件。我有两个文本区域,当我专注于其中一个文本区域时,我想打开模式对话框,并且我想传递选定的节点引用。

示例位于 https://gist.github.com/945183

打开模式对话框很简单,但我该如何做通过参考?

谢谢 比内什·古马迪

I am trying to have one instance of RTE and reuse it for all controls on the page which require rich text editing. I have two textareas and when I focus into one of the text areas I would like to open the modal dialog and I would like to pass the selected node reference.

Example is at https://gist.github.com/945183

Opening modal dialog is simple but how do I pass the reference?

Thank you
Binesh Gummadi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笨死的猪 2024-11-10 10:19:43

正如您所做的那样,将指针传递给要作为 XPath 表达式进行编辑的节点是一个好方法。我更新了您链接到的代码:我使它变得更简单,让它工作,并粘贴了下面的结果。

或者,您可以传递要编辑的控件的 ID。然后在对话框中,将其存储在实例中,并使用 xxforms:binding() 查找绑定到该控件的节点。

<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:widget="http://orbeon.org/oxf/xml/widget"
            xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
            xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
    <xhtml:head>
        <xforms:model id="main"
                      xxforms:session-heartbeat="true"
                      xxforms:show-error-dialog="true">
            <xforms:instance id="instance">
                <dynamic>
                    <textarea1>Area1</textarea1>
                    <textarea2>Area2</textarea2>
                    <selectedNode/>
                </dynamic>
            </xforms:instance>
        </xforms:model>
    </xhtml:head>

    <xhtml:body class="body">

        <xforms:input ref="textarea1">
            <xforms:label>Text Area 1</xforms:label>
        </xforms:input>
        <fr:button>
            <xforms:label>Edit</xforms:label>
            <xforms:action ev:event="DOMActivate">
                <xforms:setvalue ref="selectedNode" value="context()/textarea1/saxon:path()"/>
                <xxforms:show dialog="hello-dialog"/>
            </xforms:action>
        </fr:button>

        <xhtml:br/>

        <xforms:input ref="textarea2">
            <xforms:label>Text Area 2</xforms:label>
        </xforms:input>
        <fr:button>
            <xforms:label>Edit</xforms:label>
            <xforms:action ev:event="DOMActivate">
                <xforms:setvalue ref="selectedNode" value="context()/textarea2/saxon:path()"/>
                <xxforms:show dialog="hello-dialog"/>
            </xforms:action>
        </fr:button>

        <xxforms:dialog id="hello-dialog">
            <xhtml:div>
                <xforms:textarea mediatype="text/html"
                                 ref="if (selectedNode != '') then saxon:evaluate(selectedNode) else ()"/>
            </xhtml:div>
        </xxforms:dialog>

    </xhtml:body>

</xhtml:html>

Passing a pointer to the node to edit as an XPath expression, as you did, is a good way to go. I updated the code you were linking to: I made it a bit simpler, got it to work, and pasted the result below.

Alternatively, you could pass the id of the control you want to edit. Then in the dialog, store this in an instance, and uses xxforms:binding() to find the node bound to that control.

<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:widget="http://orbeon.org/oxf/xml/widget"
            xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
            xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
    <xhtml:head>
        <xforms:model id="main"
                      xxforms:session-heartbeat="true"
                      xxforms:show-error-dialog="true">
            <xforms:instance id="instance">
                <dynamic>
                    <textarea1>Area1</textarea1>
                    <textarea2>Area2</textarea2>
                    <selectedNode/>
                </dynamic>
            </xforms:instance>
        </xforms:model>
    </xhtml:head>

    <xhtml:body class="body">

        <xforms:input ref="textarea1">
            <xforms:label>Text Area 1</xforms:label>
        </xforms:input>
        <fr:button>
            <xforms:label>Edit</xforms:label>
            <xforms:action ev:event="DOMActivate">
                <xforms:setvalue ref="selectedNode" value="context()/textarea1/saxon:path()"/>
                <xxforms:show dialog="hello-dialog"/>
            </xforms:action>
        </fr:button>

        <xhtml:br/>

        <xforms:input ref="textarea2">
            <xforms:label>Text Area 2</xforms:label>
        </xforms:input>
        <fr:button>
            <xforms:label>Edit</xforms:label>
            <xforms:action ev:event="DOMActivate">
                <xforms:setvalue ref="selectedNode" value="context()/textarea2/saxon:path()"/>
                <xxforms:show dialog="hello-dialog"/>
            </xforms:action>
        </fr:button>

        <xxforms:dialog id="hello-dialog">
            <xhtml:div>
                <xforms:textarea mediatype="text/html"
                                 ref="if (selectedNode != '') then saxon:evaluate(selectedNode) else ()"/>
            </xhtml:div>
        </xxforms:dialog>

    </xhtml:body>

</xhtml:html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文