Output in txt format in JasperReports Server - jasperserver

I'm using JasperReports Server 6.4.2. And in "Output Options" tab of "New Schedule" windows I have such list of output formats:
And I would like to add here .txt format. I uncommented the following line in \JasperReports Server\apache-tomcat\webapps\jasperserver\WEB-INF\flows\viewReportBeans.xml file:
<!--
<entry key="txt" value-ref="txtExporterConfiguration"/>
-->
and uncommented the lines:
<!--
<bean class="com.jaspersoft.jasperserver.war.dto.ByteEnum">
<property name="code">
<util:constant static-field="com.jaspersoft.jasperserver.api.engine.scheduling.domain.ReportJob.OUTPUT_FORMAT_TXT"/>
</property>
<property name="labelMessage">
<value>report.output.txt.label</value>
</property>
</bean>
-->
in \JasperReports Server\apache-tomcat\webapps\jasperserver\WEB-INF\flows\reportJobBeans.xml file, but these actions didn't make any visual effect, the "Text only" format didn't appear on the "Formats" form. How to add this format on the form?
I found also the similar question on the official jasper site, but, unfortunately, without answer... It seems the matter is in 6.x version.

At last I found instruction how to do this. The steps that I lacked: editing \JasperReports Server\apache-tomcat\webapps\jasperserver\scripts\scheduler\view\editor\outputTabView.js file and disabling "javascript.optimize" property in WEB-INF\js.config.properties file. After these actions "TXT" checkbox eventually appeared on the form:

Related

Set the name of an input control in a jrxml file. Is it possible?

I'd like to set the name of an input control in the jrxml file where it is defined; is that possible?
I know how to set the name of the input control via the Repository Explorer in Jaspersoft Studio, and I know how to set the name of an input control via the Jaspersoft Server.
However, I'd like to set the name of an input control in the jrxml file so that it will be set automatically upon being published to the server. Is there a property to use, similar to the following:
<parameter name="status_date_minimum" class="java.sql.Date">
<property name="some.property.key" vhalue="Minimum Status Date"/>
<defaultValueExpression><![CDATA[java.sql.Date.valueOf(java.time.LocalDate.now().minusYears(10).withMonth(1).withDayOfMonth(1))]]></defaultValueExpression>
</parameter>
As noted by #Siddharth in comments and suggested to me by a co-worker, there is a way to specify the label for the control outside of the user interface.
JasperReports Server associates each report with an XML file that it appears to create around the time it publishes your report to the server. The XML file contains, among other information, the labels for any input controls.
For an example of the XML file, first publish your report to a location on JasperReports Server. For the purpose of this example, the report file name is report.jrxml and the location is path/to/your; JasperReports Server appears to publish your report to path/to/your/report/Main jrxml (per JasperSoft Studio Repository Explorer) or path/to/your/report (per JasperReports Server Web UI).
Second, export your report from JasperReports Server (via the Web UI or via the command line); JasperReports Server will produce a zip file with the following content:
/index.xml
/resources/path/.folder.xml
/resources/path/to/.folder.xml
/resources/path/to/your/.folder.xml
/resources/path/to/your/report.xml
/resources/path/to/your/report_files/main_jrxml.data
main_jrxml.data contains the data from report.jrxml; report.xml contains the labels for any input controls. The content of report.xml may be similar to the following:
<?xml version="1.0" encoding="UTF-8"?>
<reportUnit exportedWithPermissions="true">
<folder>/resources/path/to/your</folder>
<name>report</name>
<version>2</version>
<label>report</label>
<description></description>
<creationDate>2018-03-21T18:12:41.759-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<mainReport>
<localResource
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exportedWithPermissions="false" dataFile="main_jrxml.data" xsi:type="fileResource">
<folder>/resources/path/to/your/report_files</folder>
<name>main_jrxml</name>
<version>4</version>
<label>Main jrxml</label>
<creationDate>2018-03-21T18:12:41.759-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.410-04:00</updateDate>
<fileType>jrxml</fileType>
</localResource>
</mainReport>
<inputControl>
<localResource
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exportedWithPermissions="false" xsi:type="inputControl">
<folder>/resources/path/to/your/report_files</folder>
<name>status_date_minimum</name>
<version>1</version>
<label>status_date_minimum</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>2</type>
<mandatory>false</mandatory>
<readOnly>false</readOnly>
<visible>true</visible>
<dataType>
<localResource exportedWithPermissions="false" xsi:type="dataType">
<folder>/resources/path/to/your/report_files/status_date_minimum_files</folder>
<name>myDatatype</name>
<version>0</version>
<label>myDatatype</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>3</type>
<strictMin>false</strictMin>
<strictMax>false</strictMax>
</localResource>
</dataType>
</localResource>
</inputControl>
<inputControl>
<localResource
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exportedWithPermissions="false" xsi:type="inputControl">
<folder>/resources/path/to/your/report_files</folder>
<name>status_date_maximum</name>
<version>1</version>
<label>status_date_maximum</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>2</type>
<mandatory>false</mandatory>
<readOnly>false</readOnly>
<visible>true</visible>
<dataType>
<localResource exportedWithPermissions="false" xsi:type="dataType">
<folder>/resources/path/to/your/report_files/status_date_maximum_files</folder>
<name>myDatatype</name>
<version>0</version>
<label>myDatatype</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>3</type>
<strictMin>false</strictMin>
<strictMax>false</strictMax>
</localResource>
</dataType>
</localResource>
</inputControl>
<alwaysPromptControls>true</alwaysPromptControls>
<controlsLayout>1</controlsLayout>
</reportUnit>
You may edit the content of the reportUnit/inputControl/localResource/label element to change the name of the label.
Once edited, you may import the data into the JasperReports Server. If you import through the command line, I recommend importing the directory, not the zip file - it appears that the command line import is picky about the zip format. Also, if you import through the command line, you must restart the JasperReports Server before you may run your changed report.

