jasper grails parameters - grails

I have a Jasper report which accepts an Integer parameter.
I am using the <g:jasperReport> tag to call the report. The body of this tag has an HTML <input> whose value gets passed to the report.
The report is not working. It is giving an InvalidFormatException.
Please help.
Thanks in advance.
Abe

I found that defining the passed-in parameter as a String works even in the SQL; i.e., in the .jrxml:
<parameter name="headerid" class="java.lang.String">
<parameterDescription><![CDATA[ID this report is for]]></parameterDescription>
<defaultValueExpression><![CDATA['1']]></defaultValueExpression>
</parameter>
Use it in the SQL as you would an Integer; i.e.:
where header.id = $P{headerid}

Related

AntSCript to extract xml tag having specific matching string in attribute value from xml file

I have and XML file as below
<sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:atleastonce="http://www.tibco.com/wrm/policy/atleastonce" xmlns:common="http://xsd.tns.tibco.com/n2/models/common" xmlns:compositeext="http://schemas.tibco.com/amx/3.0/compositeext" xmlns:jdbc="http://xsd.tns.tibco.com/amf/models/sharedresource/jdbc" xmlns:pbu="http://www.tibco.com/wrm/policy/pbu" xmlns:pfe="http://xsd.tns.tibco.com/n2/models/pfe/1.0" xmlns:scact="http://xsd.tns.tibco.com/amf/models/sca/componentType" xmlns:scaext="http://xsd.tns.tibco.com/amf/models/sca/extensions" xmlns:service="http://xsd.tns.tibco.com/bx/amx/model" xmlns:smtp="http://xsd.tns.tibco.com/amf/models/sharedresource/smtp" xmlns:soapbt="http://xsd.tns.tibco.com/amf/models/sca/binding/soap" xmlns:startservicefirst="http://www.tibco.com/wrm/policy/startservicefirst" xmlns:threading="http://www.tibco.com/wrm/policy/threading" xmlns:transactedoneway="http://www.tibco.com/wrm/policy/transactedoneway" xmlns:webapp="http://xsd.tns.tibco.com/amf/models/sca/implementationtype/webapp" xmlns:wrm="http://www.tibco.com/wrm" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" compositeext:formatVersion="2" compositeext:version="1.0.0.20180112132229840" name="za.co.rmb.dealamendmentsmaintenance" targetNamespace="http://www.example.com/za.co.rmb.dealamendmentsmaintenance" xmi:id="_4EfRQfeKEeeZRvktH3XIjg" xmi:version="2.0">
<sca:reference multiplicity="0..1" name="WorkListService_Consumer1" promote="dealAmendmentsMaintenanceProcessFlow/WorkListService_Consumer" wiredByImpl="false" xmi:id="_AR2UQPeLEeeZRvktH3XIjg">
<sca:interface.wsdl interface="http://services.brm.n2.tibco.com#wsdl.interface(WorkListService)" scaext:wsdlLocation=".processOut/process/dealAmendmentsMaintenance.xpdl/brm.wsdl" xmi:id="_AR2UQfeLEeeZRvktH3XIjg"/>
</sca:reference>
<sca:reference multiplicity="0..1" name="CreateDailyTasks_Consumer1" promote="dealAmendmentsMaintenanceProcessFlow/CreateDailyTasks_Consumer" wiredByImpl="false" xmi:id="_ATRQkPeLEeeZRvktH3XIjg">
<sca:interface.wsdl interface="http://www.tibco.com/bs3.0/_8uwIINbzEeWTpucOvGErRg#wsdl.interface(CreateDailyTasks)" scaext:wsdlLocation=".processOut/process/dealAmendmentsMaintenance.xpdl/dealAmendments_segregation.wsdl" xmi:id="_ATRQkfeLEeeZRvktH3XIjg"/>
</sca:reference>
</sca:composite>
With ant script i want to extract value in the "interface" attribute under sca:interface, by matching input value in "name" attribute in sca:refernce.
So lets say
if input will be : WorkListService_Consumer1
Expected Output : http://services.brm.n2.tibco.com#wsdl.interface(WorkListService)
Similarly, if
input will be : CreateDailyTasks_Consumer1
Expected Output : http://www.tibco.com/bs3.0/_8uwIINbzEeWTpucOvGErRg#wsdl.interface(CreateDailyTasks)
I tried using various xmltask commands but i am not getting succesfull.
Thanks
Shrijeet Sinha
You almost had the solution, however text() is used to reference the inner text of an XML element, such as <element>This text here</element>. Here is the syntax for referencing an attribute's value:
<xmltask source="xmlfile.xml">
<copy path="sca:composite/sca:reference[#name='${input}']/sca:interface.wsdl/#interface" property="testproperty"/>
</xmltask>

