jump to navigation

Struts form names October 11, 2007

Posted by Phill in Struts.
Tags: ,
trackback

One of our clients recently wanted to integrate some tracking software into an application which uses Struts. Basically what you need to do is include some JavaScript into your page, and the tracking software will do the rest (a bit like Google Analytics). Unlike Google Analytics, however, this tracking software had some fairly specific requirements as to things like form field names and form names. One of them was that each form had to have a unique name, and the form name had to change when someone went back to edit their details… the problem is, in Struts the form takes its name from the form bean you’re using. You can’t actually explicitly set the form name using the <html:form> tag.

Fortunately, there’s an easy solution: each input element (i.e., <html:text>) has a “name” attribute which you can use to set the name of the form bean that you’re using. Do that for all of your input elements, and then replace <html:form> with a conventional <form> tag, and everything should work OK.

Of course, having to specify a form name is probably a rather unusual requirement, but just in case it helps someone I publish it here for posterity!

Advertisements

Comments

1. Cazz - November 28, 2007

Thanks, you’ve helped me 🙂

2. Phill - November 28, 2007

Excellent, glad to hear that it’s helped someone! 😀

3. Alfredo - August 12, 2008

Excellent, just what I was looking for!

4. Alex - March 22, 2011

Hi Phil,
I got two software tools developed from an IT company. The links for the tools are as follows:
http://www.mydomain.com/tool_1
http://www.mydomain.com/tool_2
I asked them to incorporate Google Analytics.. and they are telling me its not easy as the tools are J2EE based. I don’t understand technology. Would you be able to advise me, so that I can talk to them? I am not a technical person, but I take keen interest in technology.
Thanks,
Alex

5. kamesh - July 16, 2011

Thanks,it solved my issue,i was working since 2 days on this issue.once again thanks a lot


Sorry comments are closed for this entry

%d bloggers like this: