ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-21-2010 17:32
Hi ,
     i was trying to run ur JSF example in my application ,which u wrote in this link
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1251103089

but m not able to understand from where u create response ,requet object .i did get these object from FacesContext like this
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse() ;

and all other code same as u wrote but chart not work ,can u plz let me know where i m wrong or what the mistake i m doing

thanks

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Peter Kwan on Sep-22-2010 03:39
Hi Subodh,

One of our customers reported in the following thread that the code should work. He is using the same method as you to get the request and response object:

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1239105242#N1239810952

Have you set the managed-bean-scope of the bean to "request" as mentioned in the above thread?

If the above still cannot solve the problem, is it possible to inform me what is the error message, or the symptom? In the above thread, I also mentioned a method of not using makeSession (session variables) at all. This is by using makeTmpFile instead of makeSession, and should work around issues related to session scope.

Regards
Peter Kwan

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-22-2010 19:21
I added navigation bean in faces.config.xml ,and i m not getting any exception in bean,also when i checked source code of web page i saw the image tag and data like this

<div class="maincon">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>

<td width="740" valign="top">
<div class="detailedcon2">
    <body bgcolor="white"><img src="getchart.jsp?img=chart1&id=6C7DB5B1C8FF0CD6C9A9B2DBF787B377_1" style="border:0" usemap="#map1" /><map name='map1'><area shape="rect" coords="195,122,224,220" title='Fri: US$123K'>
<area shape="rect" coords="155,51,184,220" title='Thu: US$211K'>
<area shape="rect" coords="115,76,144,220" title='Wed: US$179.5K'>
<area shape="rect" coords="75,95,104,220" title='Tue: US$156K'>
<area shape="rect" coords="35,152,64,220" title='Mon: US$85K'>
</map>
    </body>
</div>


but chart not able to display in page and i m not getting any red cross image nothing is displaying in webpage.I

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Peter Kwan on Sep-22-2010 22:57
Hi Subodh,

If you are familiar with HTML, you may have noticed that the HTML you attached is invalid. For example, you have a <body> tag inside a <div> tag, which is illegal. (The <body> tag should be under the <html> tag, not under a <div> tag.)

To diagnose the problem, please make sure your code outputs legal HTML. I suggested instead of outputting

<body>
<img src='getchart.jsp....'>
....
</body>

Please change it to:

Hello World 1234<br>
<img src='getchart.jsp....'>
....
Hello World 5678<br>

It may be possible other parts of the web page are also invalid. The "Hello World 1234" and "Hello World 5678" can help to determine if at least the table cell is valid.

Also, you probably are aware that your code needs "getchart.jsp". Please make sure this file is in the same directory as your JSP.

If you can see a valid web page with "Hello World 1234" and "Hello World 5678" using IE, but cannot see the chart image or the red X, please save the entire web page (using File/Save As, and save it as a web archive). This will save the HTML, CSS as well as the empty image.

Also, if possible, for testing, please create a simplified version of your web page for testing. The testing web page should contain just the chart, and should not use CSS, Javascript or other unnecessary HTML tags. This avoids the uncertainty related to CSS, Javascript or other HTML tags.

Regards
Peter Kwan

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-23-2010 03:16
THis is My JSF Page Code

<ui:composition xmlns:jsp="http://java.sun.com/JSP/Page"  xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:c="http://java.sun.com/jstl/core" template="./../Templates/WatchListMainTemplate.xhtml">
<ui:define name="title">ChartDirector Financial Chart Demonstration</ui:define>
<ui:define name="body"  >

    <f:view>
    Hello World 1234<br/>
         <h:graphicImage url='#{MyChart.url}' usemap="#map1" style="border:0" />
         <h:outputText escape="false" value="#{MyChart.imageMap}" />
         Hello World 5678<br/>
    </f:view>

    </ui:define>
    </ui:composition>


And i m able to see the HelloWorld in Web Page But image not viewing and no any red Cross(X) image displaying in the web page and no any exception in Java Class.(This is in the case of Firefox).

