ColdFusion.navigate and PIE.htc

Hello, everyone.
I'm not sure if PIE.htc is part of the problem; I am assuming.
But most of the links that appear in Google when using "ColdFusion 9" +"'f' is null or not an object" as the keyword search are links related to PIE.htc.
I have a list of links that load in a cfdiv when clicked.  [onClick = ColdFusion.navigate('doc.cfm?param=blah blah blah','div_name',myCallback,myErrorHandler)]
The first time a link is clicked, no problems whatsoever.
The second time a link is clicked (ANY link), I get the error message 'f' is null or not an object.
Does ColdFusion.navigate clear/delete a JavaScript variable called 'f' when it kicks in?
Any suggestions on what could be causing this?
Thanks,
^_^

The following code works.
Here you go:
I had to make a simple version. I am swamped today.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
<cfajaximport tags="cfinput-autosuggest,cfinput-datefield,
cfajaxproxy, cfpod, cftooltip, cfdiv, cfwindow, cflayout-tab,
cfform,cftextarea">
<script language="javascript">
var orgcallBack = function(){
document.getElementById("orgsection").innerHTML = "This
Works";
var salescallBack = function(){
document.getElementById("").innerHTML = "";
var oppscallBack = function(){
document.getElementById("").innerHTML = "";
<!--- The error handler pops an alert with the error code
and message. --->
var myerrorhandler = function(errorCode,errorMessage){
alert("[In Error Handler]" + "\n\n" + "Error Code: " +
errorCode + "\n\n" + "Error Message: " + errorMessage);
</script>
</head>
<body>
<cfform format="html" name="enterpartner" id="form1">
<cfinput type="text"
name="partnername"
size="35"
style="z-index:1000;"
tabindex="0">
<cfinput type="button" name="Submit" value="Go!"
onClick="javascript:ColdFusion.navigate('testcfdiv.cfm','orgsection',orgcallBack,myerrorh andler,'POST','form1');"
tabindex="1">
<cfinput type="button" name="Print" value="Print"
tabindex="2">
</cfform>
<cfdiv id="orgsection"/>
</body>
</html>
Hope this helps!
Ron

Similar Messages

  • ColdFusion.navigate and unvisited tabs

    I have created a cflayout (type = border). Naturally, I have
    a nifty left side menu, which outputs a query result as a text.
    In the center layoutarea, I have a new layout of two tabs.
    The tabs are named projectOverview and projectTickets
    A link in the left navigation menu is like: <a
    href="javascript:
    ColdFusion.navigate('project.cfm?pid=#id#','projectOverview');
    ColdFusion.navigate('tickets.cfm?pid=#id#','projectTickets')">#projectName#</a>
    Now, when I click the link, the projectOverview tab updates
    contents always, but projectTickets never updates, until I manually
    visit that tab first once. Clicking the left link for the first
    time, and then going to the Tickets tab doesn't show the changes.
    The next clicking will update the tab, because now it was once
    visited.
    How could I get around this issue (a bug?) ?
    Example cflayout that I use currently.
    <cflayout type="border" align="justify">
    <cflayoutarea position="left" name="projectDiv"
    title="Projects" splitter="true"
    collapsible="true" source="projectlist.cfm" size="170"
    maxsize="350">
    </cflayoutarea>
    <cflayoutarea position="center" align="justify"
    overflow="auto" >
    <cflayout type="tab" name="mainarea">
    <cflayoutarea name="projectOverview" title="Project
    Overview" source="project.cfm" selected="true">
    </cflayoutarea>
    <cflayoutarea name="projectTickets" title="Tickets"
    source="tickets.cfm">
    </cflayoutarea>
    </cflayout>
    </cflayoutarea>
    </cflayout>
    And again: The projectTickets source doesn't update until I
    visit that tab once. Then it updates on every click from within
    projectDiv (projectlist.cfm)

    After investigating a bit, it seems that if you don't specify
    the source attribute for a tab, then the ColdFusion.navigate works
    correctly even for an unvisited tab.However, normally a tab loads
    its contents only when it's activated. Previous ColdFusion.navigate
    referrals are overridden when the tab is activated, thus updating
    the content with the original value of source attribute.
    I think this is unwanted behaviour, right?

  • Cfmenuitems no longer work after coldfusion.navigate

    There are times when you want to make slight changes to menus based on what a user does.  It would be nice to simply "refresh" the menu (likely a cfdiv containing a cfmenu) using ColdFusion.navigate(..).  However, if your menu contains cfmenuitems, they no longer appear ("drop down") after performing the navigate. If this is the intended behavior I think it is a major limitation.  (CF9 and CF8)
    code for my_test.cfm:
    <cfajaximport />
    <cfdiv id="myDiv">
    <cfmenu name="my_menu" type="horizontal">
    <cfmenuitem name="options" display="My Options">
    <cfmenuitem name="option1" display="Option 1" href="javascript:ColdFusion.navigate('my_test.cfm','myDiv')" />
    <cfmenuitem name="option2" display="Option 2" href="javascript:ColdFusion.navigate('my_test.cfm','myDiv')" />
    <cfmenuitem name="option3" display="Option 3" href="javascript:ColdFusion.navigate('my_test.cfm','myDiv')" />
    </cfmenuitem>
    </cfmenu>
    </cfdiv>

    It turns out that if you remove any one of the cfmenuitem elements prior to doing the navigate the cfmenuitems work correctly...
    <cfajaximport />
    <script type="text/javascript">
      function myNav() {
                removeElements();
                ColdFusion.navigate('my_test.cfm','myDiv');
      function removeElements() {
              var d = document.getElementById('myDiv');
              var e = document.getElementById('option1');
              d.removeChild(e);
    </script>
    <cfdiv id="myDiv">
      <cfmenu name="my_menu" type="horizontal">
      <cfmenuitem name="options" display="My Options">
      <cfmenuitem name="option1" display="Option 1" href="javascript:myNav();" />
      <cfmenuitem name="option2" display="Option 2" href="javascript:myNav();" />
      <cfmenuitem name="option3" display="Option 3" href="javascript:myNav();" />
      </cfmenuitem>
      </cfmenu>
    </cfdiv>

  • Can you toggle open/close javascript:ColdFusion.navigate?

    I'm looking for a way to toggle open/close a table row within a search query.  I have a table of results and a link to more detailed information. I would like that page to stay within the current page.  I have the ColdFusion.navigate working correctly but wondering if there is a way to close it?
    Here's some of the code I'm using...
    <td><a href="javascript:ColdFusion.navigate('details.cfm?ID=#ID#','detail#q.CurrentRow#')">#q.sl n#, #q.sfn#</a></td>
    <td><cfdiv id="detail#q.CurrentRow#"></cfdiv>
    Message was edited by: Catherine Lesniewski

    It is still unclear what you wish to toggle with what. There are a number of processes going on underneath: the open window, its original content, the content - within the window - coming from  detail.cfm, and the closed window. It may be impossible to toggle between them.
    ColdFusion.navigate() does not create the window. Neither can it open a window. It simply copies output from the page detail.cfm into the already opened window.
    You would therefore need, besides ColdFusion.navigate(), two further events. One to open or re-open the window and one to close it. That makes a total of at least 3 events.
    Here is an example toggling a shown and a hidden window:
    <table>
    <cfoutput query="q">
    <tr><td><a href="javascript:ColdFusion.navigate('details.cfm?ID=#ID#','detail#q.CurrentRow#')">#q.sl n#, #q.sfn#</a></td><td><a href="javascript:ColdFusion.Window.hide('detail#q.CurrentRow#');">Hide</a> | <a href="javascript:ColdFusion.Window.show('detail#q.CurrentRow#');">Show</a></tr>
    </cfoutput>
    </table>

  • Issues with coldfusion.navigate (CF9) in Safari & Chrome

    I am using Coldfusion 9. I have a ColdFusion.navigate call in a cfdiv tag located within a Cflayout tag (type tab).
    The following piece of code is located in a file called "inc_shjobs.cfm" and is being called using the src attribute from a Cflayout tag on another page:
    <script>
            ColdFusion.navigate('inc_shjobs.cfm?morejobs','jobs1')
      </script>
    <cfdiv id="jobs1">
    <form name="ne">   
        <table width="98%" cellspacing="1" cellpadding="6" border="0" bgcolor="white" >
          <tr>
            <td colspan="1" align="center"><br />
    <input type="submit" name="morejobs" style="font-size:1.4em; font-style:bold " value="Expand Job Search" onClick="javaScript:ColdFusion.navigate('inc_shjobs.cfm?morejobs','jobs1');    "></td>
          </tr>
      </tr>
      <tr><td><br /><br /></td></tr>
           <tr><td valign="top">
                 <strong>Search Within</strong> <select name="radius" >
          <option value="0" <cfif session.trn.jsradius is 0> selected</cfif>>0 miles</option>
          <option value="5" <cfif session.trn.jsradius is 5> selected</cfif>>5 miles</option>     
          <option value="10" <cfif session.trn.jsradius is 10> selected</cfif>>10 miles</option>           
          <option value="25" <cfif session.trn.jsradius is 25> selected</cfif>>25 miles</option>                 
          <option value="50" <cfif session.trn.jsradius is 50> selected</cfif>>50 miles</option>                 
          <option value="100" <cfif session.trn.jsradius is 100> selected</cfif>>100 miles</option>                 
          <option value="-1" <cfif session.trn.jsradius is -1> selected</cfif>>Statewide</option>                 
          <option value="-2" <cfif session.trn.jsradius is -2> selected</cfif>>Nationally</option>                 
          </select>
        <input type="submit" name="rad" value="Go" onClick="javaScript:ColdFusion.navigate('inc_shjobs.cfm?radius='+ne1.radius.options[radiu s.selectedIndex].value,'jobs1')">  center of  <strong><cfoutput>#session.trn.city#</cfoutput></strong></td>
    <td  valign="top"><a href="dsp_jobresearch.cfm" ><img src="images/justjobs1.gif" alt="Just Job Search" border="0" /> </a></td>
             </tr>
        </table>
        </form>
        </cfdiv>
    In IE and FF, it behaves approriately by loading only the div. In Chrome and Safary, it reloads the entire page and ignores the parameters. When the same code was run under CF8, it also worked.
    Anyone got a clue as to why?
    Thanks!

    I just tested ColdFusion.navigate on Safari and Chrome (Win 7) and everything works fine.
    I recently ran into that same behavior and it had to do with submitting a form. I set an onSuccess or an onSubmit javascript function, which caused an exception and IE didn't handle it very well. It reloaded the entire page.
    I suspect it has to do with a javascript error. I would start by doing some simple js debugging.

  • Cfgrid & coldfusion.navigate

    I am using a cfgrid and javascript to update a div container.
    I am binding the grid to the javascript with cfajaxproxy.
    When I click on the grid the appropriate record should show
    in the div contain and it does. The problem is that the div
    container flashes therefore it is not seamless. I am using
    Coldfusion.navigate to pass appropriate parms to the page that
    needs to load into the div container. Here is the code that I am
    using. I hope that someone has a clue how I can fix this because I
    apparently am clueless......
    Grid Code followed by the javascript code:

    oops, I had two arguments inverted..
    Should have been...
    ColdFusion.navigate('/cf8/text.cfm','myDiv',mycallBack,myerrorHandler,'POST','form1')

  • Coldfusion.navigate moving my browser scrollbar

    I have a little Ajax application to build a document a
    section at a time. It works great except whenever I use
    Coldfusion.navigate to reload my <cflayout type="vbox"> the
    whole page automatically scrolls to the top of the page. Is there
    any way to "lock" the scroll bar in position so it will not move
    when reloading a container? Alternatively is there a way to pass an
    anchor through this function? So far I can't get it to work.

    If you can't see half of your page, it's probably in your
    code. Sounds like
    a tag of somesort hasn't been closed.
    As Ade said, post a link to your page, or put the page
    through the validator
    http://validator.w3.org/ this
    may pick up your problem.
    Nadia
    Adobe� Community Expert : Dreamweaver
    http://www.DreamweaverResources.com
    |Tutorials|SEO |CSS Templates
    http://www.csstemplates.com.au
    http://www.adobe.com/devnet/dreamweaver/css.html
    CSS Tutorials for Dreamweaver
    > Hello, I was editing a new template and doing fine until
    SOMETHING in
    > dreamweaver altered my browser settings and now when you
    click on ' view
    > page"
    > in IE browser I have lost the scroll bar and can no
    longer access half of
    > my
    > page. ITS GONE. I have gone over the code dozens of
    times, I even
    > downloaded a
    > new template and still I cannot get the scrollbar to
    show.
    >
    > I have tried to work on this for a week contacting the
    template people and
    > my
    > hosting. While I was working on another page I put my
    cursor over an area
    > on
    > my page where some of the borders were.... just looking
    around at
    > different
    > areas but NOT altering ANYTHING. When I went to close
    that page a notice
    > came
    > up from DREAMWEAVER that ' Settings for the browser had
    been altered did
    > I
    > want to save them?" SEEING THIS ALARMED ME that this may
    be the problem
    > so I
    > said NO and the page was okay. However this may have
    been what happed on
    > my
    > index.html page. Even tho I didnt type or edit ANYTHING
    on the page at
    > the
    > time. I was moving the cursor around on the ' design"
    protion looking at
    > varioius areas on the template.
    >
    > THIS MAY HAVE BEEN WHAT ALTERED MY PAGE and now I cant
    see ' half of my
    > index.html page and there is no scroll bar.
    >
    >
    > PLEASE HELP I have gone everywhere to get some help
    >
    >

  • ColdFusion.navigate call JS function

    Hi,
    I use ColdFusion.navigate to call a cfc method. In this function, it loads a list from database and set the div innerhtml to the list content.
    Then, get the list and it can do the confirmation function.
    However, I find that it always call the confirmation function before loading the list complete.
    What I use is the following:
    ColdFusion.navigate('cfc/control.cfc?method=findSimilarName&new_name='+encodeURIComponent( document.getElementById('name').value),'tempMessage', confirmUpdate(i));
    findSimilarName method will set the similar name list to a div named similarName. And I will use it to do the confirmation.
    Is there any method to force ColdFusion.navigate calling my confirmation function after the findSimilarName method completed?

    Hi Mehdi,
    I'm not really sure what you mean here, but let me suggest a solution.
    I fyou want to execute javascript at the end of a request you can use the ExtendedRenderKitService.
    This makes it possible to add a javascript function call from within javacode.
    Example:
    You have a javascript function named "pressButton"
    <af:resource type="javascript">
         function pressButton() {
             var component = AdfPage.PAGE.findComponentByAbsoluteId("pt1:pt_region0:1:r4:0:cb1");
             AdfActionEvent.queue(component, component.getPartialSubmit());
    </af:resource> Now you want to call that function from within javacode using the ExtendedRenderKitService;
    public void actionListener(ActionEvent actionEvent) {  
         FacesContext context = FacesContext.getCurrentInstance();
         AdfFacesContext.getCurrentInstance().isPartialRequest(context)) {
         ExtendedRenderKitService erks = Service.getRenderKitService(context, ExtendedRenderKitService.class);
         erks.addScript(context, "pressButton();");
    } good luck
    Luc Bors

  • ColdFusion.navigate with POST form submission

    I need to refresh the entire page, so I am not using any div
    on my javascript, I am using the following line.
    ColdFusion.navigate(AjaxFormAction, null, callback,
    errorHandler, 'post', 'LocCondByQtr')
    there is no error but, the whole form is being submit as GET
    not POST.
    I see my form variables in the url, I need those in the form
    scope, any idea where I am doing wrong?
    My form name is "LocCondByQtr" and the action for that page
    is save in "AjaxFormAction" variable.
    I am also using the grid on my form as well.
    Please advise.
    Thanks,

    I believe the answer is that the JSP page after put together with other jsp pages via 'includes' should contain only one <form> tag. The outer most JSP should have the form tag. The inner jsp pages should not. Note all tags on the completed jsp page need to have unique names (to avoid name collisions).

  • How to create bar and pie graph from a backing bean in ADF

    HI,
    my requirement is to populate a line and pie graph based on a collection in a backing bean.
    I got the solution for the bar graph with setTabularData(list data) method in one of the thread.
    For bar graph,
    i constructed the list for the setTabularData(list) method but it is not working with the line and pie graph.Coul'd you explain why?..
    Is it different for the line and pie graph.I don't want to use adf bindings.
    thanks in advance.
    Anil.G

    HI,
    my requirement is to populate a line and pie graph based on a collection in a backing bean.
    I got the solution for the bar graph with setTabularData(list data) method in one of the thread.
    For bar graph,
    i constructed the list for the setTabularData(list) method but it is not working with the line and pie graph.Coul'd you explain why?..
    Is it different for the line and pie graph.I don't want to use adf bindings.
    thanks in advance.
    Anil.G

  • ColdFusion 11 and Solr

    I just installed ColdFusion 11. I am pretty sure I selected the option to install the addons like Solr, but when I am in the coldfusion administrator under Data & Services, I click ColdFusion Collections and I get nothing. It won't go to the page at all. If I click on Solr Services a page will come up. If I click on ColdFusion collections and then restart the coldfusion addons I get a page that comes up saying
    "Unable to retrieve collections from the Search Services.Ensure that you have installed ColdFusion Search Service and it is running."
    I am assuming it means it isn't installed.
    So I went to Adobe - ColdFusion Support Center : More Downloads and downloaded/installed the Windows Add-on Services Standalone Installer. I didn't change any of the settings or folders and installed it. I restarted the server. I logged back into the coldfusion administrator and I see the same thing. Nothing changed. When I go to view the file folders I have c:coldfuion11 and a c:coldfusionAdd-onServices. Should the coldfusionAdd-onServices folder been within the coldfusion11 folder?
    I read you can create your collection through the administrator or through coding a page. I thought maybe I need to try it this way. So I created a page to create the collection and it did not work either.
    What am I missing? Did I miss a step or something to make this work?
    Any help I can get, I would appreciate.
    I have a windows 2008 server.

    Here are just a few of the solr files for you to look at. They all appear to be SUCCESSFUL.
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\abc
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\abo
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\backup
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\backupcleaner
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\commit
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\optimize
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\readercycle
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\rsyncd-disable
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\rsyncd-enable
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\rsyncd-start
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\rsyncd-stop
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\scripts-util
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\snapcleaner
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\snapinstaller
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\snappuller
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\snappuller-disable
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\snappuller-enable
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\bin\snapshooter
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\conf\admin-extra.html
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\conf\elevate.xml
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\conf\mapping-ISOLatin1Accent.txt
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\conf\protwords.txt
                              Status: SUCCESSFUL
    Install File:             C:\ColdFusion11\cfusion\jetty\solr\conf\schema.xml
                              Status: SUCCESSFUL
    On the coldfusion-out.log file it all appears ok as well.
    I can see things like this that shows solr is starting:
    Apr 6, 2015 15:16:54 PM Information [localhost-startStop-1] - Starting jaxrs...
    Apr 6, 2015 15:16:54 PM Information [localhost-startStop-1] - Starting graphing...
    Apr 6, 2015 15:16:55 PM Information [localhost-startStop-1] - Starting solr...
    Apr 6, 2015 15:16:55 PM Information [localhost-startStop-1] - Starting archive...
    Apr 6, 2015 15:16:55 PM Information [localhost-startStop-1] - Starting document...
    Apr 6, 2015 15:16:55 PM Information [localhost-startStop-1] - Starting eventgateway...
    Apr 6, 2015 15:16:55 PM Information [localhost-startStop-1] - Event Gateway Disabled.
    I can see on this same log, when I am in the coldfusion administrator I click on ColdFusion Collections I see this:
    Apr 24, 2015 10:12:21 AM Error [ajp-bio-8014-exec-6] - The request has exceeded the allowable time limit Tag: cfoutput The specific sequence of files included or processed is: C:\ColdFusion11\cfusion\wwwroot\CFIDE\administrator\solr\index.cfm, line: 331

  • Setting Up IIS 5.1 for ColdFusion 9 and Setting Up ColdFusion 9 for IIS 5.1

    Can someone point me in the direction of instructions for setting up IIS 5.1 for ColdFusion 9 and setting up ColdFusion 9 for IIS 5.1

    I Googled "coldfusion 9 iis 5" and the first result is a detailed set of instructions on how to do it.

  • Bar and Pie chart  display with values

    Hi All...
    I want implement the my swing application Bar and Pie chart functionality with vales, If both are disply same veues.
    Thanx to Advance
    Arjun

    www.jfree.org

  • Plot line, bar and pie chart

    Anyone can let me know where can i learn or tutorial on how to plot line, bar and pie chart by using java2D... (no third-party software)....
    thanks in advance.

    Here's a pie chart app I made for an earlier question:
    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChart {
      public static void main(String[] args) {
        int[] data = {
          18, 95, 102, 87
        PieCharter pie = new PieCharter();
        pie.enterData(data);
        JFrame f = new JFrame("Pie Chart");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(pie);
        f.setSize(400,300);
        f.setLocation(300,300);
        f.setVisible(true);
    class PieCharter extends JPanel {
      int[] data, percents;
      int dataTotal;
      final int
        PAD = 25,
        R_PAD = 5;
      public PieCharter() {
        setBackground(Color.white);
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        Font font = new Font("lucida sans unicode", Font.PLAIN, 16);
        g2.setFont(font);
        FontRenderContext frc = g2.getFontRenderContext();
        int width = getWidth();
        int height = getHeight();
        int cx = width/2;
        int cy = height/2;
        int dia = (int)Math.min(width, height) - 2*PAD;
        g2.draw(new Ellipse2D.Double((width - dia)/2, (height - dia)/2, dia, dia));
        // draw zero datum
        double radians = 0;
        int x = cx + (int)((dia/2) * Math.cos(radians));
        int y = cy - (int)((dia/2) * Math.sin(radians));
        g2.draw(new Line2D.Double(cx, cy, x, y));
        String s;
        int dataWidth, dataHeight, deltaR, rXInc, rYInc;
        for(int i = 0; i < data.length; i++) {
          radians += 2*Math.PI * data/dataTotal;
    x = cx + (int)((dia/2) * Math.cos(radians));
    y = cy - (int)((dia/2) * Math.sin(radians));
    g2.draw(new Line2D.Double(cx, cy, x, y));
    s = String.valueOf(percents[i]) + "%";
    dataWidth = (int)font.getStringBounds(s, frc).getWidth();
    dataHeight = (int)font.getLineMetrics(s, frc).getAscent();
    deltaR = (int)Math.sqrt(dataWidth*dataWidth + dataHeight*dataHeight)/2 + R_PAD;
    rXInc = (int)(deltaR * Math.cos(radians));
    rYInc = (int)(deltaR * Math.sin(radians));
    x += rXInc;
    y -= rYInc;
    x -= dataWidth/2;
    y += dataHeight/2;
    g2.drawString(s, x, y);
    s = String.valueOf(data[i]);
    dataWidth = (int)font.getStringBounds(s, frc).getWidth();
    dataHeight = (int)font.getLineMetrics(s, frc).getAscent();
    x = cx + (int)((dia/4) * Math.cos(radians - 2*Math.PI * data[i]/(2*dataTotal)));
    y = cy - (int)((dia/4) * Math.sin(radians - 2*Math.PI * data[i]/(2*dataTotal)));
    x -= dataWidth/2;
    y += dataHeight/2;
    g2.drawString(s, x, y);
    private void prepareData() {
    for(int i = 0; i < data.length; i++)
    dataTotal += data[i];
    percents = new int[data.length];
    int dataPlus = 0;
    for(int i = 0; i < data.length; i++) {
    dataPlus += data[i];
    percents[i] = Math.round(100 * dataPlus/dataTotal);
    public void enterData(int[] data) {
    this.data = data;
    prepareData();
    repaint();

  • Bar Chart and Pie Chart

    Hi!
    In My application i want to create few bar and pie chart.
    If is there any code for generating bar and pie chart,
    pl send me.
    If third party software is available tell me the details of it.

    Sure, this functionality would be nice to have right
    out of the box, but when you think about it: should
    Sun be distributing a reporting SDK and promoting bad
    practices anyhow? Implementing your reporting in
    disparate and distributed manners is just plain messy
    and definitely translates to a bad practice. Turning
    to a centralized reporting mechanism, driven by a
    reporting server that can handle the needs for 80% of
    your requirements is a helluva lot more thoughtful and
    mindful than implementing separate mini reporting
    engines encapsulated within each and every application
    that you deploy.Elegantly stated! On a practical point, my company built an Enterprised based reporting solution on top of Java technology within the windows environment (please be kind). Specifically we used Java, ASP and Javascript (no VBScript), and delivered the information using the Microsoft IE 4 and 5.
    However, since Microsoft chose to elminate Java from it's current browser (IE6), we have to throw two years of coding away. We are now in the process of moving backward (technically speaking) to a desktop reporting model using Java (no browser technology) that accesses an Enterprise database, or embedded Java database. None of our customers are using Netscape, so that was never an option. Microsoft's and Sun's inablity to cooperate almost decimated our company's product line (and it still may).
    So I agree with you that an Enterprise server based reporting solution is the best architecture, and yet here I am running away from it after a two year struggle with competing standards. Sometimes the best solution loses for reasons that are simply not technical in nature.

Maybe you are looking for