XPath Expression to select an specific node - xpath

I'm having an issue trying to build an Xpath expression to select all the "field" nodes "name" value attribute.
I already tried: //field[#name] but it returns no matches.
The sample results I need from the XML document are: currentDate, trulyYours, claimant, dateOfLoss etc...
Thank you for your help.
<?xml version="1.0" encoding="UTF-8"?>
<?xfa generator="AdobeLiveCycleDesignerES_V9.0.0.2.20101008.1.734229" APIVersion="3.1.20001.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2012-01-23T17:23:59Z" uuid="594e6d9b-2319-4fdb-b490-4d7655e56aa0">
<template xmlns="http://www.xfa.org/schema/xfa-template/2.4/">
<?formServer defaultPDFRenderFormat acrobat7.0.5static?>
<subform name="form1" locale="en_US" layout="tb">
<pageSet>
<pageArea>
<contentArea name="ContentArea1" x="0pt" y="0pt" w="612pt" h="792pt"/>
<medium short="612pt" long="792pt" stock="custom"/>
</pageArea>
</pageSet>
<subform name="DynamicFragment">
<bind match="none"/>
<field name="currentDate" y="0mm" x="0.86mm" w="62mm" h="0.229167in" access="readOnly">
<ui>
<textEdit>
<border hand="right" presence="hidden">
<?templateDesigner StyleID aped0?></border>
<margin/>
</textEdit>
</ui>
<font typeface="Myriad Pro"/>
<para vAlign="middle"/>
<?PDF_OBJR TextField1[3]?>
<bind match="global"/>
</field>
<field name="trulyYours" y="129.578mm" w="62mm" h="0.229167in" access="readOnly">
<ui>
<textEdit>
<border hand="right" presence="hidden">
<?templateDesigner StyleID aped0?></border>
<margin/>
</textEdit>
</ui>
<font typeface="Myriad Pro"/>
<para vAlign="middle"/>
<?PDF_FIELD_ID 30003?>
<?PDF_OBJR TextField1[3]?>
<bind match="global"/>
</field>
<field name="claimant" y="47.624mm" x="46.135mm" w="62mm" h="0.229167in" access="readOnly">
<ui>
<textEdit>
<border hand="right" presence="hidden">
<?templateDesigner StyleID aped0?></border>
<margin/>
</textEdit>
</ui>
<font typeface="Myriad Pro"/>
<para vAlign="middle"/>
<?PDF_FIELD_ID 30003?>
<?PDF_OBJR TextField1[3]?>
<bind match="global"/>
</field>
<field name="ourInsured" y="42.618mm" x="46.135mm" w="62mm" h="0.229167in" access="readOnly">
<ui>
<textEdit>
<border hand="right" presence="hidden">
<?templateDesigner StyleID aped0?></border>
<margin/>
</textEdit>
</ui>
<font typeface="Myriad Pro"/>
<para vAlign="middle"/>
<?PDF_FIELD_ID 30002?>
<?PDF_OBJR TextField1[2]?>
<bind match="global"/>
</field>
<field name="dateOfLoss" y="37.127mm" x="46.135mm" w="62mm" h="0.229167in" access="readOnly">
<ui>
<textEdit>
<border hand="right" presence="hidden">
<?templateDesigner StyleID aped0?></border>
<margin/>
</textEdit>
</ui>
<font typeface="Myriad Pro"/>
<para vAlign="middle"/>
<?PDF_FIELD_ID 30001?>
<?PDF_OBJR TextField1[1]?>
<bind match="global"/>
</field>
<field name="ourClaimNumber" y="32.132mm" x="46.153mm" w="62mm" h="0.229167in" access="readOnly">
<ui>
<textEdit>
<border hand="right" presence="hidden">
<?templateDesigner StyleID aped0?></border>
<margin/>
</textEdit>
</ui>
<font typeface="Myriad Pro"/>
<para vAlign="middle"/>
<?PDF_FIELD_ID 30001?>
<?PDF_OBJR TextField1[0]?>
<bind match="global"/>
</field>
<traversal>
<traverse operation="first" ref="currentDate[0]"/>
</traversal>
<?templateDesigner isFragment yes?>
<?templateDesigner fragmentTitle 3016DynamicFragment?></subform>
</subform>
<?templateDesigner FormTargetVersion 24?>
<?templateDesigner Zoom 89?>
<?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?></template>
<config xmlns="http://www.xfa.org/schema/xci/1.0/">
<agent name="designer">
<!-- [0..n] -->
<destination>pdf</destination>
<pdf>
<!-- [0..n] -->
<fontInfo/>
</pdf>
</agent>
<present>
<!-- [0..n] -->
<destination>pdf</destination>
<pdf>
<!-- [0..n] -->
<fontInfo/>
<version>1.65</version>
</pdf>
<xdp>
<packets>*</packets>
</xdp>
</present>
</config>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c043 52.437709, 2010/08/04-17:30:07 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about="">
<xmp:MetadataDate>2012-01-23T17:23:59Z</xmp:MetadataDate>
<xmp:CreatorTool>Adobe LiveCycle Designer ES 9.0</xmp:CreatorTool>
</rdf:Description>
<rdf:Description xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
<pdf:Producer>Adobe LiveCycle Designer ES 9.0</pdf:Producer>
</rdf:Description>
<rdf:Description xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" rdf:about="">
<xmpMM:DocumentID>uuid:594e6d9b-2319-4fdb-b490-4d7655e56aa0</xmpMM:DocumentID>
</rdf:Description>
<rdf:Description xmlns:lcd="http://ns.adobe.com/livecycle/designer/" xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about="">
<lcd:fragmentCatalog>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">3016DynamicFragment</rdf:li>
</rdf:Alt>
</dc:title>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default"/>
</rdf:Alt>
</dc:description>
<dc:identifier>$template.form1.DynamicFragment</dc:identifier>
<lcd:fragmentRole>Subform</lcd:fragmentRole>
</rdf:li>
</rdf:Seq>
</lcd:fragmentCatalog>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<localeSet xmlns="http://www.xfa.org/schema/xfa-locale-set/2.1/">
<locale name="en_US" desc="English (United States)">
<calendarSymbols name="gregorian">
<monthNames>
<month>January</month>
<month>February</month>
<month>March</month>
<month>April</month>
<month>May</month>
<month>June</month>
<month>July</month>
<month>August</month>
<month>September</month>
<month>October</month>
<month>November</month>
<month>December</month>
</monthNames>
<monthNames abbr="1">
<month>Jan</month>
<month>Feb</month>
<month>Mar</month>
<month>Apr</month>
<month>May</month>
<month>Jun</month>
<month>Jul</month>
<month>Aug</month>
<month>Sep</month>
<month>Oct</month>
<month>Nov</month>
<month>Dec</month>
</monthNames>
<dayNames>
<day>Sunday</day>
<day>Monday</day>
<day>Tuesday</day>
<day>Wednesday</day>
<day>Thursday</day>
<day>Friday</day>
<day>Saturday</day>
</dayNames>
<dayNames abbr="1">
<day>Sun</day>
<day>Mon</day>
<day>Tue</day>
<day>Wed</day>
<day>Thu</day>
<day>Fri</day>
<day>Sat</day>
</dayNames>
<meridiemNames>
<meridiem>AM</meridiem>
<meridiem>PM</meridiem>
</meridiemNames>
<eraNames>
<era>BC</era>
<era>AD</era>
</eraNames>
</calendarSymbols>
<datePatterns>
<datePattern name="full">EEEE, MMMM D, YYYY</datePattern>
<datePattern name="long">MMMM D, YYYY</datePattern>
<datePattern name="med">MMM D, YYYY</datePattern>
<datePattern name="short">M/D/YY</datePattern>
</datePatterns>
<timePatterns>
<timePattern name="full">h:MM:SS A Z</timePattern>
<timePattern name="long">h:MM:SS A Z</timePattern>
<timePattern name="med">h:MM:SS A</timePattern>
<timePattern name="short">h:MM A</timePattern>
</timePatterns>
<dateTimeSymbols>GyMdkHmsSEDFwWahKzZ</dateTimeSymbols>
<numberPatterns>
<numberPattern name="numeric">z,zz9.zzz</numberPattern>
<numberPattern name="currency">$z,zz9.99|($z,zz9.99)</numberPattern>
<numberPattern name="percent">z,zz9%</numberPattern>
</numberPatterns>
<numberSymbols>
<numberSymbol name="decimal">.</numberSymbol>
<numberSymbol name="grouping">,</numberSymbol>
<numberSymbol name="percent">%</numberSymbol>
<numberSymbol name="minus">-</numberSymbol>
<numberSymbol name="zero">0</numberSymbol>
</numberSymbols>
<currencySymbols>
<currencySymbol name="symbol">$</currencySymbol>
<currencySymbol name="isoname">USD</currencySymbol>
<currencySymbol name="decimal">.</currencySymbol>
</currencySymbols>
<typefaces>
<typeface name="Myriad Pro"/>
<typeface name="Minion Pro"/>
<typeface name="Courier Std"/>
<typeface name="Adobe Pi Std"/>
<typeface name="Adobe Hebrew"/>
<typeface name="Adobe Arabic"/>
<typeface name="Adobe Thai"/>
<typeface name="Kozuka Gothic Pro-VI M"/>
<typeface name="Kozuka Mincho Pro-VI R"/>
<typeface name="Adobe Ming Std L"/>
<typeface name="Adobe Song Std L"/>
<typeface name="Adobe Myungjo Std M"/>
</typefaces>
</locale>
</localeSet></xdp:xdp>

