how to change export file name [message #893683] |
Thu, 05 July 2012 09:09 |
smith link Messages: 14 Registered: May 2012 |
Junior Member |
|
|
birt 2.3.x
<context-param>
<param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name>
<param-value>com.link.report.FilenameGenerator</param-value>
</context-param>
package jetsennet.jnmp.report;
import java.util.Date;
import java.util.Map;
import org.eclipse.birt.report.utility.filename.IFilenameGenerator;
public class FilenameGenerator implements IFilenameGenerator
{
/**
* default report file name
*/
public static final String DEFAULT_FILENAME = "report";
public String getFilename(String [b]fileName[/b], String extension,
String outputType, Map options)
{
System.out.println(baseName);
return makeFileName(baseName, extension);
}
/**
* Makes a filename using the target extension from the options.
*
* @param fileName
* file name which extension must be replaced
* @return file name with replaced extension
*/
public static String makeFileName(String fileName, String extensionName)
{
String baseName = fileName;
if (baseName == null || baseName.trim().length() <= 0)
{
baseName = DEFAULT_FILENAME;
}
// check whether the file name contains non US-ASCII characters
for (int i = 0; i < baseName.length(); i++)
{
char c = baseName.charAt(i);
// char is from 0-127
if (c < 0x00 || c >= 0x80)
{
baseName = DEFAULT_FILENAME;
break;
}
}
// append extension name
if (extensionName != null && extensionName.length() > 0)
{
baseName += (new Date()).toString() + "." + extensionName; //$NON-NLS-1$
}
return baseName;
}
}
I'd like to use the follow code, but it is unusable!
<birt:viewer id="birtViewer" reportDesign="reports/alarmeventstatisticsnew.rptdesign"
pattern="frameset"
format="HTML"
isHostPage = "true">
<birt:param name="baseName" value="myexportfile"/>
</birt:viewer>
how to change baseName, or how to pass parameter to baseName?
[Updated on: Thu, 05 July 2012 10:13] Report message to a moderator
|
|
|
Re: how to change export file name [message #893807 is a reply to message #893683] |
Thu, 05 July 2012 14:25 |
|
I assume you read through this post?
http://birtworld.blogspot.com/2008/09/naming-exported-files-from-birt.html
baseName is passed in and in your case should be
alarmeventstatisticsnew
I am not certain 2.3.x implemented the filename generator extension.
Did this context parameter already exist in your web.xml?
> <context-param>
> <param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name>
> <param-value>com.link.report.FilenameGenerator</param-value>
> </context-param>
Or did you add it?
Jason
On 7/5/2012 5:09 AM, smith link wrote:
> birt 2.3.x
>
>
>
>
> <context-param>
> <param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name>
> <param-value>com.link.report.FilenameGenerator</param-value>
> </context-param>
>
>
>
>
> package jetsennet.jnmp.report;
>
> import java.util.Date;
> import java.util.Map;
>
> import org.eclipse.birt.report.utility.filename.IFilenameGenerator;
>
>
> public class FilenameGenerator implements IFilenameGenerator
> {
> /**
> * default report file name
> */
> public static final String DEFAULT_FILENAME = "report";
>
> public String getFilename(String baseName, String extension,
> String outputType, Map options)
> {
> System.out.println(baseName);
> return makeFileName(baseName, extension);
> }
>
> /**
> * Makes a filename using the target extension from the options.
> * * @param fileName
> * file name which extension must be replaced
> * @return file name with replaced extension
> */
> public static String makeFileName(String fileName, String
> extensionName)
> {
> String baseName = fileName;
> if (baseName == null || baseName.trim().length() <= 0)
> {
> baseName = DEFAULT_FILENAME;
> }
>
> // check whether the file name contains non US-ASCII characters
> for (int i = 0; i < baseName.length(); i++)
> {
> char c = baseName.charAt(i);
>
> // char is from 0-127
> if (c < 0x00 || c >= 0x80)
> {
> baseName = DEFAULT_FILENAME;
> break;
> }
> }
>
> // append extension name
> if (extensionName != null && extensionName.length() > 0)
> {
> baseName += (new Date()).toString() + "." + extensionName;
> //$NON-NLS-1$
> }
> return baseName;
> }
> }
>
>
>
>
>
> I'd like to use the follow code, but it is unusable!
> <birt:viewer id="birtViewer"
> reportDesign="reports/alarmeventstatisticsnew.rptdesign"
> pattern="frameset"
> format="HTML"
> isHostPage = "true">
> <birt:param name="baseName" value="ok"/>
> </birt:viewer>
>
>
> how to change baseName, or how to pass parameter to baseName?
|
|
|
|
Powered by
FUDForum. Page generated in 0.02861 seconds