Tag: 绑定

在Java中嵌入Groovy(绑定)

我尝试将变量绑定到Groovy并从Groovy绑定到Java Java: Java代码: Binding binding = new Binding(); binding.setVariable(“SRESULT”, “foo”); GroovyShell gs = new GroovyShell(binding); gs.evaluate(script); String sResult = (String) gs.getContext().getVariable(“SRESULT”); System.out.println(“FROM GROOVY: ” + sResult); Groovy代码: class Est { static SRESULT public static void main(String[] args) { println ‘From Java: ‘+SRESULT SRESULT = ‘bar’ } } 输出: From Java: foo FROM GROOVY: foo 我的问题:我想在Groovy中更改SRESULT并可以访问Java中的Value。 […]

JavaFX绑定不是要控制的属性成员

想象一下,我有一个像POJO: public class Person() { private int id; private String name; public int getId() { return this.id; } public String getName() { return this.name; } } 如果我需要使用bind()方法将name成员绑定到JavaFX标签,我无法应用,因为我需要和可观察的值。 我知道我可以使用StringProperty而不是String,但我需要原始类型,因为我使用Hibernate并且我不知道Hibernate是否可以支持JavaFX的属性来映射来自DB的数据。 我必须将哪些替代方法从我的pojo绑定到JavaFX控件?

不同属性的双向绑定

我只是试图绑定一个Integer和一个String属性。 经过一些谷歌搜索后,应该可以使用以下两种方法之一: public static void bindBidirectional(Property stringProperty, 属性otherProperty,StringConverter转换器) public static void bindBidirectional(Property stringProperty, 属性otherProperty,java.text.Format格式) 不幸的是,这似乎对我不起作用。 我究竟做错了什么? import java.text.Format; import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.util.converter.IntegerStringConverter; public class BiderectionalBinding { public static void main(String[] args) { SimpleIntegerProperty intProp = new SimpleIntegerProperty(); SimpleStringProperty textProp = new SimpleStringProperty(); Bindings.bindBidirectional(textProp, intProp, new IntegerStringConverter()); intProp.set(2); System.out.println(textProp); textProp.set(“8”); System.out.println(intProp); } […]

JGoodies Binding vs. JSR 295

JGoodies Binding和JSR 295,Beans Binding有什么实际区别? 它们似乎都是出于同样的目的而完成工作(采用略有不同的方法)。 JGoodies Binding更加成熟,但JSR 295最终将成为Java 7中JDK的一部分。 使用JDK的标准部分肯定比使用单独的库来实现相同的function更好,但还有其他因素需要考虑吗? 还有其他一些选择吗? 选择这些是非常不可逆转的架构决策……

不能与控件一起使用的JavaFX双向绑定变得不可编辑

给一个非常基本的类(导入解析为javafx包): public class T07 extends Application implements Initializable{ 一些字段表示.fxml文件中定义的控件: @FXML TextField text01; 以及以最基本的方式使用Property包装器的数据模型: public static class DataModel { StringProperty first = new SimpleStringProperty(); //getter public String getFirst() {return first.get();} //setter public void setFirst(String first) {this.first.set(first);} //new “property” accessor public StringProperty firstProperty() {return first;} } 我尝试将ui控件与初始化中的数据模型绑定: @Override public void initialize(URL arg0, ResourceBundle arg1) { Bindings.bindBidirectional(text01.textProperty(), dm.firstProperty()); […]

地址重用不适用于新的Java Runtime Environment

我使用以下代码检查地址可重用性: – import java.io.IOException; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; public class CheckBind { public static void main(String[] args) { Thread serverThread = new Thread(new Runnable() { @Override public void run() { try { ServerSocket server = new ServerSocket(); server.setReuseAddress(true); server.bind(new InetSocketAddress(“127.0.0.1”, 2000)); System.out.println(“Server Listen: “+server.getLocalSocketAddress()); while(true) { Socket client = server.accept(); System.out.println(“”+client.getRemoteSocketAddress()); System.out.println(“”+client.getLocalSocketAddress()); } […]

JSon模式和inheritance

我已经使用带有inheritance的java绑定搜索了json模式,所有搜索都让我使用了“allOf”。 使用allOf可能会解决我的问题,但我想知道在json架构中是否有一个我可以使用的构造,它将使用真正的javainheritance“B extends A”生成我的java代码 – 而不是从B内部的A内联所有属性? 我想知道这是否支持/可行,或者我只是在做梦。 如果不支持,我很想知道原因。

从PHP5调用Java方法

曾经有一个PHP扩展可以加载Java库并调用其中的方法。 那是PHP 4。 有没有办法在PHP 5中做同样的事情?

xjc:两个声明在ObjectFactory类中导致冲突

运行以下xjc命令会引发错误: $ xjc “ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd” parsing a schema… compiling a schema… [ERROR] Two declarations cause a collision in the ObjectFactory class. line 340 of ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd [ERROR] (Related to above error) This is the other declaration. line 475 of ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd 虽然我理解JAXB绑定以及XJC中存在什么冲突,但我不明白当前模式中的冲突在哪里。 我应该怎么解决这个问题? 谢谢, 皮埃尔 更新:这里是错误的上下文: $ curl -s “ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd” | sed ‘s/^[ \t]*//’ | cat -n | […]

类路径包含多个SLF4J绑定

我的应用服务器ibm websphere。 我在应用程序服务器日志中收到以下错误。 我在哪里可以进行websphere设置? [19.09.2012 14:56:54:940 EEST] 0000000a SystemErr R SLF4J:类路径包含多个SLF4J绑定。 [19.09.2012 14:56:54:940 EEST] 0000000a SystemErr R SLF4J:在[wsjar:file:/ C:/Lib/slf4j-log4j12-1.6.1.jar!/ org / slf4j / impl / StaticLoggerBinder中找到绑定。类] [19.09.2012 14:56:54:941 EEST] 0000000a SystemErr R SLF4J:在[bundleresource://217.fwk37356669:1 / org / slf4j / impl / StaticLoggerBinder.class]中找到绑定 [19.09.2012 14:56:54:941 EEST] 0000000a SystemErr R SLF4J:请参阅http://www.slf4j.org/codes.html#multiple_bindings以获得解释。