How to set ‘autoComplete’ property for html:text component in struts

If you are developing your jsp page using struts then, In few cases you get a requirement that while typing in an input filed it should not show the suggestions that previously entered.

So generally to achieve this we use the property ‘autoComplete=off’ for html input fields. But struts <html:text> doesn’t support this property. So to achieve this feature in struts we have three options.

1) Use normal html input component in the place of  struts html:text component.

<input type="text" value="" autoComplete="off" size="10" maxlength="10" name="Account" />

2) Use <html:text> in the following way that you set ‘autoComplete’ like a css injection. The below method can be used to set properties for the components which are not supported by struts html by default.


<html:text size="10" maxlength="10" property="Account" styleClass="\" autoComplete=\"off" />

3) Create a class extending Form class or Text class and add a custom property in it.

4) You can think of using jQuery also.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s