2 Replies Latest reply: Oct 1, 2013 4:43 PM by jsmith RSS

    JavaFX Webengine not validating the form using javascripts loaded from the URL

    user13425887

      Hi,

       

      I am working on Javafx Webiew in swing application.

      I have created an Webview and loading an URL but when we submit the form, the javascripts validation should be done but they are not done in the background.

      Generally if I load that URL in chrome browser and hit submit, it show error for required fields. But its not working in the webview.

       

      I have tested by enabling the firebug, the scripts get loaded but the validation is not done.

       

      Can you let me know is there anything that I need to enable to execute the scripts loaded from the URL to work in the webengine

       

      Thanks

      Abhi

        • 1. Re: JavaFX Webengine not validating the form using javascripts loaded from the URL
          user13425887

          I was debugging the issue. I have some more information.

           

           

          The HTML5 attribute for input tag "required" is not working in the JavaFX webview webengine.

           

           

          Username: <input type="text" name="usrname" required="required" >

           

           

          when the html page that has this attribute is loaded in webengine and submitted it not generating the "Please fill out this field". The form is getting submitted and the next page is loaded

           

          I was reading online JavaFX 2.2 supports HTML 5 but this attribute is not working can any one help me to fix this issue.

          • 2. Re: JavaFX Webengine not validating the form using javascripts loaded from the URL
            jsmith

            > The HTML5 attribute for input tag "required" is not working in the JavaFX webview webengine.

             

            You're right, it doesn't work.

            Log a tweak request against the WebView project.

            https://javafx-jira.kenai.com/secure/Dashboard.jspa

             

            import javafx.application.Application;
            import javafx.scene.Scene;
            import javafx.scene.web.WebView;
            import javafx.stage.Stage;
            
            public class WebViewFunctionTest extends Application {
                public static void main(String[] args) { launch(args); }
            
                @Override
                public void start(Stage stage) {
                    final WebView webView = new WebView();
                    webView.getEngine().load(
                            "http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_required"
                    );
                    stage.setScene(new Scene(webView));
                    stage.show();
                }
            }
            
            

             

            > I was reading online JavaFX 2.2 supports HTML 5

             

            WebView supports most of the HTML 5 functionality, but not the required attribute.

             

            Anyway HTML 5 is just one of those specs that nobody completely implements, so nobody really supports it.

              The HTML5 test - How well does your browser support HTML5?

            HTML 5 is also a "living standard", so the standard changes over time ahead of the implementations.

              FAQ - WHATWG Wiki - Living Standard

             

            In particular the required attribute is just a proposed feature in a draft specification that is poorly supported across browsers:

              http://caniuse.com/#search=required

             

            ----

             

            So basically, you need to:

              a) File a tweak request against the JavaFX project.

              b) Implement fallback javascript code for your web page for client side validation.

            You can get assistance with (b) by posting questions on a JavaScript forum.