vinoth kumar
vinoth kumar

Reputation: 679

what is the purpose of using <html:text instead of <input type="text" in struts?

in struts programming we use <html:text instead of <input type="text" But we can use <input type="text" and it will work also what is the specific reason for using <html:text tag? can any one answer me please?

Upvotes: 3

Views: 2058

Answers (3)

Bozho
Bozho

Reputation: 597244

It's just for convenience. You can easily write an regular input, supplying a proper name for binding, and a value - some EL that takes the current value from the request. You can take a look at the HTML generated by <html:text> to get a better idea.

Upvotes: 0

Logan
Logan

Reputation: 2505

The only reason to use

<html:text 

instead of using normal

<input type=text 

is the support for Internationalization. With

<html:text 

we use the attribute key, which names the value to be fetched from the Resource.properties file. So for internationalization, all we have to do is change the values stored against the keys in the resource.properties file and nothing else.

Upvotes: 0

bwawok
bwawok

Reputation: 15357

It will do magic. I.e. if your form has a field with a name of "bob", and you have an html:text with a name of "bob", the value you put in the bob field of the form within an action will cause the rendered html input to be populated. If you just did a nornal

On the other hand, html:button does (IIRC), the exact same thing as a normal button, but is just there so you can consistently put html: in front of everything. I think if you use internationalized labels you can get a small benefit out of html:button, but nothing I have ever done.

Upvotes: 1

Related Questions