Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Encoding is not working
JoSeTe
Hello everybody !
I am deploying a report using JSF4Birt in a Jboss 6 application. I have managed to put the resources folder in the .ini configuration file and also to load several .properties files for report translation. The trouble is that I have a russian .properties with unicode escaping caracters, for instance:
alarm_test_report=\u043e\u043a\u043b\u0430\u0434
(alarm_test_report= ?????)
In the preview inside eclipse it works perfectly, but in the deployment test (browser) it appears
?????
I have tried changing the encoding of the browser (IE8) also I have realized that in the HTML code the tag is
<div class="style_3" id="AUTOGENBOOKMARK_2" style=" text-align:center;">????? </div>
So maybe the problem comes before rendering ?
Any Help would be highly appreciated.
Thanks in advance. ^_^
Find more posts tagged with
Comments
JoSeTe
Hello again,
After a few hours of research, i think i've figured out what my problem is,
http://www.eclipse.org/forums/index.php?&t=msg&th=154675
it is that the birt engine is not outputing the right response codification, I need to access the response attribute in the beforefactory script, something like
reportContext.getReportRunnable().getReportEngine().setresponse.setContentType( "text/html;charset=utf-8" );
But i dont know exactly the call, How can i see this ? Any Help?
Thanks in advance
JasonW
You may need to ask this question in the exadel forums. Can you create a blank report that has one data item that gets the http servlet request? The expression shold look like:
reportContext.getHttpServletRequest();
Just trying to see if jsf4birt loads the request object.
Jason
JoSeTe
Hello Jason <br />
<br />
Thanks for the quick answer, yes, JSF4BIRT reach the request and can access it, but my problem is to "setup" the response of the runengine at the beforefactory script, because it is sending a incorret output to the upperlayer when it is deployed at the JBOSS.(The output in the webviewer inside the eclipse is fine)<br />
<br />
It should be something like <br />
reportContext.getHttpResponse() and change the output coding...<br />
<br />
It is even possible? <br />
<br />
Thank you very much<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81972" data-time="1314371698" data-date="26 August 2011 - 08:14 AM"><p>
You may need to ask this question in the exadel forums. Can you create a blank report that has one data item that gets the http servlet request? The expression shold look like:<br />
<br />
reportContext.getHttpServletRequest();<br />
<br />
Just trying to see if jsf4birt loads the request object.<br />
<br />
Jason<br /></p></blockquote>
JasonW
Currently you can not get the response object in BIRT script. I am not certain this will help but you could try setting the encoding like:
reportContext.getHttpServletRequest().setCharacterEncoding("UTF-8");
To see what is being used currently check it with:
reportContext.getHttpServletRequest().getCharacterEncoding();
Jason
JoSeTe
Thanks for answering Jason,<br />
<br />
<br />
It is not working, have you got any other tip to configure the "outputcoding" in a BIRT beforefactory script? (I have no servlet because I am using a jsf wrapper, so i can not modify a servlet... maybe touch the "run" servlet sourcecode?) I have thought about changing the HTMLRenderOption Emmiter configuration... How could I access the HTMLRenderOption for putting something like options.setUrlEncoding("utf-8") from the beforeFactory script?<br />
<br />
Sorry for the bunch of questions, but I am kind of desperate here hehe<br />
<br />
Thank you very much for your help. <br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81976" data-time="1314375460" data-date="26 August 2011 - 09:17 AM"><p>
Currently you can not get the response object in BIRT script. I am not certain this will help but you could try setting the encoding like:<br />
<br />
reportContext.getHttpServletRequest().setCharacterEncoding("UTF-8");<br />
<br />
To see what is being used currently check it with: <br />
reportContext.getHttpServletRequest().getCharacterEncoding();<br />
<br />
Jason<br /></p></blockquote>
JasonW
I do not think the jsf4birt project uses the run servlet. I assume your report works with the default birt viewer? It may be best to log a jira on the jsf4birt project or check out the code and modify it.
Jason
JoSeTe
Again, thank you for your response Jason. Nice work! <br />
<br />
Yes, my report is perfectly fine executed in the birt viewer...Thank for everything I am "bothering" jira jsfproject right now... so my last question is... <br />
<br />
How can I access the HTMLRenderOption from the beforefactory script? <br />
<br />
My last question I swear
<br />
<br />
Kind regards from Germany<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81979" data-time="1314377996" data-date="26 August 2011 - 09:59 AM"><p>
I do not think the jsf4birt project uses the run servlet. I assume your report works with the default birt viewer? It may be best to log a jira on the jsf4birt project or check out the code and modify it.<br />
<br />
Jason<br /></p></blockquote>
JasonW
I am not certain if you change them if it will take effect, but it may be worth a try. To access them add a data item to a report and enter the following expression:
reportContext.getRenderOption().getOptions()
You can also get to them in the beforeFactory the same way.
BTW - There is no harm in asking questions. If you have them others may learn from your example.
Jason
JoSeTe
Hello Jason again.<br />
<br />
I solved my problem. I had to checkout the code for JSF4Birt, and changing the outputstream to be encoding to UTF-8 (Class BirtRenderUtils.java, in bold my change)<br />
<br />
I can't believe that anybody hasn't tried to use JSF4BIRT with an international charset coding, anyway i am reporting this bug to exadel as well. <br />
<br />
Thank you for everything Jason, great job ! <br />
<br />
Cheers<br />
<br />
private void printInResponse(OutputFormat format, FacesContext context, ByteArrayOutputStream out ) throws IOException {<br />
HttpServletResponse resp = (HttpServletResponse)context.getExternalContext().getResponse();<br />
<br />
<br />
OutputStream outputStream =null;<br />
try {<br />
if (context.getResponseWriter() != null) {<br />
context.getResponseWriter().write(<strong class='bbc'>out.toString("UTF-8")</strong>);<br />
}<br />
<br />
else {<br />
outputStream = resp.getOutputStream();<br />
<br />
if (outputStream == null) {<br />
throw new NullPointerException(<br />
"Response output stream is null !!");<br />
}<br />
<br />
//resp.setContentType(format.getContentType());<br />
resp.setContentType(<br />
<br />
"text/html;charset=UTF-8");<br />
resp.setCharacterEncoding(<br />
<br />
"UTF-8");<br />
//java.nio.charset.CharsetDecoder<br />
//aqui haciendo malabares con los datos madre mia<br />
outputStream.write(out.toByteArray());<br />
<br />
}<br />
<br />
}<br />
<br />
finally {<br />
if (outputStream != null) {<br />
outputStream.close();<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81990" data-time="1314382001" data-date="26 August 2011 - 11:06 AM"><p>
I am not certain if you change them if it will take effect, but it may be worth a try. To access them add a data item to a report and enter the following expression:<br />
reportContext.getRenderOption().getOptions()<br />
You can also get to them in the beforeFactory the same way.<br />
<br />
BTW - There is no harm in asking questions. If you have them others may learn from your example.<br />
<br />
<br />
Jason<br /></p></blockquote>
JasonW
Thanks so much for posting your solution. This is great work.
Jason