UiBinder小部件中的自定义属性 [英] Custom attributes in UiBinder widgets

查看:102
本文介绍了UiBinder小部件中的自定义属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的应用使用了GWT和UiBinder,并且我正在尝试这样做。

< g:TextBox ui:

但是自定义<$ c $ c> placeholder 属性不起作用,因为 TextBox setPlaceholder 方法c> - 我需要这个:
$ b

searchBox.getElement()。setAttribute(placeholder,search);



返回到java代码中。关于如何在UiBinder本身做到这一点的想法?我想我可以将它改为正常的输入元素,并尝试获取参考及其价值,但我宁愿不走那条路。 如何创建自定义 SearchBox > TextBox with method setPlaceholder(String placeholder)

然后在UiBinder中:


< custom:SearchBox ui:field =searchBoxstyleName ={style.searchBox}
placeholder =search/>



I'm using GWT and UiBinder for my app, and I'm trying to do this

<g:TextBox ui:field="searchBox" styleName="{style.searchBox}" placeholder="search" />

But the custom placeholder attribute won't work because there isn't a setPlaceholder method on TextBox - I need to this:

searchBox.getElement().setAttribute("placeholder", "search");

back in the java code. Any ideas on how to do this in UiBinder itself? I suppose I could change it over to a normal input element and try to grab a reference and its value, but I'd rather not go down that road.

解决方案

What about creating custom SearchBox that extends TextBox with method setPlaceholder(String placeholder) ?

Then in UiBinder:

<custom:SearchBox ui:field="searchBox" styleName="{style.searchBox}" placeholder="search" />

这篇关于UiBinder小部件中的自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