Xquery to map the value of a specific name attribute

I am trying to create an xquery in jdeveloper . I am stuck at a small portion of it. It would be great if I get some suggestions.
Below is the part I am stuck at
The request is:
`<variables>
<variable name="StartTime" value="01:00:00"/>
<variable name= "EndTime" value="05:00:00"/>
The response I want to map is a single element with two values looks like below:
<ns2:time ns2:startTime="01:00:00" ns2:endTime="05:00:00"/>
Below is the xquery I tried. But I get only the start time at both places. I want some way by which I can correctly assign the values looking at the name value in the request.
if (fn:data($Prefereces/ns1:variables/ns1:variable/#name="StartTime")or fn:data($Prefereces/ns1:variables/ns1:variable/#name="EndTime")) then
( <ns2:time ns2:startTime="{fn:data($Prefereces/ns1:variables/ns1:variable/#value)}" ns2:endTime="{fn:data($Prefereces/ns1:variables/ns1:variable/#value)}">
</ns2:time>)
else
()
Thanks in advance.
You can use this :
<ns2:time ns2:startTime="{fn:data($Prefereces/variables/variable[#name = 'StartTime']/#value)}" ns2:endTime="{fn:data($Prefereces/variables/variable[#name = 'EndTime']/#value)}"/>
Note that the ns2 prefix has to be defined beforehand.
XQuery's predicates are specified using brackets ([condition]), which were missing from your tries.

sysproperty set to value "${value}" when no property is passed to target

I am executing a target with paramters as Dcolor=red.I am using this property value to set system property as
<sysproperty key="COLOR" value="${color}" />
If not passing any parameter named -Dcolor, when fetching key COLOR as System.getProperty("COLOR") is returning ${color}.
Is this correct behavior. How to handle such scenario ie. setting COLOR as null if no parameter names color is passed.
Please let me know if I am missing basics here. Resource link will be helpfull
That's crazy, the evaluation of the properties is done by the PropertyHelper class of the ant. But based on the source code, the returned value should be null, but it's not.
The documentation says the ant tries to evaluate it, but it doesn't state what happens if the evalutation is unsuccessful.
You can set a default value by predefining the property.
<property name="COLOR" value="defaultColor" />
But this will never set value null.
And finally after a long search, I found out that using syspropertyset instead of sysproperty, will return nulls.
This is a working example:
<propertyset id="java.props">
<propertyref name="test.property"/>
</propertyset>
<java>
<syspropertyset refid="java.props"/>
</java>
If you get the test.property, it will return null.

multiple expressions for single condition result

I have to change the header string of primefaces dialog, acording to a variable state in my backing bean. The condition would be the following (pseudo code):
#{backingBean.editing ? resourceBundle.edit_string resourceBundle.item.id : msg.add_string}
and the short snippet example:
<p:dialog id="dokDialog" header="#{backingBean.editing ? resourceBundle.edit_string resourceBundle.item.id : msg.add_string}" ...>
<!-- content -->
</p:dialog>
In this example I want to display either value #{msg.edit_string} #{resourceBundle.item.id} or #{msg.add_string} according to boolean value of #{backingBean.editing}.
What I want to do is to show either Editing Item 01 or New Item in the title.
Also I get the following exeption because I have two expressions (resourceBundle.edit_string resourceBundle.item.id) for one result:
Caused by: org.apache.el.parser.ParseException: Encountered " <IDENTIFIER>
Thanks!
resourceBundle.edit_string resourceBundle.item.id - it's a wrong expression. You need to concatenate
String.concat may help if you are using an appropriate version of EL: resourceBundle.edit_string.concat(' ').concat(resourceBundle.item.id)

Grails: out vs return

An strange problem occourse on grails 1.2.4 on my machine only....
We are using an custom taglib which can be accessed from services via gspTagLibraryLookup-bean from AppContext.
On my local machine
<my:span value="abc" title="${my.write(text:'123')}"/>
writes:
123<span title="">abc</span> <!-- what i see -->
<span title="123">abc</span> <!-- what my collegue see -->
my:write is defied as:
def write = {out << attrs.text}
But: If i use return instead of out, the html generate what my collegue see.
Anyone know the difference?
Argument value for the title attribute is evaluated before passing it to <my:span>. So if you define write as {out << attrs.text}, and use it in <my:span>, the write function will write to out before span function does, and return nothing - so 123 will be written to output before <span>, and the title attribute will be empty.
If you define write as {return attrs.text}, its evaluation won't write anything to out, and return 123 which will be inserted as value of title attribute.
Not sure why the first definition works on your collegue's machine.

Resources