gpt4 book ai didi

GWT JSNI bool 值

转载 作者:行者123 更新时间:2023-12-01 15:01:47 26 4
gpt4 key购买 nike

这是我的代码:

package com.eggproject_hu.WPECommerceAdminSales.client;

import java.lang.Boolean;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;

public class AblakVillogo
{
public static Boolean focusedWindow = true;
private static Boolean init = false;

public static void setFocused(Boolean focus)
{
focusedWindow = focus;
}

public static Boolean getFocused()
{
return focusedWindow;
}

public static void focusVizsgalat()
{
if(focusedWindow == true)
{
GWT.log("igen");
}
else
{
GWT.log("nem");
}
}

public static void init()
{
if(init == false)
{
_init();
}
}

private native static void _init() /*-{
$wnd.jQuery(document).ready(function()
{
$wnd.jQuery($wnd).focus(function()
{
@com.eggproject_hu.WPECommerceAdminSales.client.AblakVillogo::focusVizsgalat()(); @com.eggproject_hu.WPECommerceAdminSales.client.AblakVillogo::setFocused(Ljava/lang/Boolean;)(true);
$wnd.console.log("focus");
}).blur(function()
{
var ret = false;
@com.eggproject_hu.WPECommerceAdminSales.client.AblakVillogo::focusVizsgalat()();
@com.eggproject_hu.WPECommerceAdminSales.client.AblakVillogo::setFocused(Ljava/lang/Boolean;)(false);
$wnd.console.log("blur");
});
});
}-*/;
}

我在浏览器控制台中看到了这个:

uncaught exception: java.lang.IllegalArgumentException: invoke arguments: JS value of type boolean, expected java.lang.Boolean

我已经在 Chrome 和 Firefox 中测试过。

问题是什么?

感谢您的帮助!

最佳答案

您必须将 bool 值声明为原始 bool 值才能从 javascript 设置值

并且您不需要在调用中指定 L/java/lang/Boolean,而是指定 Z

关于GWT JSNI bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6257532/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com