JDK-4465905 : JEditorPane("html/text") with HTML FORM INPUT
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-06-04
  • Updated: 2002-01-15
  • Resolved: 2001-07-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Related Reports
Relates :  
Description

Name: bsC130419			Date: 06/04/2001


java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

1.) When entering text in the first html input element, then the cursor
immediately moves to the next input element.

2.) The Tab-Key does not work at all.

3.) Why do I not get a HyperlinkEvent when pressing the submit button?
    With an URL like: menu.html?fname=foo&lname=bar&submit


import java.awt.*;
import javax.swing.event.*;
import javax.swing.*;

class Frame extends JFrame {
  Frame() {
    super("Html Test");
    String htmlText =  "<html><body>\n"+
                       "<H1>Login:</H1>\n"+
                       "<form action='menu.html' method='post'>\n"+
                         "<p>First name: <input type='text'
name='fname'></p>\n"+
                         "Last name: <input type='text' name='lname'><br>\n"+
                         "<input type='submit' name='submit'>\n"+
                       "</form>\n"+
                       "</body></html>";

    JEditorPane browser = new JEditorPane("text/html",htmlText);
    browser.setEditable(false);
    getContentPane().add(browser);
    browser.addHyperlinkListener( new HyperlinkListener(){
      public void hyperlinkUpdate(HyperlinkEvent ev) {
        System.out.println(ev.getURL());
      }
    });
  }

  public static void main(String[] args) {
    Frame frame = new Frame();
    frame.setLocation(250,200);
    frame.setSize(360,300);
    frame.setVisible(true);
  }
}

  Comments to 1.)
The immediate cursor move to the next element arises only if the element is
encapsulated within a paragraph tag. When replacing <p> by <br> then the cursor
remains in the current element.
This used to work fine in pre jdk1.4 releases.

  Comments to 3.)

There was never an offical way to retreive the html form intut data from the
document. I found several request/questions on that topic in the "Java
Discussion Forums" but no solution for it.
So please either add a way to collect this data from html forms, or if one
already exists, then document it so that one can find it easily.
I think sending a HyperlinkEvent (with an URL that keeps the form data in the
query part) would be a good and backward compatible solution.
(Review ID: 125734) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2 VERIFIED IN: merlin-rc1
14-06-2004

WORK AROUND Name: bsC130419 Date: 06/04/2001 None. ======================================================================
11-06-2004

EVALUATION This bug report comprises a number of problems: 1) This is happening because focus will now be moved from a Component when it is removed from the containment hiearchy. When you type a character in a text field inside a JTextComponent invalidate is invoked on the JTextField. This in turn invokes preferencedChanged on a ComponentView which ends up recreating the Row, which will end up temporarily removing the text field and then adding it back. This then causes the focus to be lost. The fix for this is in BasicTextUI.setSize to remember the focus owner, and if it is a descendant to request focus on it again. On build 69 this doesn't work due to bug 4454331, which will fix the Windows side, for Solaris/linux bugs 4465508 and 4449510 will make this not work. 2) This is because of the new focus architecture. JEditorPane resets the focus traversal keys (it use to override isManagingFocus) which effects all children components, not just the JEditorPane and thus tab no longer works. This can be fixed by explicitly setting the focus traversal keys of the children, or doing this in ComponentView.Invalidator or perhaps making JEditorPane be better about this (conditionally return something from getFocusTraversalKeys). ComponentView will now override getFocusTraversalKeys to skip those of the JEditorPane. 3) FormView will do a post or directly open a connection to the url. A post doesn't fit with the HyperlinkEvent, but a get would. I'll file a separate RFE on this as this is really a completely different issue from the previous two. scott.violet@eng 2001-06-22
22-06-2001