Moving data from a JTable to a Javascript table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Epix
    New Member
    • Oct 2007
    • 7

    Moving data from a JTable to a Javascript table

    Hi,

    I have a program that is written in Java using swing. There is a JTable that is filled with data that needs to be put into a table on a web site which is written in Javascript. Each cell in the table on the web site is editable. The table in the application it set up to exactly like the one on the web site so it has all the same rows and columns. I have never used Javascript and don't know how to do this. Any help would be greatly appreciated.

    Thanks
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Epix
    Hi,

    I have a program that is written in Java using swing. There is a JTable that is filled with data that needs to be put into a table on a web site which is written in Javascript. Each cell in the table on the web site is editable. The table in the application it set up to exactly like the one on the web site so it has all the same rows and columns. I have never used Javascript and don't know how to do this. Any help would be greatly appreciated.

    Thanks
    What language is your website written in? JSPs? PHP?HTML only?

    Comment

    • Epix
      New Member
      • Oct 2007
      • 7

      #3
      Originally posted by r035198x
      What language is your website written in? JSPs? PHP?HTML only?
      It is written in HTML.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by Epix
        It is written in HTML.
        Create method in some Utility class. Call it createHTMLTable that takes a JTable object as a parameter and returns an HTML table as a String

        [CODE=java]public static String createHTMLTable (JTable jtable) {
        //....
        }[/CODE]

        The method would then simply use a StringBuilder to build the HTML table from the jtable data inserting all the <TR> and <TD> tags where necessary. After that just save that string as a text or html file.

        Can you do that?

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by Epix
          It is written in HTML.
          I don't understand your question: you have a client machine C that receives html
          from a server machine S; you also have a machine J that displays that JTable;
          possibly some of the C, S and J are one and the same machine. You want to
          transfer data from machine J (the JTable thing) to which of the two other machines?
          the client C or the server S that should transfer it again to the client C?

          You do realize that that Javascript you mentioned runs on the client C do you?

          kind regards,

          Jos

          Comment

          • Epix
            New Member
            • Oct 2007
            • 7

            #6
            Originally posted by r035198x
            Create method in some Utility class. Call it createHTMLTable that takes a JTable object as a parameter and returns an HTML table as a String

            [CODE=java]public static String createHTMLTable (JTable jtable) {
            //....
            }[/CODE]

            The method would then simply use a StringBuilder to build the HTML table from the jtable data inserting all the <TR> and <TD> tags where necessary. After that just save that string as a text or html file.

            Can you do that?
            Unfortunately that won't work because I don't have access to any of the code of the website. I need to be able to just post the data from the JTable onto the table in the website.

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by JosAH
              I don't understand your question: you have a client machine C that receives html
              from a server machine S; you also have a machine J that displays that JTable;
              possibly some of the C, S and J are one and the same machine. You want to
              transfer data from machine J (the JTable thing) to which of the two other machines?
              the client C or the server S that should transfer it again to the client C?

              You do realize that that Javascript you mentioned runs on the client C do you?

              kind regards,

              Jos
              I don't suppose they want it done automatically?

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by Epix
                Unfortunately that won't work because I don't have access to any of the code of the website. I need to be able to just post the data from the JTable onto the table in the website.
                "post" using what?

                Comment

                • Epix
                  New Member
                  • Oct 2007
                  • 7

                  #9
                  Originally posted by JosAH
                  I don't understand your question: you have a client machine C that receives html
                  from a server machine S; you also have a machine J that displays that JTable;
                  possibly some of the C, S and J are one and the same machine. You want to
                  transfer data from machine J (the JTable thing) to which of the two other machines?
                  the client C or the server S that should transfer it again to the client C?

                  You do realize that that Javascript you mentioned runs on the client C do you?

                  kind regards,

                  Jos
                  Sorry, I'll make my question more clear. There is a website that is run by another person that needs to be updated by me often by inputting values on the table in the website. I want to make this updating easier by having a program that will update all the fields on the website for me so I just have to press the submit button.

                  I have created a Java application that has a JTable with all of the updated information on it that needs to be put on the website. I need a way for the program to post this information onto the table in the website.

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by Epix
                    Sorry, I'll make my question more clear. There is a website that is run by another person that needs to be updated by me often by inputting values on the table in the website. I want to make this updating easier by having a program that will update all the fields on the website for me so I just have to press the submit button.

                    I have created a Java application that has a JTable with all of the updated information on it that needs to be put on the website. I need a way for the program to post this information onto the table in the website.
                    So you have a means of communication between your computer J (the one that
                    has the JTable) and machine S that needs an updated html file that it can send
                    to clients C?

                    I'd say follow r035198x's advice and have your computer J generate that html
                    file and send it to that server computer S.

                    kind regards,

                    Jos

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Originally posted by Epix
                      Sorry, I'll make my question more clear. There is a website that is run by another person that needs to be updated by me often by inputting values on the table in the website. I want to make this updating easier by having a program that will update all the fields on the website for me so I just have to press the submit button.

                      I have created a Java application that has a JTable with all of the updated information on it that needs to be put on the website. I need a way for the program to post this information onto the table in the website.
                      When you say "post in the website" you mean enter the values into a table on one of the websites's HTML pages?
                      And you don't have acces to the code for that HTML page? I don't see how you can update the table then.

                      Comment

                      • JosAH
                        Recognized Expert MVP
                        • Mar 2007
                        • 11453

                        #12
                        I think I was right from the start: I don't understand the question at all.

                        kind regards,

                        Jos

                        Comment

                        • Epix
                          New Member
                          • Oct 2007
                          • 7

                          #13
                          Originally posted by JosAH
                          So you have a means of communication between your computer J (the one that
                          has the JTable) and machine S that needs an updated html file that it can send
                          to clients C?

                          I'd say follow r035198x's advice and have your computer J generate that html
                          file and send it to that server computer S.

                          kind regards,

                          Jos
                          The only way that I have access to the website is normally through a web browser so I can't sent the server a new html file unfortunately.

                          Comment

                          • JosAH
                            Recognized Expert MVP
                            • Mar 2007
                            • 11453

                            #14
                            Originally posted by Epix
                            The only way that I have access to the website is normally through a web browser so I can't sent the server a new html file unfortunately.
                            So r035198x was right then: it can't be done; compare it with, say, google.com,
                            you can't *force* it to add information to its databases. The initiative is on google's
                            side. The same holds for your machines J and S.

                            kind regards,

                            Jos

                            Comment

                            • Epix
                              New Member
                              • Oct 2007
                              • 7

                              #15
                              Originally posted by r035198x
                              When you say "post in the website" you mean enter the values into a table on one of the websites's HTML pages?
                              And you don't have acces to the code for that HTML page? I don't see how you can update the table then.
                              Yes that is what I mean by post to the website. Thanks for your help. Is there a way to do it using Javascript and PHP protocols or would you still need access to the websites html code for that to work? My coworker says there should be a way to do it using that.

                              Comment

                              Working...