动态设置birt chart图标题
在chart图的script里添加如下方法:
function beforeGeneration(chart, icsc)
{
// a1=icsc.getExternalContext().getScriptable().getParameterValue("a");
b1= icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("b")
// chart.getTitle().getLabel().getCaption().setValue(a1);
chart.getTitle().getLabel().getCaption().setValue(b2);
}
首先a1是从我们参数a里取值 ,然后设置到title里。当然我这里完全设置title为a,如果a1只是title
的一部分,应该先得到这个text 然后再set他们之和。
第二个b是从我们设置的持久性变量里取值。
这里注意一下,b这是个持久性变量,应该在图表之前设置了这个b,设置的方法是:
reportContext.PersistentGlobalVariable("b", 值);
这个值你就随便设置啦。
http://www.birthome.cn/read.php?tid-113.html
第一种:读配置文件(已经测试通过)
importPackage( Packages.java.io,Packages.java.util,Packages.java.net );
importPackage( Packages.javax.servlet.http );
req = reportContext.getHttpServletRequest( );
propPath = new String(params["propFile"].value); // 把配置文件名用参数传进来
if ( propPath.charAt(0) != "/" )
propPath = "/" + propPath;
url = req.getSession( ).getServletContext( ).getResource( propPath ); // 获得配置文件的相对路径
if ( url != null ) // 如果文件的相对路径不为空,则读取配置文件
{
props = new java.util.Properties( );
props.load( url.openStream( ) );
odaURL = new String(props.getProperty("url"));
odaDriverClass = new String(props.getProperty("driver"));
odaUser = new String(props.getProperty("userid"));
odaPassword = new String(props.getProperty("password"));
}
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/zunshanke2004/archive/2009/01/05/3705296.aspx
在chart图的script里添加如下方法:
function beforeGeneration(chart, icsc)
{
// a1=icsc.getExternalContext().getScriptable().getParameterValue("a");
b1= icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("b")
// chart.getTitle().getLabel().getCaption().setValue(a1);
chart.getTitle().getLabel().getCaption().setValue(b2);
}
首先a1是从我们参数a里取值 ,然后设置到title里。当然我这里完全设置title为a,如果a1只是title
的一部分,应该先得到这个text 然后再set他们之和。
第二个b是从我们设置的持久性变量里取值。
这里注意一下,b这是个持久性变量,应该在图表之前设置了这个b,设置的方法是:
reportContext.PersistentGlobalVariable("b", 值);
这个值你就随便设置啦。
http://www.birthome.cn/read.php?tid-113.html
第一种:读配置文件(已经测试通过)
importPackage( Packages.java.io,Packages.java.util,Packages.java.net );
importPackage( Packages.javax.servlet.http );
req = reportContext.getHttpServletRequest( );
propPath = new String(params["propFile"].value); // 把配置文件名用参数传进来
if ( propPath.charAt(0) != "/" )
propPath = "/" + propPath;
url = req.getSession( ).getServletContext( ).getResource( propPath ); // 获得配置文件的相对路径
if ( url != null ) // 如果文件的相对路径不为空,则读取配置文件
{
props = new java.util.Properties( );
props.load( url.openStream( ) );
odaURL = new String(props.getProperty("url"));
odaDriverClass = new String(props.getProperty("driver"));
odaUser = new String(props.getProperty("userid"));
odaPassword = new String(props.getProperty("password"));
}
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/zunshanke2004/archive/2009/01/05/3705296.aspx