Passing node reference to modal dialog in orbeon
I am trying to have one instance of RTE and reuse it for all controls on the开发者_C百科 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
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>
精彩评论