General idea: add custom decorator
Note: this article assumes you have already implemented .jsp for custom decorator. You can check .jsp files under /WEB-INF/decorators folder for examples.
The idea is to add another decorator selected when for example a parameter meter=true is in the URL.
Problem:
If you try adding new decorator in decorators.xml by adding the following lines:
<decorator name="custom_dec" page="custom_decorator.jsp"> <pattern>**d_parameter=true</pattern> </decorator>
the parameter in URL is simply ignored.
Resolution:
Option 1:
Any parameters defined in decorators.xml are indeed ignored. The problem is hidden in ConfigDecoratorMapper class. The best solution is to customize the class to recognize parameters defined in decorators.xml. To do this you'll need to get JasperReports Server sources, modify the class and re-compile the project.
The ConfigDecoratorMapper.java can be found in:
/jasperreports-server-4.2.0-src/jasperserver-repo/opensymphony/sitemesh/2.2.1-JasperSoft/sitemesh-2.2.1-JasperSoft-src.zip
archive in the source distribution. In this archive you can find ConfigDecoratorMapper.java file under /sitemesh-2.2.1/src/java/com/opensymphony/module/sitemesh/mapper/ folder.
Option 2:
The simpler solution is to define one more parameter and use it in the URL along with parameter defined in decorators.xml. Here's what you basically need to do:
add your custom decorator in decorators.xml as follows:
<decorator name="custom_dec" page="custom_decorator.jsp"> <pattern>**d_parameter=true</pattern> </decorator>
open sitemesh.xml file and find mapper
class='com.opensymphony.module.sitemesh.mapper.ParameterDecoratorMapper'
- in this class set your own decorator.parameter value (for example value="custom_decorator"). Also set parameter.name value to "cxs"
- save the changes and restart the server
in the URL string add &custom_decorator=custom_dec&d_parameter=true
In this last step you define which decorator to use and make sure that decorator condition is "true".
Ref. Case #00022550 -- 15:01, 23 December 2011 (UTC)
Recommended Comments
There are no comments to display.