Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:3500:0700:0730 [2023/04/05 07:50] – removed - external edit (Unknown date) 127.0.0.1 | docs:3500:0700:0730 [2023/04/06 04:47] (current) – sean | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | {{tag> | ||
| + | [< | ||
| + | ===== Report Scriptlet Example ===== | ||
| + | |||
| + | The following example shows the code for a simple scriptlet that accumulates names encountered in the report and provides them in a single comma separated string. It also displays a static image. It is assumed that the report in which the scriptlet executes has the following elements: | ||
| + | |||
| + | - Tag element with the name " | ||
| + | - Tag element with the name "Last Name" | ||
| + | - Text element with the name " | ||
| + | - Image element with the name " | ||
| + | |||
| + | <code java> | ||
| + | { | ||
| + | private boolean m_firstTime= true ; | ||
| + | public TestScriptlet() | ||
| + | { | ||
| + | |||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void beforeReportInit(IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | |||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void afterReportInit(IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void beforePageInit(IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | } | ||
| + | /* (non-Javadoc) | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void afterPageInit(IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | |||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | | ||
| + | public void beforeColumnInit(IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void afterColumnInit(IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | |||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void beforeGroupInit( | ||
| + | StringgroupName, | ||
| + | IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void afterGroupInit( | ||
| + | StringgroupName, | ||
| + | IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | public void beforeDetailEval(IReportEnvironmentenvironment) | ||
| + | throws Exception | ||
| + | { | ||
| + | } | ||
| + | /* | ||
| + | * @see com.bas.basserver.documents.IReportScriptlet# | ||
| + | */ | ||
| + | | ||
| + | | ||
| + | { | ||
| + | // here all report elements have been calculated already | ||
| + | StringfirstName=(String)environment.getElementValue (" | ||
| + | StringlastName =(String)environment.getElementValue (" | ||
| + | StringcurList =(String)environment.getElementValue (" | ||
| + | if (curList== null ) | ||
| + | curList=""; | ||
| + | // create the string with names | ||
| + | if (m_firstTime) | ||
| + | m_firstTime= false ; | ||
| + | else | ||
| + | curList=curList+","; | ||
| + | // set the value for our element | ||
| + | environment.setElementValue(" | ||
| + | // set the value for another element | ||
| + | ImageIconimage= new ImageIcon(getClass().getResource("/ | ||
| + | environment.setElementValue(" | ||
| + | } | ||
| + | }</ | ||
| + | |||