I'm wanting to populate the header in a xf:submission with a value from the current context. Documentation says that an xpath expression can be used but doesn't provide any examples.
I've tried using xsl:value, seen below, but that doesn't populate anything. Is that the correct syntax to populate xf:value?
<p:for-each href="#attachments" select="//attachment" root="attachments" id="post-document-pages">
<p:processor name="oxf:xforms-submission">
<p:input name="submission">
<xf:submission
method="post"
resource="http://localhost:8080/is/document/{#documentId}/page"
serialization="application/octet-stream">
<xf:header>
<xf:name>Resource-Name</xf:name>
<xf:value>
<xsl:value-of select="#filename" />
</xf:value>
</xf:header>
</xf:submission>
</p:input>
<p:input name="request" href="current()" />
<p:output name="response" ref="post-document-pages" />
</p:processor>
Inside the <xf:header>, simply use:
<xf:value value="[your XForms expression here]"/>
Related
I am using orbeon-cli.jar for calling my pipeline. It's currently in version 3.8. However, during the process, my xml file has no xml comment anymore. I upgrade to orbeon 3.9 according to the announcement that "Orbeon Forms now has XML / HTML comments support in XPL and in the XForms engine." In fact it does, but in a strange way.
I simplify the process to a simple xpl file, where it only read the xml file and write it down. Here is my test:
1. I use relative path in : the output xml has xml comments, as expected.
<p:processor name="oxf:url-generator">
<p:input name="config">
<config>
<url>export.xml</url>
</config>
</p:input>
<p:output name="data" id="main-input"/>
</p:processor>
<p:processor name="oxf:xml-converter">
<p:input name="config">
<config>
<encoding>utf-8</encoding>
</config>
</p:input>
<p:input name="data" href="#main-input"/>
<p:output name="data" id="input-converted"/>
</p:processor>
<p:processor name="oxf:file-serializer">
<p:input name="config">
<config>
<file>file_written_relative_path.xml</file>
</config>
</p:input>
<p:input name="data" href="#input-converted"/>
</p:processor>
But in fact, what we need is a absolute-path in , as:
<p:processor name="oxf:url-generator">
<p:input name="config">
<config>
<url>file:///D:/path/to/file/export.xml</url>
<mode>xml</mode>
<encoding>utf-8</encoding>
<force-encoding>true</force-encoding>
<content-type>application/xml</content-type>
<force-content-type>true</force-content-type>
<handle-lexical>true</handle-lexical><!-- 'true' is the default value anyway -->
<cache-control>
<use-local-cache>false</use-local-cache>
</cache-control>
</config>
</p:input>
<p:output name="data" id="main-input-absolute"/>
</p:processor>
<p:processor name="oxf:xml-converter">
<p:input name="config">
<config>
<encoding>utf-8</encoding>
</config>
</p:input>
<p:input name="data" href="#main-input-absolute"/>
<p:output name="data" id="input-absolute-converted"/>
</p:processor>
<p:processor name="oxf:file-serializer">
<p:input name="config">
<config>
<file>file_written_absolute_path.xml</file>
</config>
</p:input>
<p:input name="data" href="#input-absolute-converted"/>
</p:processor>
To me, it seems like "url-generator" has different ways to load file in those cases. Even though I have tried all possible configs for url-generator in [2], it does not keep all comments as in [1]. Why it doesn't? Is it a bug? Is there any way to workaround? Or is there some where else it can be configured?
I'm using primefaces 3.5 with JSF mojarra 2.2.
I've a page with two ui:include which are wrapped in a p:dialog and ui:param is being used to pass values in/out of the includes.
<p:dialog header="Customer Selection Criteria" widgetVar="customerSelectionDialog" width="1200" position="center" appendToBody="true">
<h:form id="customerForm">
<p:outputPanel id="customerSelection">
<ui:include src="../INTERNAL/8500.xhtml">
<ui:param name="showCidSelect" value="1" />
<ui:param name="targetObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
</ui:include>
<p:commandButton rendered="false" value="#{COMMON.COMMON_SELECTBUTTON}" action="#{customerDetailsInquiry.tchelp.handleReturnFromCustomerSelectionCriteria}" oncomplete="customerSelectionDialog.hide();" update=":mainForm:cf8444icg1014c1002" >
<f:setPropertyActionListener value="#{customerSearchEngine}" target="#{flash.customerSearchEngine}"/>
</p:commandButton>
</p:outputPanel>
</h:form>
</p:dialog>
<p:dialog closeOnEscape="true" modal="true" appendToBody="false" header="Entity Stack" widgetVar="entityStackDialog" width="400" >
<h:form id="entityForm">
<ui:include src="../INTERNAL/StackedEntity.xhtml">
<ui:param name="displayCaption" value="CID Numbers" />
<ui:param name="department" value="8" />
<ui:param name="stackedObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
</ui:include>
</h:form>
</p:dialog>
Backing Bean:
FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
String paramValue = (String) faceletContext.getAttribute("showCidSelect");
now the problem is with "showCidSelect" parameter.
showCidSelect determines whether to show "select" button in 8500.xhtml or not.
Since "showCidSelect" in this above example is set to "1", select button should be rendered.
Without the second dialog for "StackedEntity.xhtml" this works perfectly fine.
But when i put second dialog and its ui:param's this stops working and FaceletContext getAttribute call returns null.
As of now i'm forced to include "showCidSelect" in both dialogs, then everything works fine. But i somehow feel there is some other better possible solution for this problem.
Request expert help
It actually solved the same problem here by rewriting ui:include and ui:param to a custom JSF tag in a taglib.
Then you have a nice and easy to reuse tag, like:
<widgets:showCustomerSelector targetObject="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
And:
<widgets:stackedEntity displayCaption="CID Numbers" department="8" stackedObject="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
And then add new namespace to each JSF page/template where you use it (of, course):
xmlns:widgets="http://your-company/jsf/widgets/customer"
And write a taglib:
WEB-INF/widgets.jsf.taglib.xml:
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
<namespace>http://your-company/jsf/widgets/customer</namespace>
<tag>
<tag-name>showCustomerSelector</tag-name>
<description>#TODO Document this. Here goes your 8500.xhtml You had it in INTERNAL, better put templates in e.g. WEB-INF/templates/group/sub-group/ to have it out of document-root.</description>
<source>resources/tags/show_customer_selector.xhtml</source>
<attribute>
<name>targetObject</name>
<description>#TODO Document this.</description>
<required>true</required>
<!-- #TODO Find a **WAY** better type-hint, like an interface? -->
<type>java.lang.Object</type>
</attribute>
<attribute>
<name>rendered</name>
<description>Whether this tag is being rendered by JSF engine. </description>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
</tag>
<tag>
<tag-name>stackedEntity</tag-name>
<description>#TODO Document this. Here goes your StackedEntity.xhtml - keep file names lower_under_scored to avoid case-sensitive problems!</description>
<source>resources/tags/stacked_entity.xhtml</source>
<attribute>
<name>displayCaption</name>
<description>#TODO Document this.</description>
<required>true</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>department</name>
<description>#TODO Document this.</description>
<required>true</required>
<type>java.lang.Number</type>
</attribute>
<attribute>
<name>rendered</name>
<description>Whether this tag is being rendered by JSF engine. </description>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<name>stackedObject</name>
<description>#TODO Document this.</description>
<required>true</required>
<!-- #TODO Find a **WAY** better type-hint, like an interface? -->
<type>java.lang.Object</type>
</attribute>
</tag>
</facelet-taglib>
And finally, register it in web.xml:
<context-param>
<description>JSF widget tags library</description>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/widgets.jsf.taglib.xml</param-value>
</context-param>
I'm trying to forward "f:validateRequired" validator through a composite component without using required attribute.
How to get its value inside of my component ?
<aa:myComponent id="specificNotice" value="#{edit.specificNotice}">
<f:validateRequired for="specificNotice" disabled="#{empty param['form:save']}" />
</aa:myComponent>
Thanks.
The for attribute should refer the id of the input component inside the composite component implementation. The input component in turn should be declared as <cc:editableValueHolder> inside the composite component interface.
So,
<my:input value="#{bean.input}">
<f:validateRequired for="input" />
</my:input>
with
<cc:interface>
<cc:editableValueHolder name="input" />
</cc:interface>
<cc:implementation>
<h:inputText id="input" value="#{cc.attrs.value}" />
</cc:implementation>
should do.
I get the error:
XPath syntax error at ... in {...get-request-parameter('query..}:
Cannot find a matching 1-argument function named {http://orbeon.org/oxf/xml/xforms}get-request-parameter(). Note: external function calls have been disabled
when I attempt to execute a pipeline with:
<p:processor name="oxf:xslt">
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
<TargetURL>
<xsl:variable name="location" select="/Configuration/XMLDB/Location/text()"/>
<xsl:variable name="name" select="/Configuration/XMLDB/Name/text()"/>
<xsl:variable name="query" select="xxforms:get-request-parameter('query')"/>
<xsl:value-of select="fn:concat($location,'/',$name,'?',$query)"/>
</TargetURL>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:input name="data" href="#configuration"/>
<p:output name="data" id="Target"/>
</p:processor>
Is XPL not the correct location to retrieve the HTTP request params (should I be doing it in page-flow.xml instead?)
Solved it by using the oxf:request processor in the XPL to retrieve query parameters and provide them on a separate output which is then accessed using oxf:xslt processor, like so:
<p:processor name="oxf:request">
<p:input name="config">
<config>
<include>/request/parameters/parameter[name='param1']</include>
<include>/request/parameters/parameter[name='param2']</include>
</config>
</p:input>
<p:output name="data" id="request"/>
</p:processor>
<p:processor name="oxf:xslt">
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
<TargetURL>
<xsl:variable name="var1" select="doc('input:request')/request/parameters/parameter[name='param1']/value"/>
<xsl:variable name="var2" select="doc('input:request')/request/parameters/parameter[name='param2']/value"/>
</TargetURL>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:input name="data" href="#configuration"/>
<p:input name="request" href="#request"/>
<p:output name="data" id="Target"/>
</p:processor>
xxforms:get-request-parameter() is designed to called from XForms, but you are here calling it from XSLT.
Do you really need to use XPL/XSLT in this case? In most cases, if what you are generating is a web page, you might just be able to use XForms. In your page flow, you point to your XForms with the view attribute, and in your XForms, on xforms-model-construct-done, you can access the request parameters with xxforms:get-request-parameter(), and copy their value somewhere in an instance if necessary.
This is what I have in my schema section of my WSDL to specify the field has to be comparison operators
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="<|>|<=|>=|="/>
</xsd:restriction>
</xsd:simpleType>
SoapUI complains about this part of the WSDL, I tried to set the value to something with non special characters and the WSDL is valid. So I tried to replace that whole long string to be
value=">gt;" and it valid but value="<lt;" is not valid, and value=">" is also not valid. My question is, why does the WSDL validation need > to be double escaped?
The main question is, how to provide a valid less than side within the pattern value.
This might actually be a bug in SoapUI. I tried using the following schema and XML with Apache Xalan (in Java):
Schema:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.foo.com/"
xmlns:tns="http://www.foo.com/"
elementFormDefault="qualified">
<element name="foo">
<simpleType>
<restriction base="string">
<pattern value="<|>|<=|>=|="/>
</restriction>
</simpleType>
</element>
</schema>
Sample XML:
<foo xmlns='http://www.foo.com/'>></foo>
and it validates fine. When I try this instead:
<foo xmlns='http://www.foo.com/'>abc</foo>
I get the following error, as expected: cvc-pattern-valid: Value 'abc' is not facet-valid with respect to pattern '<|>|<=|>=|=' for type '#AnonType_foo'.
My recommendation is to try using an enum instead. For example:
<simpleType>
<restriction base="string">
<enumeration value="<" />
<enumeration value=">" />
<enumeration value="<=" />
<enumeration value=">=" />
<enumeration value="=" />
</restriction>
</simpleType>
And see if SoapUI likes this better. Hope this helps!
I think I solved my own problem, why would you define in your schema that one of the allowable value is
<xsd:restriction base="xsd:string">
<xsd:pattern value="=|>|>=|<|<=|<>|[Ii][Nn]|[Nn][Oo][Tt] [Ii][Nn]|[Ll][Ii][Kk][Ee]"/>
</xsd:restriction>