The expression you've shown -- //field[#name] -- selects all field elements that have a name attribute. What you need to do is select the attribute itself. Like this:
//field/#name
Regarding namespaces: Your target nodes are found in the http://www.xfa.org/schema/xfa-template/2.4/ namespace. Any XPath expression must take this into account with the following steps:
Register the namespace to a prefix with your XPath engine. How this is done depends on the host language you're using to evaluate the expression. In Java, for example, this is done by creating a javax.xml.namespace.NamespaceContext that gets registered with the javax.xml.xpath.XPath instance.
Use the prefix you registered in step 1) to query elements in the target namespace. So, for example, if you were to register http://www.xfa.org/schema/xfa-template/2.4/ with the prefix xfa, then you'd write the expression like this:
//xfa:field/#name
Namespace-agnostic solution: It is possible (but not necessarily recommended) to select the target nodes without accounting for namespaces with the following expression:
//*[local-name()='field']/#name

You need to assign a prefix for the namespace. The field element is not in a null namespace. It appears to be in http://www.xfa.org/schema/xfa-template/2.4/.
How you assign the namespace prefix depends on what host language you are using to issue the XPath. You don't say so we can't help you. It will probably look something like this made-up example:
xpather.registerNamespace('xfa', 'http://www.xfa.org/schema/xfa-template/2.4/');
Note that "xfa" can be any prefix you want. Only the namespace uri matters.
Once that is done, your XPath will look like this:
//xfa:field/#name
If you assign a prefix to the xpd namespace too, you can be more specific:
/xpd:xpd/xfa:template//xfa:field/#name

