How to disable autocomplete Struts tags (HTML: text)

For a regular HTML input tag, disabling auto-completion is simple, as follows:

<input type="email" name="email" autocomplete="off"> 

While this does not work for the Struts tags that are listed below:

 <html:text property="" styleId="Field" maxlength="4" size="4" tabindex="14" onblur="check(this);" value="" /> 

How to disable autocomplete tags Struts?

+1
source share
5 answers

The Autocomplete attribute is not passed to the displayed HTML tag.

You can do this by writing your own tag, which extends the tag, to accept the autocomplete attribute and pass it to the processed tag.

check these links ::

Struts 2 + Disable AutoFill Form

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

+1
source

I met the same problem. Editing tld attibutes did not help me. I solved this by adding an attribute through 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
source

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

0
source

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 specify textnac for this class in your tld mapping! .. and viola! Not the best reusable code. Provided that Struts 1.x will by no means be reviewed, this sort of monkey-patch code is more than enough from my point of view :)

0
source

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

 <html:text property="userName" styleId="firstname\" placeholder=\"Email*\" autocomplete=\"off" styleClass="ql-inpt" readonly="true" /> 
0
source

Source: https://habr.com/ru/post/1502165/


All Articles