GWT uibinder会自动关闭 [英] GWT uibinder autocorrect off

查看:126
本文介绍了GWT uibinder会自动关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用GWT uibinder方法,我的html包含一个文本框,如

 < ui:UiBinder xmlns:ui =urn :ui:com.google.gwt.uibinder
xmlns:g =urn:import:com.google.gwt.user.client.ui
xmlns:idmw =urn:import:com .testing.wid.impl>
< g:HTMLPanel>
< table align =centervalign =centerheight =25%>
< tr>< td>< g:TextBox ui:field ='searchS'/>< / td>< / tr>

< / table>
< / g:HTMLPanel>



我如何为此文本框关闭自动更正和autocapitalize
i已尝试

 < g:TextBox ui:field ='searchS'autocapitalize =offautocorrect =off /> 

但是我得到

  [错误]类TextBox没有合适的setAutocorrect()
方法元素< g:TextBox autocapitalize ='off'autocorrect ='off'ui:field ='searchS'>

其他方式我可以这样做???

Thanks

解决方案

正如@Boris Brudnoy指出的那样,没有内置的方法可以使用TextBox。羚牛进一步他的建议它将很好提取到新的自定义组件(以简化重用和支持):


  1. 添加新的包(for例如 com.app.shared.customcontrol

  2. 添加新的CustomTextBox:

      public class CustomTextBox extends TextBox {
    $ b $ public void setAutocomplete(String value){
    this.getElement()。setAttribute(autocomplete ,价值);

    $ b $ public void setAutocapitalize(String value){
    this.getElement()。setAttribute(autocapitalize,value);


    $ / code $ / pre
  3. 使用UI绑定声明新名称空间并使用您的组件:

     <!DOCTYPE ui:UiBinder SYSTEMhttp://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
    xmlns:c =urn:import:com.app.shared.customcontrol>

    < c:CustomTextBox ui:field =...autocomplete =offautocapitalize =off/>
    < / g:HTMLPanel>
    < / ui:UiBinder>


如果您想要应用这些设置系统范围内你可以通过构造函数完成它:

  public class CustomTextBox extends TextBox {

public CustomTextBox ){
this.getElement()。setAttribute(autocomplete,off);
this.getElement()。setAttribute(autocapitalize,off);
}

....
}


im using GWT uibinder method and my html contains a textbox like

<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
     xmlns:g="urn:import:com.google.gwt.user.client.ui"
     xmlns:idmw="urn:import:com.testing.wid.impl">
    <g:HTMLPanel>
    <table align="center" valign="center" height="25%">
        <tr><td><g:TextBox ui:field='searchS' /></td></tr>

    </table>
    </g:HTMLPanel>

How can i TURN OFF autocorrect and autocapitalize for this Textbox?? i tried

  <g:TextBox ui:field='searchS' autocapitalize="off" autocorrect="off"/>

but i get

[ERROR] Class TextBox has no appropriate setAutocorrect()
method Element <g:TextBox autocapitalize='off' autocorrect='off' ui:field='searchS'> 

Any other way i can do this???

Thanks

解决方案

As already pointed by @Boris Brudnoy there is no built-in way to do it with TextBox. Takin futher his suggestion it will be nice to extract this into new custom component (to simplify reuse and support):

  1. Add new package (for example com.app.shared.customcontrol)
  2. Add new CustomTextBox:

    public class CustomTextBox extends TextBox {
    
        public void setAutocomplete(String value){
            this.getElement().setAttribute("autocomplete", value);
        }
    
        public void setAutocapitalize(String value){
            this.getElement().setAttribute("autocapitalize", value);
        }
    }
    

  3. Declare new namespace using UI binder and use your component:

    <!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"
        xmlns:c="urn:import:com.app.shared.customcontrol">
    
        <g:HTMLPanel ...>
            <c:CustomTextBox ui:field="..." autocomplete="off" autocapitalize="off"  />
        </g:HTMLPanel>
    </ui:UiBinder>
    

As alternative way if you want apply these settings system wide you can do it via constructor:

public class CustomTextBox extends TextBox {

    public CustomTextBox() {
        this.getElement().setAttribute("autocomplete", "off");
        this.getElement().setAttribute("autocapitalize", "off");
    }

    ....
}

这篇关于GWT uibinder会自动关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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