I am trying to use BIRT 2.5.0 to generate a pdf file. BIRT is called from pHp (this is done thanks to JavaBridge and a Tomcat server).
And I am simply trying to create a checkbox, checked under certain conditions.
I looked a bit on the internet and found 2 different ways to do it.
The first way is to play with the Visibility if the field "idclassebillet" (on which I am making the test) has a value of 1. I did it this way :
<image id="9010">
<list-property name="visibility">
<structure>
<property name="format">all</property>
<expression name="valueExpr" type="javascript">row["classEq1"]</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"] == 1</expression>
<property name="dataType">boolean</property>
</structure>
</list-property>
<property name="source">embed</property>
<property name="imageName">checkbox_unchecked.png</property>
</image>
But this doesn't work.
So the second solution that I found was to play with a simple URL. This solution is much more convenient, but doesn't work neither. This would looks like that.
<image id="9018">
<property name="source">url</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<expression name="uri" type="javascript">
if(row["classEq1"] == 1)
"http://my.server.com/checkbox_checked.png"+row["classEq1"];
else
"http://my.server.com/checkbox_unchecked.png"+row["classEq1"];
</expression>
</image>
In both cases, I declare the field "dataSetRow["idfield"]" like that :
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="infoBordereau" id="178">
<structure name="cachedMetaData">
<list-property name="resultSet">
...
<structure>
<property name="position">9</property>
<property name="name">idclassebillet</property>
<property name="dataType">integer</property>
</structure>
...
</structure>
<property name="dataSource">GestionBillet</property>
<list-property name="resultSet">
...
<structure>
<property name="position">8</property>
<property name="name">idclassebillet</property>
<property name="nativeName">idclassebillet</property>
<property name="dataType">integer</property>
</structure>
...
</list-property>
....
</oda-data-set>
</data-sets>
I checked that I can access to the content of "idclassebillet". If I simply print it this way, it works fine :
<data id="90060001">
<property name="whiteSpace">nowrap</property>
<property name="dataSet">infoBordereau</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<property name="resultSetColumn">classEq1</property>
</data>
And whatever the solution I choose to get my "dynamic" images, I always get the same image, whatever the value of "dataSetRow["idclassebillet"]" is.
I have no problem accessing and printing the image. The problem is more to "test" the value of the "idclassebillet" field (ie. how can I access this field ?).
I hope that you understand what I am trying to do. If you have a better solution (and if possible an example of working code), don't hesitate to share ^^ :)
Many thanks,
Raphaƫl POITTEVIN
NB : At first, I wanted my images to be embedded in the document (this what I use in the first solution), but as this didn't worked, I used an images hosted on http://my.server.com ...
If your objective is to display an unchecked/checked checkbox, have you considered using the Wingdings font with characters 0xA8 and 0xFD or 0xFE?
Related
My configuration is like below:
I am using SpEL inside router to get values from map.
<util:map id="routeConfig">
<entry key="Default" value="not configured" />
<entry key="GB22XXX" value="LON" />
<entry key="AEADXXX" value="ME" />
<entry key="HBXXXX" value="ME" />
<entry key="EBHBXBAO" value="ME" />
</util:map>
<router input-channel="InputRoutingChannel" default-output-channel="testOutputChannel" expression="#routeConfig.get('payload.getMsgHeader().getSourceSystem().substring(4, 12)')">
<mapping value="LON" channel="MarshallerOutputChannel_lonme" />
<mapping value="ME" channel="MarshallerOutputChannel_me" />
</router>
Your issue is here:
expression="#routeConfig.get('payload.getMsgHeader().getSourceSystem().substring(4, 12)')
Since you get deal with runtime Message you really don't need to wrap to the literal. Hence an answer to you is:
expression="#routeConfig.get(payload.msgHeader.sourceSystem.substring(4, 12))
How is it possible to add entry to dictionary, defined in parent object, from the child object?
*UPDATED
I edit my config as follows:
<object id="ParentType" singleton="false" type="SomeType">
<property name="FieldNameMap">
<dictionary key-type="string" value-type="string" >
<entry key="Title" value="TitleName"/>
</dictionary>
</property>
</object>
<object id="ChildType" singleton="false" type="SomeType" parent="ParentType">
<property name="FieldNameMap">
<dictionary merge="true">
<!-- this entry should be added to, not replace the whole Dictionary -->
<entry key="Position" value="PositionName"/>
</dictionary>
</property>
</object>
but, unfortunately, it now throws cast exception:
Cannot convert property value of type
[System.Collections.Specialized.HybridDictionary] to required type
[System.Collections.Generic.IDictionary`2[[System.String,
],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]]
I haven't tried this myself, but according to the docs, spring.net will use the Add method of the collection to add items, if the collection itself is exposed as a readonly property.
So it might be possible to use object definition inheritance to achieve the behavior you describe. Config will be something like:
<object id="ParentType" singleton="false" type="SomeType"
abstract="true">
<property name="FieldNameMap">
<dictionary>
<entry key="Title" value="TitleName"/>
</dictionary>
</property>
</object>
<object id="ChildType" singleton="false" type="SomeType"
parent="ParentType">
<property name="FieldNameMap">
<dictionary>
<!-- this entry should be added to, not replace the whole Dictionary -->
<entry key="Position" value="PositionName"/>
</dictionary>
</property>
</object>
This will only work if FieldNameMap is a readonly property.
I wish to break a string in wso2esb using xpath
my input like this
<property name="Message" value="assetname:ups,assetcode:452chi,assetid:548935,assetvalue:215" scope="default"/>
i need break in same property using xpath
i need like this
assetname:ups
assetcode=452chi
assetid=54895
assetvalue=215
for this i tried with tokenize function but wso2esb showing errors
my configure file
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Xpathcheck" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="max" value="1" scope="default" type="STRING"/>
<property name="min" value="1" scope="default" type="STRING"/>
<property name="MessageText" expression="fn:concat('Assetid:',get-property('min'),',','Assetname:',get-property('max'))" scope="default" type="STRING"/>
<property name="Tokenize" expression="fn:tokenize(get-property('Messagetext'),',')" scope="default" type="STRING"/>
<log>
<property name="MessageText" expression="get-property('MessageText')"/>
<property name="Tokenize" expression="get-property('Tokenize')"/>
</log>
</inSequence>
<outSequence/>
</target>
<description></description>
</proxy>
But its throwing errors like this u have any idea for this i need store this in Db table as a one field which look like separate lines
error is
ERROR - SynapseXPath Evaluation of the XPath expression fn:tokenize(get-property('Messagetext'),',') resulted in an error
org.jaxen.UnresolvableException: No Such Function tokenize
tokenize is a function comes with XPath 2.0. To enable XPath 2.0 functions uncomment the following entry in the synapse.properties file which is located at $ESB_HOME/repository/conf directory
synapse.xpath.dom.failover.enabled=true
then you have to specify the mediator as follows,
<property name="Message" value="a,b,c,d,e" scope="default"/>
<property xmlns:fn="http://www.w3.org/2005/xpath-functions" name="Tokenize" expression="fn:tokenize(syn:get-property('Message'),',')" scope="default" type="STRING"/>
I dont think this can be done through XPath, XPath is to navigate elements in an XML. You can do this by using a script mediator and write a JS to break the property values.
use the following to access the ESB params from the script mediator
<script language="js"> var test_param = mc.getProperty('Message')
Use the following to retrieve the params within the script mediator back to the ESB
mc.setProperty("param1",var1)
mc.setProperty("param2",var2)
Use the javascript to carry out the required string manupulations
How can I use/translate the (url_expr/available_expr) in actions.xml?
My usual way was to make a seperate "object" for each language:
<object name="contact" meta_type="CMF Action" i18n:domain="my.theme">
<property name="title" i18n:translate="">Contact</property>
<property name="description" i18n:translate=""></property>
<property
name="url_expr">string:${globals_view/navigationRootUrl}/contact</property>
<property name="icon_expr"></property>
<property name="available_expr">python:request.LANGUAGE == 'en'</property>
</object>
<object name="contact-de" meta_type="CMF Action" i18n:domain="my.theme">
<property name="title" i18n:translate="">Contact</property>
<property name="description" i18n:translate=""></property>
<property
name="url_expr">string:${globals_view/navigationRootUrl}/kontakt</property>
<property name="icon_expr"></property>
<property name="available_expr">python:request.LANGUAGE == 'de'</property>
</object>
If your contact / kontakt content is multilingual content managed by LinguaPlone, you can use the takeaction add-on to create one action that'll switch between translations as needed.
takeaction has it's own configuration file, like actions.xml it is a Generic Setup file:
<?xml version="1.0"?>
<object name="portal_takeaction"
meta_type="TakeAction content-as-actions tool">
<item category="site_actions" path="en/contact" />
</object>
The above configuration designates a content object at en/contact as a site_actions action item. It'll be listed in that action category, taking the title and description of one of the translations of the content object matching the current language.
You do not list the action in actions.xml anymore; the takeaction tool is itself a action provider.
Disclaimer: I am the original author of takeaction.
When Xpath expression is applied on /data/title , the results displayed are 'All the connections', 'Forward Details', 'Forward Detail',''Forward Detail', 'Forward Details' , 'ABCD', ...e.t.c..
My xpath expression has to list only if the /title is 'Forward Detail' or ''Forward Details'...
<?xml version="1.0" encoding="UTF-8"?>
<data>
<title>All the connections</title>
<List>
<Listitem>
<Price>P9909</Price>
</Listitem>
</List>
<title>Forward Detail</title>
<List>
<Listitem>
<Price>P45</Price>
</Listitem>
<Listitem>
<Price>P98</Price>
</Listitem>
<Listitem>
<Price>P68</Price>
</Listitem>
</List>
<title>Forward Details</title>
<List>
<Listitem>
<Price>P452</Price>
</Listitem>
<Listitem>
<Price>P983</Price>
</Listitem>
</List>
<title>Forward Detail</title>
<List>
<Listitem>
<Price>P4501</Price>
</Listitem>
<Listitem>
<Price>P909</Price>
</Listitem>
<Listitem>
<Price>P899</Price>
</Listitem>
</List>
<title>Forward Details</title>
<List>
<Listitem>
<Price>P4522</Price>
</Listitem>
<Listitem>
<Price>P98311</Price>
</Listitem>
</List>
of this input, I have to extract the price of only 'Forward Detail' and 'Forward Details'. I have to ignore the rest.
Please help me in framing the Xpath for this. I am using Xpath 1.0
Thanks
Ramm
Try if next command works for you:
/data/title[text() = "Forward Detail" or text() = "Forward Details"]/following-sibling::*[1]/descendant::Price
My result:
<Price>P45</Price>
<Price>P98</Price>
<Price>P68</Price>
<Price>P452</Price>
<Price>P983</Price>
<Price>P4501</Price>
<Price>P909</Price>
<Price>P899</Price>
<Price>P4522</Price>
<Price>P98311</Price>
You need a condition. Something like /data/title[text() == 'Forward Detail'].
However I suspect you actually need the List that is preceded by given title, right? Your XML is badly designed for that (it should have the title inside the <List> element instead), but XPath is capable enough to cope. You need to look at the sibling axis and the pos() function.
I'd have to look in the documentation myself, so I am just making this a community wiki; anybody feel free to rewrite.