更新:
请在下面查看logan 的答案以获取最新版本的 GWT 中可用的解决方案。
我有(实际上,有)和你一样的问题——在迁移到 GWT 2.0 之后,我有一个我想在我的 UiBinder 文件中使用的属性文件。不幸的是,我无法让它像我想要的那样工作 - 似乎 GWT 开发人员希望人们使用UiBinder 的 i18n 指南中描述的语法- 在编译期间为每个 UiBinder 模板等创建一个消息接口。
无论如何,您仍然可以使用Messages
这样的外部接口:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:with field='cc' type='path.to.i18n.SomeMessages'/>
<ui:with field='res' type='path.to.resource.ResourceBundle'/>
<ui:style>
.required {
color: red;
font-weight: bold;
}
.right {
text-align: right;
}
.textBox {
margin-right: 7px;
}
</ui:style>
<g:HTMLPanel styleName='{res.style.form} {res.style.mbox}' ui:field='mainPanel'>
<h2 ui:field='loginHeader' />
<h3 ui:field='loginLabel' />
<div class='{style.textBox}'><g:TextBox ui:field="loginBox" /></div>
<h3 ui:field='passwordLabel' />
<div class='{style.textBox}'><g:PasswordTextBox ui:field="passwordBox" /></div>
<div><g:CheckBox ui:field='rememberMeCheckBox' text='{cc.rememberMeCheckboxText}' /></div>
<div class='{style.right}'><g:Button ui:field='submitButton' text='{cc.loginSubmitButtonText}' /></div>
</g:HTMLPanel>
</ui:UiBinder>
虽然,这仅适用于诸如Button
标题等内容,而不适用于 div 的内容:/ 您可以在 UiBinder 模板后面的类中填写这些内容,但应该有更好的方法。
我希望您可以通过设置内部 HTML innerHTML
(因为 UiBinder 应该识别该方法并允许通过 XML/UiBinder 模板设置它的值)但是唉,上次我检查它不起作用:/