Eclipse wrongly formats a Spring p-namespace bean

I am using spring-2.5 (cannot upgrade, product dependency) and I notice a strange behaviour of the Eclipse formatter when I am using the p-namespace notation and some value expression:
If I use the standard way (without p-namespace) like this:
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig">
<property name="ldapServer" value="${ldap.server}" />
<property name="ldapPort" value="${ldap.port}" />
<property name="ldapBindDn" value="${ldap.bindDn}" />
<property name="ldapPass" value="${ldap.password}" />
</bean>
and press the key combination: Ctrl-Shift-F the formatting (e.g indentation) works very well.
Now if I use the p-namespace notation like this:
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig">
<p:ldapServer="${ldap.server}" />
<p:ldapPort="${ldap.port}" />
<p:ldapBindDn="${ldap.bindDn}" />
<p:ldapPass="${ldap.password}"/>
</bean>
When I press the key combination: Ctrl-Shift-F the formatting (e.g indentation)
removed some part of the code
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig">
<p:ldapServer = ldap.server } />
<p:ldapPort = ldap.port } />
<p:ldapBindDn = ldap.bindDn } />
<p:ldapPass = ldap.password } />
</bean>
Is there any incompatibility between the value expressions ( ${variable} ) and the p-namespace, or it is just an Eclipse bug on the XML formatting part?
Bean definition of ldapConfig when using p-namespace is not correct. By using the p-namespace you can use attributes as part of the bean element that describe your property values, instead of using nested elements. More details can be found here.
Assuming you have declared namespace as xmlns:p="http://www.springframework.org/schema/p"
The correct way to use it is:
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig"
p:ldapServer="${ldap.server}"
p:ldapPort="${ldap.port}"
p:ldapBindDn="${ldap.bindDn}"
p:ldapPass="${ldap.password}">
</bean>
Now try CTRL-SHIFT-F

How do I optionally require a command line arguement for Ant?

I'm new to ant, and I want to require a file name if something other than the default target is used, so the calling syntax would be something like this:
ant specifictarget -Dfile=myfile
I'm using the ant contrib package to give me additional functionality, so I have this:
<if>
<equals arg1="${file}" arg2="" />
<then>
<!-- fail here -->
</then>
</if>
My thinking is that if file was not specified it might be equal to the empty string. Obviously, this didn't work, and I'm not finding any examples on google or the right syntax in the manual.
So what syntax should I use?
You don't really need the contrib package. This is more conveniently done using built-in ant capabilities like if/unless and depends. See below:
<target name="check" unless="file" description="check that the file property is set" >
<fail message="set file property in the command line (e.g. -Dfile=someval)"/>
</target>
<target name="specifictarget" if="file" depends="check" description=" " >
<echo message="do something ${file}"/>
</target>
You've got the right idea. The
ant specifictarget -Dfile=myfile
sets Ant Properties from the command line. All you really need is
<property name="file" value=""/>
for your default value. That way if file is not specified, it will be equal to the empty string.
Since properties are not mutable in Ant, you can add this:
<property name="file" value="" />
This will set the property file to an empty string if it hasn't already been set on the command line. Then your equality test will work as you intended.
Alternately, you can use escape the value since ant just spits out the actual text when it can't do a property substitution.
<if>
<equals arg1="${file}" arg2="$${file}" />
<then>
<echo>BARF!</echo>
</then>
</if>

Reading values from property file through NANT

How can I read a value alone from the property file. For example, how can I read the values of build.home or temp.dir from the below example.
contents of env.properties
build.home=c:\build
temp.dir=c:\temp
Regards
Sarathy
We do this in a slightly different format for Nant.
In your build file:
<include buildfile="./env.properties" failonerror="true"/>
env.properties:
<?xml version="1.0" ?>
<project>
<property name="build.home" value="c:/build"/>
<property name="temp.dir" value="c:/temp"/>
</project>

How do I deploy registry keys and values using WiX 3.0?

If I want to create the registry key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MyApp
with the string value
EventMessageFile : C:\Path\To\File.dll
how do I define this in my WiX 3.0 WXS file? Examples of what the XML should look like is much appreciated.
You seem to want to create an event log source. If that is the case, you should take a look at the <EventSource> element in the util extension.
Check out this page. An example would be:
<registry action="write"
root"HKLM" key="SYSTEM\CurrentControlSet\Services\Eventlog\Application\MyApp"
type="string" value="EventMessageFile : C:\Path\To\File.dll" />
I went with this:
<Component Id="EventLogRegKeys" Guid="{my guid}">
<RegistryKey Id="Registry_EventLog" Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\Eventlog\Application\MyApp" Action="create">
<RegistryValue Id="Registry_EventLog_EventSourceDll" Action="write" KeyPath="yes" Name="EventMessageFile" Type="string" Value="C:\Path\To\File.dll" />
</RegistryKey>
</Component>
It would be better to refer to File.dll using file reference syntax, to ensure that the actual path it's installed to is used. Use [#filekey], where filekey is the Id of the File element describing the file.
Use the following under DirectoryRef --> Directory...
<Component Id="RegisterAddReferencesTab32" Guid="D9D01248-8F19-45FC-B807-093CD6765A60"> <RegistryValue Action="write" Id="RegInstallDir32" Key="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MyApp" Root="HKLM" Type="string" Value="C:\Path\To\File.dll" /></Component>