Related

Jasper Report how to get a sibling node with parameter of another sibling?

I am working on a new Jaspert Report. It should print all data of a xml text.
The xml text looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<invoice:invoiceMessage>
<invoice>
<invoiceIdentification></invoiceIdentification>
<seller>
<address>
<name></name>
<city></city>
<cityCode></cityCode>
</address>
</seller>
</invoice>
</invoice:invoiceMessage>
And the Jasper Report looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.1.0.final using JasperReports Library version 6.4.3 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="main_report_xml1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="24a4119c-6e8f-4411-bbb5-c069ab379330">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="ireport.jasperserver.url" value="http://10.100.10.236/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="reko"/>
<property name="ireport.jasperserver.reportUnit" value="/Reko/main_report_xml1"/>
<subDataset name="pageHeader" uuid="cf87fcbb-cbcd-4c3b-bf87-3cf147854adb">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<queryString language="xPath">
<![CDATA[//seller/address]]]>
</queryString>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="streetAdressOne" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="streetAdressOne"/>
<fieldDescription><![CDATA[streetAdressOne]]></fieldDescription>
</field>
<field name="cityCode" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="cityCode"/>
<fieldDescription><![CDATA[cityCode]]></fieldDescription>
</field>
<field name="city" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="city"/>
<fieldDescription><![CDATA[city]]></fieldDescription>
</field>
</subDataset>
<parameter name="xmlString" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[xmlText]]></defaultValueExpression>
</parameter>
<parameter name="XML_INPUT_STREAM" class="java.io.InputStream">
<defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{xmlString}.getBytes("ISO-8859-1"))]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[/invoiceMessage/invoice[invoiceIdentification/entityIdentification=9000009029]]]>
</queryString>
<field name="value" class="java.lang.String">
<fieldDescription><![CDATA[creationDateTime]]></fieldDescription>
</field>
<pageHeader>
<band height="38"/>
</pageHeader>
<columnHeader>
<band height="31" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="488" splitType="Stretch">
<componentElement>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="21" width="552" height="30" isRemoveLineWhenBlank="true" uuid="fc7d22c7-8c60-4ecb-974f-c842becc4bf7"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="pageHeader" uuid="1e20fa2b-bb3a-475f-b721-5a13d3c374eb">
<datasetParameter name="XML_DATE_PATTERN">
<datasetParameterExpression><![CDATA[$P{XML_DATE_PATTERN}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_NUMBER_PATTERN">
<datasetParameterExpression><![CDATA[$P{XML_NUMBER_PATTERN}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_LOCALE">
<datasetParameterExpression><![CDATA[$P{XML_LOCALE}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_TIME_ZONE">
<datasetParameterExpression><![CDATA[$P{XML_TIME_ZONE}]]></datasetParameterExpression>
</datasetParameter>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//*[entityIdentification=9000009029]/parent::*/seller")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30">
<textField isStretchWithOverflow="true">
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="552" height="15" uuid="eac696b9-e20f-48a3-b70d-b186f5e649d6"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
</jasperReport>
My question is:
What should my dataSourceExpression in the componentElement be, so I can get the data out of it?
I also have some data in the invoice node that I need to show and thats why i set it like this in the query string. And I need to filter by the parameter that is stored inside of invoiceIdentification node.

apex 4 gantt chart task collapser missing

I used APEX 4.2 to create a Gantt chart with the AnyGantt Library.
When i use a custom XML for the Anygantt Diagram everythign works fine. As soon as i want to use custom datagrids, the collapser is missing.
My XML is the following:
<anygantt> <settings>
<navigation enabled="True" position="Top" size="30">
</navigation>
<editing allow_edit="true">
<rounding>
<date unit="Week" step="1" />
</rounding>
</editing>
<locale>
<date_time_format week_starts_from_monday="True">
<months>
<names>January,February,March,April,May,June,July,August,September,October,November,December</names>
<short_names>Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec</short_names>
</months>
<week_days>
<names>Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday</names>
<short_names>Sun,Mon,Tue,Wed,Thu,Fri,Sat</short_names>
</week_days>
<format>
<full>%yyyy.%MM.%dd.%HH.%mm.%ss</full>
<date>%yyyy.%MM.%dd</date>
<time>%HH.%mm.%ss</time>
</format>
</date_time_format>
</locale>
</settings>
<datagrid enabled="true" width="300">
<columns>
<column attribute_name="Name" width="200" cell_align="Left">
<header>
<text>Name</text>
</header>
<format>{%Name}</format>
</column>
<column width="40" cell_align="Left">
<header>
<text>Stunden</text>
</header>
<format>{%Stunden}</format>
</column>
</columns>
</datagrid>
<styles>
<defaults>
<period>
<period_style>
<bar_style>
<labels>
<label anchor="Center" valign="Center" halign="Center">
<text>{%DISPO} %</text>
<font face="Verdana" size="10" bold="true" color="White">
</font>
</label>
</labels>
</bar_style>
</period_style>
</period>
</defaults>
<period_styles>
<period_style name="test">
<bar_style>
<labels>
<label anchor="Center" valign="Center" halign="Center">
<text>Center</text>
<font face="Verdana" size="10" bold="true" color="White">
</font>
</label>
</labels>
<middle shape="Full">
<fill enabled="true" type="Solid" color="DarkSeaGreen" />
<border enabled="true" color="#FF0000" />
</middle>
</bar_style>
</period_style>
</period_styles>
</styles>
<resource_chart><resources><resource name="AVI" id="5"/>
<resource name="CAB" id="4"/>
<resource name="Test, Test (Test)" id="3-U837751" parent="3"/>
<resource name="PL" id="3"/>
<resource name="Struktur" id="2"/>
</resources><periods><period resource_id="3-U837751" name="NAME-3-U837751" start="2015.07.28 00:00" end="2015.07.31 00:00">
<attributes>
<attribute name="DISPO"><![CDATA[,5]]></attribute>
</attributes>
</period></periods></resource_chart>
You need to add cell_align="LeftLevelPadding" to the column where you want to see the collapser. Something like:
<column attribute_name="Name" width="200" cell_align="LeftLevelPadding">
This is described in KB: http://support.anychart.com/customer/portal/articles/2077851--anygantt-4-x-collapser-is-missing-in-datagrid-column
You can find more info on columns at
http://6.anychart.com/products/anygantt/docs/users-guide/index.html?columns.html

The optimized way to show text

I am in a process of optimizing item renderers that display a character in a Rect, I notice that the action of dynamically setting the text is slow, now I am thinking of creating premade objects with text hard-coded in them and inside the item-renderer have a switch to select the proper text object instead of using .text = , does anyone have any other idea on how to optimize the renderer , it is a tile layout that displays about 100 renderers on screen.
also - what is the cheapest(performance-wize) text object I can use in a renderer?
Thanks
<!-- DNA Plus -->
<s:Group height="26" width="100%" y="20">
<s:Rect id="backgroundTop" left="0" right="0" top="0" bottom="0"
alpha="{(data as MiniBrick).brick.strand == StrandEnum.PLUS.value ? 1 : 0.7}">
<s:fill>
<s:SolidColor id="bgFillTop" color="{BrickColors.getColor((data as MiniBrick).brick)}"/>
</s:fill>
</s:Rect>
<s:Rect id="selectedBackgroundTop" left="0" right="0" top="2" bottom="1" includeIn="selected">
<s:fill>
<s:SolidColor id="sBgFillTop" color.selected="0xB6E0F2"/>
</s:fill>
</s:Rect>
<!--- #copy spark.components.supportClasses.SkinnableTextBase#textDisplay -->
<s:Label id="textDisplayTop" width="100%" top="4" fontFamily="Consolas" text="{(data as MiniBrick).origin}"
fontSize="20" lineBreak="explicit" verticalAlign="middle" textAlign="center"/>
</s:Group>
<!-- DNA Minus -->
<s:Group height="26" width="100%" y="46">
<s:Rect id="backgroundBottom" left="0" right="0" top="0" bottom="0"
alpha="{(data as MiniBrick).brick.strand == StrandEnum.MINUS.value ? 1 : 0.7}">
<s:fill>
<s:SolidColor id="bgFillBottom" color="{BrickColors.getColor((data as MiniBrick).brick)}"/>
</s:fill>
</s:Rect>
<s:Rect id="selectedBackgroundBottom" left="0" right="0" top="1" bottom="2" includeIn="selected">
<s:fill>
<s:SolidColor id="sBgFillBottom" color.selected="0xB6E0F2"/>
</s:fill>
</s:Rect>
<!--- #copy spark.components.supportClasses.SkinnableTextBase#textDisplay -->
<s:Label id="textDisplayBottom" width="100%" top="4" fontFamily="Consolas" text="{DnaDictionary.getComplementSequenceOneLetter((data as MiniBrick).origin)}"
fontSize="20" lineBreak="explicit" verticalAlign="middle" textAlign="center"/>
</s:Group>
<!-- DNA index [tick list] -->
<s:Group width="15" id="dnaTick" y="72">
<s:Rect horizontalCenter="0" width="2" height="2" radiusX="1">
<s:fill>
<s:SolidColor color="#666666"/>
</s:fill>
</s:Rect>
<s:Label id="dnaTickLabel" horizontalCenter="0" y="5" height="9" color="#888888" fontFamily="Arial" fontSize="9"
textAlign="left" />
</s:Group>
<s:Line id="firstMiniBrickInBrickLine" x="0" y="20" yFrom="72">
<s:stroke>
<s:SolidColorStroke caps="none" color="#FFFFFF" weight="1"/>
</s:stroke>
</s:Line>
To answer your question directly: the most optimized way to display text is to use the UITextField class. But you're going to have a hard time implementing that into your ItemRenderer since it doesn't inherit from UIComponent.
Also that is not where the most performance gain is to be made in your code. The biggest problem is that this renderer has 6 data bindings in it. If you have 100 items on screen, that makes for 600 listeners watching for data changes.
So you should remove all those bindings and set those properties by overriding the ItemRenderer's data setter, like so:
override public function set data(value:Object):void {
super.data = value;
var brick:MiniBrick = value as MiniBrick;
backgroundTop.alpha = brick.brick.strand == StrandEnum.PLUS.value ? 1 : 0.7;
bgFillTop.color = BrickColors.getColor(brick.brick);
...
}
If you want to optimize even further, I would suggest you put the information for the renderers directly on the data so that it doesn't have to be evaluated every time and you can write the following:
override public function set data(value:Object):void {
super.data = value;
var brick:MiniBrick = value as MiniBrick;
backgroundTop.alpha = brick.alpha;
bgFillTop.color = brick.color;
...
}

List as subreport parameter

I need to pass to my subreport a list of integers which will be used as parameter for a IN statement in my query like this:
SELECT * FROM my_tables WHERE $X{IN, table.id || '', PARAMETER_LIST}
I have tried various syntax to instance a list on my master report but none of them lead to
a functional report ; eg :
<subreportParameter name="PARAMETER_LIST">
<subreportParameterExpression><![CDATA[[1,2]]]></subreportParameterExpression>
</subreportParameter>
Is there a solution to my problem?
I've tried to use $X{IN, attributeName, parameterName} with List component.
The main steps (parameters names are from the sample below):
Declare listParam parameter as java.util.List in main report
Declare quantityParam parameter as java.util.List in subDataset
Make mapping from listParam parameter to quantityParam parameter with help of ArrayList constructor
Add $X{} expression to subDataset query.
The working sample with language property as Java:
<jasperReport ...>
...
<subDataset name="dataset1">
<parameter name="ProductId" class="java.lang.Integer"/>
<parameter name="quantity" class="java.util.List"/>
<queryString>
<![CDATA[SELECT
POSITIONS."DOCUMENTID" AS POSITIONS_DOCUMENTID,
POSITIONS."POSITIONNO" AS POSITIONS_POSITIONNO,
POSITIONS."PRODUCTID" AS POSITIONS_PRODUCTID,
POSITIONS."QUANTITY" AS POSITIONS_QUANTITY,
POSITIONS."PRICE" AS POSITIONS_PRICE
FROM
"PUBLIC"."POSITIONS" POSITIONS WHERE PRODUCTID=$P{ProductId} AND $X{IN, QUANTITY, quantityParam}]]>
</queryString>
<field name="POSITIONS_DOCUMENTID" class="java.lang.Integer"/>
<field name="POSITIONS_POSITIONNO" class="java.lang.Integer"/>
<field name="POSITIONS_PRODUCTID" class="java.lang.Integer"/>
<field name="POSITIONS_QUANTITY" class="java.lang.Integer"/>
<field name="POSITIONS_PRICE" class="java.math.BigDecimal"/>
</subDataset>
<parameter name="listParam" class="java.util.List" isForPrompting="false">
<defaultValueExpression><![CDATA[Arrays.asList("1", "2")]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT
PRODUCT."ID" AS PRODUCT_ID,
PRODUCT."NAME" AS PRODUCT_NAME,
PRODUCT."COST" AS PRODUCT_COST
FROM
"PUBLIC"."PRODUCT" PRODUCT]]>
</queryString>
<field name="PRODUCT_ID" class="java.lang.Integer"/>
<field name="PRODUCT_NAME" class="java.lang.String"/>
<field name="PRODUCT_COST" class="java.math.BigDecimal"/>
...
<detail>
...
<componentElement>
<reportElement x="200" y="2" width="313" height="29"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="dataset1">
<datasetParameter name="ProductId">
<datasetParameterExpression><![CDATA[$F{PRODUCT_ID}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="quantityParam">
<datasetParameterExpression><![CDATA[new ArrayList($P{listParam})]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:listContents height="29" width="313">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{POSITIONS_QUANTITY}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{POSITIONS_PRICE}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
...
</jasperReport>
The sample is also works with report's language property as groovy.
I think that this solution can be applied to subreport.

Can you transition using Fade specifying all elements, without listing individually?

I've got the beginning of an air app, and I'm trying to transition between the states using Fade (a Sequence that should, in theory, fade out, then fade the next state in.) Is there a way to target it to fade out ALL the elements, or will I need to use targets="..." and list every element?
I've tried nesting all the elements in a Group, but that isn't seeming to work.
Shortened version of my current code:
<s:states>
<s:State name="HomeScreen"/>
<s:State name="EnemyBuilder"/>
<s:State name="EncyclopediaBuilder"/>
</s:states>
<fx:Declarations>
<s:Transition toState="*" fromState="*" >
<s:Sequence >
<s:Fade alphaFrom="1" alphaTo="0" duration="250" target="{wrapper}" />
<s:Fade alphaFrom="0" alphaTo="1" duration="250" target="{wrapper}" />
</s:Sequence>
</s:Transition>
</fx:Declarations>
<s:Group id="wrapper" includeIn="HomeScreen, EnemyBuilder, EncyclopediaBuilder" >
<s:BorderContainer id="encounter" includeIn="HomeScreen"
x="49" y="99" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)" click="currentState='EncyclopediaBuilder'" >
<s:Label x="48" y="8" color="#000000" fontFamily="Arial" text="Create a new encounter" />
<s:Label x="48" y="24" color="#000000" fontStyle="italic" text="Single encounter" />
<s:Image x="10" y="10" source="assets/001_01.png" />
<s:BorderContainer id="back" includeIn="EncyclopediaBuilder"
right="20" bottom="20" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)"
click="currentState='HomeScreen'" >
<s:Label x="48" y="16" color="#000000" fontFamily="Arial" text="Save and Return"/>
<s:Image x="10" y="10" source="assets/001_01.png"/>
</s:BorderContainer>
</s:BorderContainer></s:Group>
Try to use something like the following:
<s:states>
<s:State name="HomeScreen"/>
<s:State name="EnemyBuilder"/>
<s:State name="EncyclopediaBuilder"/>
</s:states>
<s:transitions>
<s:Transition toState="*" fromState="*" >
<s:Sequence target="{wrapper}">
<s:Fade alphaFrom="1" alphaTo="0" duration="250" />
<s:Fade alphaFrom="0" alphaTo="1" duration="250" />
</s:Sequence>
</s:Transition>
</s:transitions>
<s:Group id="wrapper">
<s:BorderContainer id="encounter" includeIn="HomeScreen"
x="49" y="99" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)" click="currentState='EncyclopediaBuilder'" >
<s:Label x="48" y="8" color="#000000" fontFamily="Arial" text="Create a new encounter" />
<s:Label x="48" y="24" color="#000000" fontStyle="italic" text="Single encounter" />
<s:Image x="10" y="10" source="assets/001_01.png" />
<s:BorderContainer id="back" includeIn="EncyclopediaBuilder"
right="20" bottom="20" width="200" height="44"
styleName="falseButton"
rollOut="alphaOver(event)" rollOver="alphaOver(event)"
click="currentState='HomeScreen'" >
<s:Label x="48" y="16" color="#000000" fontFamily="Arial" text="Save and Return"/>
<s:Image x="10" y="10" source="assets/001_01.png"/>
</s:BorderContainer>
</s:BorderContainer></s:Group>

Resources