JavaFX的web视图不支持Ajax的Web功能 [英] javafx webview not supporting Ajax web features

查看:1086
本文介绍了JavaFX的web视图不支持Ajax的Web功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用JavaFX web视图中打开网页。它打开网页正常,但其不支持像局部刷新和新窗口弹出处理的基于Ajax的Web功能 我现在用的是下面的code

 最后一批又一批=新集团();
  一幕一幕=新场景(组);
  fxpanel.setScene(场景);
  的WebView的WebView =新的WebView();
  。group.getChildren()加(的WebView);

  ENG = webview.getEngine();
  eng.setJavaScriptEnabled(真正的);




    尝试{

            字符串URL =htt​​p://www.abc.com;
            eng.load(URL);
            eng.setCreatePopupHandler(
            新的回调< PopupFeatures,WebEngine>(){
            @覆盖
            公共WebEngine调用(PopupFeatures配置){
            smallView =新的WebView();
            smallView.setFontScale(0.8);

            ChatPopup FRM =新ChatPopup(sm​​allView);
            frm.setBounds(0,0,400,250);
            frm.setVisible(真正的);
            返回smallView.getEngine();

            }
        });





       }
  赶上(例外前){}

             }
 

解决方案

的WebView不支持Ajax的。

  1. 运行下面的应用程序。
  2. 从服务器将数据装载到格点击按钮。
  3. 在页面将被刷新为从服务器获取数据。

 进口javafx.application.Application;
引入静态javafx.application.Application.launch;
进口javafx.scene.Scene;
进口javafx.scene.web.WebView;
进口javafx.stage.Stage;

公共类WebViewAjax扩展应用{
  公共静态无效的主要(字串[] args){发射(参数); }
  @覆盖公共无效开始(第一阶段阶段){
    的WebView web视图=新的WebView();
    webView.getEngine()加载(http://www.jquerysample.com/#BasicAJAX);

    最后一幕一幕=新场景(web视图);
    stage.setScene(场景);
    stage.show();
  }
}
 

I am trying to open webpage in webview using JavaFx . Its opening the web page properly but its not supporting the Ajax based web features like partial refreshing and new window popup handling I am using the following code

  final Group group= new Group();
  Scene scene= new Scene(group);
  fxpanel.setScene(scene);    
  WebView  webview = new WebView ();
  group.getChildren().add(webview);

  eng= webview.getEngine();
  eng.setJavaScriptEnabled(true);




    try{

            String url="http://www.abc.com";
            eng.load(url);
            eng.setCreatePopupHandler(
            new Callback<PopupFeatures, WebEngine>() {
            @Override
            public WebEngine call(PopupFeatures config) {
            smallView = new WebView();
            smallView.setFontScale(0.8);

            ChatPopup frm = new ChatPopup(smallView);
            frm.setBounds(0,0,400,250);
            frm.setVisible(true);
            return smallView.getEngine();

            }
        });





       }
  catch(Exception ex){}

             }

解决方案

WebView does support Ajax.

  1. Run the following app.
  2. Click on the "Load data from server into div" button.
  3. Page will be refreshed with data fetched from the server.

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewAjax extends Application {
  public static void main(String[] args) { launch(args); }
  @Override public void start(Stage stage) {
    WebView webView = new WebView();
    webView.getEngine().load("http://www.jquerysample.com/#BasicAJAX");

    final Scene scene = new Scene(webView);
    stage.setScene(scene);
    stage.show();
  }
}

这篇关于JavaFX的web视图不支持Ajax的Web功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