While when i test the same Url in IE i see the Red Cross Image.
Hello World 1234
(red cross image in between)
Hello World 5678

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-23-2010 03:34
Thanks Mr. Peter i got the Issue,getChart.jsp file not in the Directory from where i put other Jsp Pages Thats why chart was not working,now i changed according to ur suggestion now test chart   is working.

thanks

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-24-2010 02:27
Attachments:
Hi Mr. Peter,
Firstly Thanks For ur Gr8 help and support to learn to Ur FinancialChart,Now i have Question i want to add tool tip on each individual chart like Volume,Bollinger,SMA  etc.How can i perform this task i added the tool tip in Price Chart i will want same tool tip in other technical indicator chart ,i m also attaching the image plz let me know how this issue will resolve.

thanks
ChartTest.jpg

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Peter Kwan on Sep-24-2010 17:21
Hi Subodh,

Are you using the following way to add the tooltips? It should add tooltips to the main price chart and all technical indicator charts.

imageMap = c.getHTMLImageMap("", "", "title='{xLabel|yyyy-mm-
dd}:{value}'");

Regards
Peter Kwan

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-24-2010 17:28
Hi Mr.Peter right now i m using this way for tool tip
// include tool tip for the chart
String imageMap1 = c
.getHTMLImageMap("", "",
"High:{highData}\\nOpen:{openData}\\nClose:{closeData}\\nLow:{lowData}'");

it is showing tool tip in Only Price Chart not in other chart ,i have to use the way u mentioned in last post? then the tool tip will work for all the charts

thanks

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-28-2010 16:30
Hi Mr. Peter,
                 Waiting For Ur Reply
Thanks

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Peter Kwan on Sep-28-2010 18:16
Hi Subodh,

Sorry for the late reply.

Your current getHTMLImageMap code is incorrect. You can see that the tooltip in your chart is not the tooltip you have configured. (The chart shows Op: Hi: Lo: Cl:, but your configuration is High: Open: Close: Low:.) It is because your configuration does not use the "title" attribute. (The "title" attribute is the HTML attribute for tooltips.)

Please use the code mentioned in my last message instead:

imageMap = c.getHTMLImageMap("", "", "title='{xLabel|yyyy-mm-
dd}:{value}'");

Hope this can help.

Regards
Peter Kwan

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-28-2010 18:31
Hi Mr.Peter,
                 No need to say Sorry.About Code i m putting all my data in the following list
double[] volData;
double[] highData;
double[] lowData;
double[] openData;
double[] closeData;

u told me Use Like this
String imageMap1  = c.getHTMLImageMap("", "", "title='{xLabel|yyyy-mm-dd}:{value}'");

What is the Value here? bcz i have no any such variable "xLabel and value" in my class how can i cofigure above code according to my data.

thanks

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Subodh Joshi on Sep-28-2010 18:38
Sorry Mr peter Tool tip is working How to control the volume tool tip data will display like this 92.78 million currently it is coming like this 92.785678 also can i show volume in THousand.
thanks

  Re: Integrating ChartDir with JSF1.2 And Richfaces
Posted by Peter Kwan on Sep-29-2010 02:32
Hi Subodh,

The FinanceChart currently will choose which scale to use for the volume. It may use millions, thousands or just the plain number as the scale, depending on your data value.

May be you can try the following methods to detect which unit ChartDirector chooses and format the volume chart tooltip accordingly. It is like:

//save the return value in "v" so we can use it layer
XYChart v = myFinanceChart.addVolIndicator(....);

.... draw chart as usual ....

//after adding all indicators to the chart, can layout the chart
myFinanceChart.layout();

//set a tooltip for the volume chart
String anAxisLabel = v.yAxis().getLabel(v.yAxis().getTicks()[0]);
if (anAxisLabels.endsWith("M"))
     v.setHTMLImageMap("", "", "title='{xLabel|yyyy-mm-dd}:{value|P} millions'");
else if (anAxisLabels.endsWith("K"))
     v.setHTMLImageMap("", "", "title='{xLabel|yyyy-mm-dd}:{value|P} thousands");

//general tooltips used by all data series (except the candlestick and the volume bars)
imageMap = myFinanceChart.getHTMLImageMap("", "", "title='{xLabel|yyyy-mm-dd}:{value|P}'");

Hope thie can help.

Regards
Peter Kwan