我有从属性文件提供的常量值
MyConstants.java
public interface MyConstants extends ConstantsWithLookup {
public String text();
}
MyConstants.properties
text=Hello!
要获取文本,我执行以下操作
private MyConstants constants = GWT.create(MyConstants.class);
Button button=new Button(constants.text());
我想知道如何使用 UiBinder 使用属性文件提供的文本创建按钮
<?xml version="1.0" encoding="UTF-8"?>
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<g:Button>Hello!</g:Button>
</g:HTMLPanel>
</ui:UiBinder>
而且我还有 fieldset 标签,如何向其图例添加文本
<g:HTMLPanel>
<fieldset class="panel">
<legend>Hello!</legend>
</g:HTMLPanel>
最佳答案
尝试按照与 CssResource
相同的方式将 CssResource
注入(inject)到 ui.xml
中。
示例代码:
<?xml version="1.0" encoding="UTF-8"?>
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:with type="com.x.y.z.client.MyConstants" field="c">
</ui:with>
<g:HTMLPanel>
<g:Button text="{c.text}"/>
</g:HTMLPanel>
</ui:UiBinder>
<小时/>
编辑
使用CaptionPanel而不是 fieldset
<gwt:CaptionPanel captionText="{c.text}"></gwt:CaptionPanel>
关于java - UiBinder GWT 中的属性文件提供的常量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23782547/