Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    button > onclick > chart open

    Hello fellows!
    I have question.
    Iam doing some project to my school and I have small problem.

    I have chart (iam using jfreechart) in Chart.java file and after user is loading to his profe he should be able to push button and chart wit his statistics should appear. My problem is that I cant form proper onClick function. or mayby
    Code:
    window.parent.location.href
    is wrong used?

    here is code of website when user logged in and he can click on chart button
    Code:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java"%>
    <%@ page import ="java.sql.*" %>
    <%@ page import ="javax.sql.*" %>
    <html>
    <head>
    <link rel="stylesheet" href="style.css" type="text/css"> 
    <script src="../WEB-INF/lib/amcharts.js" type="text/javascript"></script> 
    <title>Successfully Login by JSP</title>
            
    </head>
    
    <body>
        
    <input type=button onClick="parent.location='logOut.jsp'" value='Wyloguj'>
    
    <br>
    Zalogowano pomyslnie<br />
    Twoje dane :<br />
    <%
    out.print("Nazwa uzytkownika :<b>"+session.getAttribute("sUserID")+ "</b>"+"<br>");
    out.print("Imie i Nazwisko :<b>"+session.getAttribute("sUserName")+"</b>"+"<br>");
    out.print("E-mail :<b>"+session.getAttribute("sEmail")+"</b>");
    %>
    
    
    
    <form action="nowe_dane.jsp" method="post">
    <input type="text" name="wynik_badania" /> Poziom cukru z dnia:
    <script language="javascript"> 
    <!-- 
    today = new Date(); 
    document.write(" ", today.getDate(),"/",today.getMonth()+1,"/",today.getYear()); 
    //--> 
    </script> <br>
     <input type="submit" />
    <input type=button onClick="window.parent.location.href = 'src/java/demo/Chart.java' " value='Wykres'>
    
     
    
    
    </body>
    </html>



  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    language=javascript" and document.write have both been obsolete for many years. The <!-- --> around the script is there to hide it from Internet Explorer 2.

    Also input tags are required to be inside forms.

    None of that would be preventing the new .java page loading when someone clicks on the button though.

    The problem is probably on the server in connection with how you have it set to serve .jsp and .java pages.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For tests Iam using chrome,
    When Iam putting for example reg.html or newhtml.html into this onClick form it works perfect, iam just having troubles with Chart.java . Also if I "Run" Chart.java window applet is showing up - so if its stands alone it works too!.

    Iam just having problem with connecting them... ;x

    The problem is probably on the server in connection with how you have it set to serve .jsp and .java pages.
    Can you say somethink more about it?

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,696
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    I don’t know where to move that thread. To JS or Java? In any case, this seems to have nothing to do with HTML or CSS.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by VIPStephan View Post
    I don’t know where to move that thread. To JS or Java? In any case, this seems to have nothing to do with HTML or CSS.
    The JavaScript is irrelevant - all it is doing is calling for a new Java page to load - so this question is more likely to be a problem with the Java code that hasn't been supplied.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mayby there should be some extra informations in web.xml file to run this Chart.java in browser?

  • #7
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,755
    Thanks
    41
    Thanked 191 Times in 190 Posts
    what does Chart.java class look like?

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #8
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    package demo;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.data.jdbc.JDBCCategoryDataset;
    import org.jfree.ui.*;
    
    public class Chart
    {
            public static void main(String[] args) throws Exception 
            {
                    String query = "SELECT Category, value from pieData2";
                    JDBCCategoryDataset dataset = new JDBCCategoryDataset(
                                    "jdbc:mysql://localhost:3306/tabela", "com.mysql.jdbc.Driver",
                                    "root", "root");
    
                    dataset.executeQuery(query);
                    JFreeChart chart = ChartFactory.createLineChart("Badanie Poziomu Cukru", "Numer Badania", "Poziom cukru",
                                    dataset, PlotOrientation.VERTICAL, true, true, false);
                    ChartPanel chartPanel = new ChartPanel(chart);
                    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
                    ApplicationFrame f = new ApplicationFrame("Chart");
                    f.setContentPane(chartPanel);
                    f.pack();
                    f.setVisible(true);
            }
    }

  • #9
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    bump ?

  • #10
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,755
    Thanks
    41
    Thanked 191 Times in 190 Posts
    why are there hard coded values in there?! I am assuming this is an prebuilt skeleton that is an example- you most likely have to change values around to get it to work. Also this now dives into other classes. Wherever you got that library from they should have tutorials on how to use it.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •