How to disable autocomplete for Struts tags(HTML:text)

后端 未结 5 978
抹茶落季
抹茶落季 2021-01-25 17:09

For normal HTML input tag,disabling autocomplete is simple as given below:


Whe

相关标签:
5条回答
  • 2021-01-25 17:21

    We can use the attributes which are not supported in <htm-text> inside \"

    <html:text property="userName" styleId="firstname\" placeholder=\"Email*\" 
               autocomplete=\"off" styleClass="ql-inpt"  readonly="true" />   
    
    0 讨论(0)
  • 2021-01-25 17:39

    Autocomplete attribute is not passed through to the rendered HTML by the tag.

    You can do so by writing your own custom tag that extends the tag to accept the autocomplete attribute and pass it through to the rendered tag.

    check these links ::

    Struts 2 + Disable Form Autocomplete

    http://www.coderanch.com/t/54020/Struts/form-input-tags-turning-autocomplete

    0 讨论(0)
  • 2021-01-25 17:39

    You can use redisplay="false" which is the equivalent in struts-html for autocomplete.

    0 讨论(0)
  • 2021-01-25 17:41

    Another option is to write your Own TextTag class something like this:

    public class TextTagNoAutoComplete extends BaseFieldTag {
        public TextTagNoAutoComplete() {
             super();
             this.type = "text";
             doReadonly = true;
        }
        protected void prepareOtherAttributes(StringBuffer handlers) {
             prepareAttribute(handlers, "autocomplete", "false");
        }
    }
    

    and point textnac to this class in your tld mapping! ..and Viola ! Not the best reusable code. Provided the fact that, Struts 1.x is in no way going to be revisited, this sortta monkey patching is more than enough in my point of view :)

    0 讨论(0)
  • 2021-01-25 17:44

    I've met the same issue. Editing the tld attibutes did not help me. I resolved it by adding the attribute via JavaScript code. Here is an example:

    <bean:define id="autoComplete" scope="request" type="java.lang.String"
        value="<%=String.valueOf(ApplicationConfiguration.getAutoComplete()) %>" />
    
    <script>
        var ttip;
        var ttip2;
        Ext.onReady(function() {
            var form = document.forms['formName'];
            var elem = form.elements["passortField"];
            elem.setAttribute( "autocomplete", "${autoComplete}" );
    

    ApplicationConfiguration.getAutoComplete() - returns either on or off, depending on application configuration

    0 讨论(0)
提交回复
热议问题