A couple of (hopefully) useful notes here -
If you're creating XForms and you're using Orbeon (which is a damn fine choice if you ask me ;)), then you may want to pass params to the form at some stage:
so you call your form using something like this:
http://localhost:8080/orbeon/yourform/?id=1234&id2=5678
To get at the values you pass in, you can do the following:
- Edit the page-flow.xml file in your folder, so you have something like this:
<page path-info="*" view="view.xhtml" default-submission="/path-to-your/test.xml">
<setvalue ref="/submission/first" parameter="id"/>
<setvalue ref="/submission/second" parameter="id2"/>
</page>
Note here that the default-submission refers to a file:
default-submission="/path-to-your/test.xml"
You'll need to create that XML structure, it can have no values or you can put values in there which will act as 'defaults'.
test.xml will look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<submission>
<first/>
<second/>
</submission>
in your view.xhtml, in the model, add something like this:
<xf:instance id="my-params" src="input:instance"/>
You can now XPath into your parameters using instance('my-params')/first and so on.
If you're using Orbeon 3.7 (either a nightly build or when it's released), you have the option to use the xxforms:get-request-parameter to grab the parameters and put them into an instance. To do this, first create an empty instance in your model:
<xf:instance id="params">
<data xmlns="">
<one />
</data>
</xf:instance>
And create an action (also in the model) like this:
<xf:action ev:event="xforms-model-construct-done">
<xf:setvalue ref="instance('params')/one" value="xxforms:get-request-parameter('id')" />
</xf:action>
If you call your form with an id parameter, you should find that xf:setvalue will write that request parameter into the params instance.
Finally, it may be the case that you need to fire an XSLT transform inside the view.xhtml. I've heard warnings that this can be expensive in terms of processing, but I found that the following code worked, so thought I'd make a note here.
In the body of your XForm, a block of code like this:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<xsl:variable name="test">1234lt;/xsl:variable>
<xsl:value-of select="item[number($test)]"/>
</xsl:template>
</xsl:transform>
Will be executed by an XSLT processor. That example may be useful to someone.
Thanks go to everyone at the OPS forum http://www.nabble.com/ObjectWeb-OPS---Users-f2537.html who have been very helpful whenever I've had questions.
Friday, May 9, 2008
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2009
(23)
-
▼
June
(10)
- Daisy CMS - connecting a JMS listener to the repos...
- Daisy CMS - customising the footer of the editor p...
- Daisy CMS - allowing attributes in the SimpleDocum...
- JSF - ensuring your [xhtml] pages load with a text...
- Eclipse Galileo (3.5): Creating and running a JSF ...
- Using Eclipse Galileo to develop JSF applications ...
- SVN Web view - looking at older revisions
- Notes on setting up mod_proxy on apache 2.2 for pr...
- Addressing stability issues when running Eclipse 3...
- Forcing glassfish 2.1 to start-up with JDK1.6 (OSX...
-
►
April
(6)
- XSLT, text-transform:captialize and Excel workbook...
- Structure for Regular Expressions in Javascript
- SQL Server : Granting EXEC on Stored Procedures
- Eclipse : Save Actions for autoformatting code and...
- Eclipse : Display heap status (like IntelliJ IDEA)...
- Eclipse : Display Java Type Indicator for classes
-
▼
June
(10)
1 comments:
Thanks! You showed two techniques to solve a common problem. Both techniques were explained much more clearly and simply than the documentation does.
Post a Comment