Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to retrieve data from the HTML form in the JEditorPane?

843804May 2 2003 — edited Oct 13 2004
I could quite easily use JEditorPane to render and display a simple HTML file.
My HTML looks like this:

<html>
<head>
<title> simple form</title>
</head>

<body bgcolor="cccccc">
<center><h1>SURVEY THING</h1>
</center>

<form id="survey">
<p>1.Type something in.</p>
<textarea cols=25 rows=8>
</textarea>
<BR>
<p>2.Pick ONLY one.</p>
<input type="radio" name="thing" value="0" Checked> NO choice <BR>
<input type="radio" name="thing" value="1"> First choice <BR>
<input type="radio" name="thing" value="2"> Second choice
<BR>
<p>3.Pick all you like.</p>
<input type="checkbox" name="stuff" value="A"> A <BR>
<input type="checkbox" name="stuff" value="B"> B <BR>
<input type="checkbox" name="stuff" value="C"> C <BR>
<input type="submit" value="give data">
<input type="reset" value="do clensing">
</form>
</body>
</html>

It gets diplayed fine and I can type in text, select radio buttons (they behave mutualy-exclusive,
as they should) and check checkboxes.
The problem I have is with retrieving the values which were entered into the form.
If I, after editing, try to write the html to the file using HTMLWriter,
it records the changes I made into the textarea, however all the radio and checkbox selections are lost.
Maybe the problem is that when I enter the values I do not use any methods like
insertBeforeStart and so on, but I believe I shouldn't need to use them to populate a form.
Especially I never change the structure of the HTML.
Also, when I try to traverse the Element tree and see the input elements attributes,
I can never see a change in the entered values. However it is probably b/c I am traversing through
the model and the changes are in the view (just a guess.)
Anyway, if anybody could direct me onto the right path: how to retrieve the values typed in the form,
or if it is possible at all in the JEditorPane, I would greatly appreciate.

thanks

maciej

PS. I have seen the answer to a similar question posted some time last year. However, I am trying
to find a soultion which allows forms/surveys to be built by people who have no java and only basic
html knwledge. And Axualize way is probably a little bit too "high-tech."
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2004
Added on May 2 2003
1 comment
364 views