Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript in JEditorPane - Best practises?

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I would like to get some opions on the best practises for what I would like to acheive.

I have A JEditorPane that shows a HTML page. On this HTML page are check boxes that the user interacts with. On the click of a button on the HTML page, I need to write the user's selection to a file. (I don't want to use an Applet!)

To acheive this I have found a few ways that I could do it.

1) Use Javascript to call a Java function that resides in the same place that loads the HTML page (ie a class in my application.)
2) Use javascript to call a java function that is in the html page.

I thought about doing it all in Javascript but apparently you can't write files unless the applet is signed and I'm not using an applet.

Kind regards,
Rachel
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question: where are you getting the interpretor for the JavaScript from? Are you writing it too? JavaScript isn't part of HTML, so the HTMLEditorKit will just see it as plain text. Sounds like what you are writing is a browser, which is a big, complex job. If that's true, what do you hope to gain from not using IE/Mozilla/Opera etc.?
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't actually believe that I overlooked that the pane wont interpret Javascript!

Just to elaborate on what I'm doing because I'm not doing a browser (thank goodness!)

I'm writing a communications application. It has email, weather and news and gets the information on demand from a central server.

The original application was written in VisualBasic and I'm trying to hold as much of the old look in the new application. And one of these items is this News section, and more specifically the registration page. (So that's why I'm not using IE or the likes.)

Now, the news section is made up of HTML pages. So on the news tab (it's designed on a tabbed pane) I have a menu on the left and the content on the right. For the registration part of the News, I need the user to click on a checkbox if he wants to receive that item of news. Then the user pushes a button and the file is saved so that it can be sent back to the server later on.

That's what I'd like to do as it is what the origianl application does. If it's not possible, then I'll just have to change it.

Thanks,
Rachel
[ August 10, 2004: Message edited by: Rachel Swailes ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds difficult without actually writing a browser. I'll bet your original VB app was using IE in the background to do this too. What you could do is embed Gecko into your app. I hear its not too difficult - but then I've never done it myself.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul.

I'll give it a bash and see how it goes.

Thanks again!
Rachel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic