标签: uibinder

GWT:基于uiBinder的小部件不能第二次实例化

我使用GWT uiBinder创建了一个小部件.它工作正常,直到我想第二次实例化的那一刻.在我第二次调用构造函数之后,它只返回XML中的原始描述,而构造函数(rootElement.add( new HTML( "panel1" ), leftId );)中的语句只是不起作用.它不会引发任何错误或警告.

请帮忙

Java类:

public class DashboardLayout extends Composite {

final String leftId = "boxLeft";
final String rightId = "boxRight";

interface DashboardLayoutUiBinder extends UiBinder<HTMLPanel, DashboardLayout> {
}

private static DashboardLayoutUiBinder ourUiBinder = GWT.create( DashboardLayoutUiBinder.class );

@UiField
HTMLPanel htmlPanel;

public DashboardLayout() {
    HTMLPanel rootElement = ourUiBinder.createAndBindUi( this );
    this.initWidget( rootElement );

    rootElement.add( new HTML( "panel1" ), leftId );
    rootElement.add( new HTML( "panel2" ), rightId );

}
   }
Run Code Online (Sandbox Code Playgroud)

XML描述:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:g='urn:import:com.google.gwt.user.client.ui'
             >
    <g:HTMLPanel …
Run Code Online (Sandbox Code Playgroud)

gwt uibinder

2
推荐指数
1
解决办法
1537
查看次数

如何在CheckBox ValueChangeEvent中使用@UIBinder?

我想让这个工作:

@UiField
CheckBox showDeleted;

@UiHandler("showDeleted")
public void onShowDeletedClicked(ValueChangeEvent<Boolean> ev) {
    ...
}
Run Code Online (Sandbox Code Playgroud)

我从GWT编译器中得到这些错误:

Invoking generator com.google.gwt.uibinder.rebind.UiBinderGenerator
[WARN] The method 'getAssociatedType()' in 'ValueChangeEvent' does not return Type<? extends EventHandler>.
[ERROR] Parameter 'ValueChangeEvent' is not an event (subclass of GwtEvent).
Run Code Online (Sandbox Code Playgroud)

有谁知道是否可以让这个工作?现在我将手动添加一个处理程序,但@UIBinder版本更好.

java gwt uibinder gwt2

2
推荐指数
1
解决办法
4097
查看次数

GWT Uibinder图像显示但未调整大小

这张图片正在显示,但无论我使用的宽度或高度值如何,我都无法调整大小.你有什么?谢谢.

<ui:with field='res' type='com.hellomvp.client.resources.MyResources'/>

    <ui:style>
        .fortaImage { width:'50px'; height:'50px';} 
    </ui:style>

    <g:DockLayoutPanel unit='EM'>
        <g:north size="10"> 
            <g:FlowPanel>
            <g:Image styleName='{style.fortaImage}' resource='{res.fortaLogo}'/>
            <g:InlineLabel>FortaService</g:InlineLabel>
            <g:ListBox></g:ListBox>
            <g:InlineLabel>DateIn</g:InlineLabel>
            <d:DateBox></d:DateBox>
            <g:InlineLabel>DateOut</g:InlineLabel>
            <d:DateBox></d:DateBox>
            <g:Button>Cerca</g:Button>

            </g:FlowPanel>
        </g:north>



    </g:DockLayoutPanel>
Run Code Online (Sandbox Code Playgroud)

gwt uibinder

2
推荐指数
1
解决办法
8118
查看次数

GWT简单的DockPanel使用错误

为什么这个"代码"失败了

<g:DockPanel unit="px">
    <g:south size="100">
        <g:TextBox ui:field="host" text="localhost"/>
    </g:south>
    <g:south size="100">
        <g:TextBox ui:field="port" text="3287"/>
    </g:south>
</g:DockPanel>
Run Code Online (Sandbox Code Playgroud)

而这个

<g:HorizontalPanel>
    <g:cell>
        <g:TextBox ui:field="host" text="localhost"/>
    </g:cell>
    <g:cell>
        <g:TextBox ui:field="port" text="3287"/>
    </g:cell>
</g:HorizontalPanel>
Run Code Online (Sandbox Code Playgroud)

不?

附加信息:

堆栈跟踪

ERROR: Deferred binding failed for 'client.view.EnterPage.EnterPageUiBinder'; expect subsequent failures. 
ERROR: Unable to load module entry point class client.Dbweb (see associated exception for details). java.lang.RuntimeException: Deferred binding failed for 'client.view.EnterPage$EnterPageUiBinder' (did you forget to inherit a required module?)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
    at com.google.gwt.core.client.GWT.create(GWT.java:98)
    at client.view.EnterPage.<clinit>(EnterPage.java:27)
    at client.Dbweb.onModuleLoad(Dbweb.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) …
Run Code Online (Sandbox Code Playgroud)

java gwt dockpanel uibinder

2
推荐指数
1
解决办法
4263
查看次数

使用UiBinder为普通的html元素设置样式

我有以下UiBinder代码:

...
    <div>
        <g:Label>Hello,</g:Label>
        <g:Button ui:field="button" />
    </div>
...
Run Code Online (Sandbox Code Playgroud)

现在我想设置div元素的样式,然后让它给它一个红色边框.据我所知,明确的方法是定义一个像这样的样式:

    <ui:style>
    .redborder {
        border: 1px solid red;
    }
    ...

</ui:style>
Run Code Online (Sandbox Code Playgroud)

所以代码总是看起来像这样:

...
        <div styleName="{style.redborder}">
            <g:Label>Hello,</g:Label>
            <g:Button ui:field="button" />
        </div>
...
Run Code Online (Sandbox Code Playgroud)

但在HTML页面中没有绘制红色边框.现在我用Firebug查看页面(或者你如何在Google Chrome中调用这个东西)并看到div元素具有正确的类名,但是borwser还找不到类.如果在另一方面,我把相同的样式元素放到按钮一切正常.

有没有人知道它的行为是什么?

此致,斯特凡

html gwt uibinder

2
推荐指数
1
解决办法
1471
查看次数

GWT MVP UiBinder - 将参数传递给演示者

我已经开始了一个GWT项目,我决定试试UiBinder.我很难在UiBinder上面放置一个MVP模式.

当我使用GWT-pure-java时:我会使用Gin为我的演示者注入相应的视图.这是非常直接的,如果我想将一个id传递给演示者,那么我只需将一个id传递给演示者的构造函数.

与UiBinder不太直接.我几乎可以肯定我错过了一些东西,因为很多人都声称UiBinder和MVP是在天堂做的比赛......所以我希望能在这个问题上得到一些坚实的回答;-)

我在几个简单的GWT-UiBinder示例中看到的是,视图是由绑定器创建的,然后是:

  1. 视图在其构造函数中或通过@UIFactory方法构造演示者.
  2. 相应的演示者被传递给视图(通过一个setter,不用说在构建视图之后).

使用第一种方法,如果在视图中构建演示者,如何将id传递给演示者?你会这样做view.getPresenter().setId(42);,然后主持人会去服务器获取一些信息,并要求视图显示它......闻起来很糟糕.

使用第二种方法,最终会得到一个非直观的对象图,其中不清楚谁是消费者,谁是生产者.此外,在视图需要来自演示者的信息(几乎所有用例都需要此信息)的情况下,人们会做什么:

//some code would create the presenter pass it the id and then call view.setPresenter
class MyView {
    void setPresenter(MyPresenter p) {
    this.presenter = p;
    //OK now that i have my presenter how do I ask it to fetch data from the server.
    //do i turn around and do: presenter.setView(this); and then the presenter takes 
    //over and uses the view to display the data?
     }
 }
Run Code Online (Sandbox Code Playgroud)

这同样很臭......很抱歉这篇长篇文章,并提前感谢...

mvp gwt uibinder

2
推荐指数
1
解决办法
2538
查看次数

如何使用uiBinder将复合窗口小部件嵌套到主ui.xml文件中?

我有一个任务是将复合小部件添加到主ui.xml文件中,但由于某种原因它不起作用.这是我的小部件代码:

public class MyClass extends Composite {
    @UiTemplate("MyClass .ui.xml")
    interface MyClassUiBinder extends UiBinder<Widget, MyClass > {
    }

    private static MyClassUiBinder uiBinder = GWT.create(MyClassUiBinder.class);

    @UiField Label label;

    public MyClass() {
        initWidget(uiBinder.createAndBindUi(this));
    } ...
Run Code Online (Sandbox Code Playgroud)

然后在我的主viewImpl.ui.xml类中:我声明了类包:

 ... xmlns:u="urn:com... client.view">
Run Code Online (Sandbox Code Playgroud)

然后是小部件本身:

<g:HTMLPanel ui:field="mainPanel" styleName="{style.mainPanel}">
<table align="center">
<tr>
    <td align="center">
        <u:MyClass/>
    </td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我也尝试在viewImpl类中设置一个ui:field声明,但是我在编译时抛出了一个错误:

错误]在@UiField myClass中,模板字段和所有者字段类型不匹配:com.google.gwt.dom.client.Element不能分配给com ... client.view.MyClass

当我从viewImpl和它编译的ui.xml中取出@UiField声明时,但是在加载页面时窗口小部件没有显示.

我创建了另一个复合窗口小部件类,并尝试使用按钮窗口小部件复制它.

使用firebug我看到元素已经添加到主ui.xml页面,但它也没有显示,所以我的绑定不是完全完整的.

我在这里错过了什么?

gwt widget uibinder

2
推荐指数
1
解决办法
2620
查看次数

GWT.国际化如何在UiBinder中发挥作用?

我正在尝试使用GWT编写我的第一个项目.而且我不了解使用UiBinder实现GWT应用国际化的原则.我之前使用过JSP.我清楚地了解该技术的国际化:

<fmt:message key="myValue" />
Run Code Online (Sandbox Code Playgroud)

在GWT中,类似标签可以包含一些内容:

<ui:msg key="myKey" description="myDescription">My content</ui:msg>
Run Code Online (Sandbox Code Playgroud)

我不清楚.这个标签的内容是什么意思?有什么意义呢?我理解的所有数据都应该从.properties文件中获取.什么属性keydescription手段?他们应该包含什么价值?

如果有人可以解释国际化在UiBinder中是如何运作的,我将非常感激.提前致谢!

java gwt internationalization uibinder gwt2

2
推荐指数
1
解决办法
1820
查看次数

GWT ui binder:嵌套自定义小部件

我有两个自定义小部件Foo extends CompositeBar.我想将它们嵌套在我的ui.xml中,如下所示:

<my:Foo width="100%" ui:field="myFoo">
  <my:Bar label="someLabel"/>
</my:Foo>
Run Code Online (Sandbox Code Playgroud)

我希望可以调用某种方法Foo,addWidget或者某种方法.但是我收到以下错误:

Found unexpected child element Element <my:Bar label='someLabel'>
Run Code Online (Sandbox Code Playgroud)

我怎么能修好这个?是否可以将我的自定义小部件嵌套在ui.xml中?

java gwt uibinder

2
推荐指数
1
解决办法
925
查看次数

如何在gwt中更改ag:image的url

我是GWT的新手.我在我的ui.xml中创建了一个包含Image的面板.我想根据某些条件更改该图像的URL,alt和标题.怎么做 ?

<g:Image url="images/document-statut-1.gif" title="My title" altText="My alt"></g:Image>
Run Code Online (Sandbox Code Playgroud)

日Thnx

gwt uibinder

1
推荐指数
1
解决办法
4587
查看次数

标签 统计

gwt ×10

uibinder ×10

java ×4

gwt2 ×2

dockpanel ×1

html ×1

internationalization ×1

mvp ×1

widget ×1