如何在对话框中添加类似addCloseHandler的内容,以便在单击ESC键时关闭?
是否可以指定一个返回实现两个或多个接口的对象的方法?
假设我们有以下接口:
interface FooBar {
[Foo] & [Bar] getFooBar();
}
interface Foo {
void doFoo();
}
inteface Bar {
void doBar();
}
Run Code Online (Sandbox Code Playgroud)
的实现者FooBar需要提供的方法getFooBar(),它返回一个fullfills类型的实例Foo以及Bar.
到目前为止我尝试的是使用泛型:
interface FooBar {
<T extends Foo & Bar> T getFooBar()
}
class SomeImplementor implements FooBar {
private FooAndBarImpl fSomeField;
public <T extends Foo & Bar> T getFooBar() {
return fSomeField;
}
}
Run Code Online (Sandbox Code Playgroud)
鉴于这FooAndBarImpl是由框架或库提供的某种类型和实现Foo,Bar我认为这应该工作.但是,它没有,因为"FooAndBarImpl无法转换为T".这是为什么?getFooBar()我所看到的合同所隐含的合约并没有被打破.
另一种解决方案是定义一个扩展的新接口,Foo并将Bar其用作返回类型.我只是不明白在返回的一个空的包装太大意义fSomeField的 …
我们在一个属性文件LocalizableResource_xx.properties(每种语言一个)中定义所有国际化常量字符串google.gwt.i18n.client.
这样就可以通过常量接口访问Java代码中的常量
Window.alert(myConstants.helloWorld());
Run Code Online (Sandbox Code Playgroud)
以及在UiBinder中使用它们 .ui.xml
<ui:attribute key="some.key" name="text" description="useful info" />
Run Code Online (Sandbox Code Playgroud)
如果字符串包含单引号('),则此方法无法正常工作.这是因为GWT编译器java.text.ParseException: Unterminated single quote:在处理.ui.xml文件时会抛出一个.如果我们转义引号,意味着加倍it(''),编译器会通过,但通过常量接口访问的字符串包含两个单引号(如in You can''t do that).
用utf-8编码替换单引号\ u0027没有帮助(与上面相同的例外).
是否有可能在UiBinder模板和Java代码中使用相同的属性文件而不会遇到恼人的单引号问题?
到目前为止,我成功地使用了google guice 2.在迁移到guice 3.0时,我遇到了辅助注入工厂的麻烦.假设以下代码
public interface Currency {}
public class SwissFrancs implements Currency {}
public interface Payment<T extends Currency> {}
public class RealPayment implements Payment<SwissFrancs> {
@Inject
RealPayment(@Assisted Date date) {}
}
public interface PaymentFactory {
Payment<Currency> create(Date date);
}
public SwissFrancPaymentModule extends AbstractModule {
protected void configure() {
install(new FactoryModuleBuilder()
.implement(Payment.class, RealPayment.class)
.build(PaymentFactory.class));
}
}
Run Code Online (Sandbox Code Playgroud)
在创建注入器时,我得到以下异常:
com.google.inject.CreationException: Guice creation errors:
1) Payment<Currency> is an interface, not a concrete class.
Unable to create AssistedInject factory. while locating Payment<Currency>
at PaymentFactory.create(PaymentFactory.java:1) …Run Code Online (Sandbox Code Playgroud) 我正在使用Jenkins(以前称为Hudson)的Grails插件,但没有找到为目标指定自定义环境的方法.
我试着-Dgrails.env=myEnvironment war在targets输入和配置部分-Dgrails.env=integration的Properties输入中没有任何运气.
我有RPC服务,返回从Event(抽象)扩展的GameEvent类型的对象.当我在客户端获取对象时,从Event(eventId,copyEventId,gameTimeGMT)继承的所有属性都设置为,null而在服务器端,这些属性具有值.
public class GameEvent extends Event implements IsSerializable {
private String homeTeam;
private String awayTeam;
public GameEvent() {
}
}
// Annotation are from the twig-persist framework which should not
// impact the serialization process.
public abstract class Event implements IsSerializable {
@Key
protected String eventId;
@Index
protected String copyEventId;
protected Date gameTimeGMT;
protected Event() {
}
}
Run Code Online (Sandbox Code Playgroud)
更新:我使用gwt-platform框架(MVP实现).这是对服务客户端的调用.在result.getGE()返回GameEvent对象,但与null属性.
dispatcher.execute(
new GetFormattedEventAction(
id),
new AsyncCallback<GetFormattedEventResult>() {
@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
} …Run Code Online (Sandbox Code Playgroud) 如何将XML片段的CSS类属性的值绑定到另一个XML视图中的模型属性?
以下剪辑工作正常
<core:Fragment fragmentName="com.foo.bar.Fragment" type="XML" class="important"/>
Run Code Online (Sandbox Code Playgroud)
应该改成类似的东西
<core:Fragment fragmentName="com.foo.bar.Fragment" type="XML" class="{itemStatus}"/>
Run Code Online (Sandbox Code Playgroud)
其中{itemStatus}应绑定到模型属性.
任何帮助赞赏!
我试图专注于树中的特定列表视图,我使用以下代码
this.txtListName.setCursorPos(this.txtListName.getText().length());
this.txtListName.setFocus(true);
Run Code Online (Sandbox Code Playgroud)
文本视图中的光标闪烁,但是当我键入一个键没有任何反应时,我必须再次选择文本视图才能键入.
为什么会这样呢?
设置焦点是在for循环中完成的,循环并创建了Tree Items,当我从for循环中删除它时.
我们如何从XML视图中将参数传递给i18n模型?
没有参数
<Label text="{i18n>myKey}"/>
Run Code Online (Sandbox Code Playgroud)
但是我们如何在该表达式中传递参数?
到目前为止,我发现的唯一信息是http://scn.sap.com/thread/3586754.我真的希望这不是正确的方法,因为这看起来更像是一个(丑陋)黑客.
gwt ×4
java ×3
sapui5 ×2
data-binding ×1
dialog ×1
focus ×1
generics ×1
grails ×1
guice ×1
guice-3 ×1
gwt-platform ×1
gwt-rpc ×1
hudson ×1
inheritance ×1
interface ×1
jenkins ×1
keylistener ×1
return-value ×1
uibinder ×1