In Struts say we define some form with the name TaskForm in struts-config.xml.
In one of the javascript function, I can see the statement:
document.TaskForm(some form name in struts-config.xml).action = action
My question here is how come we are able to execute document.taskform at client side?
I mean statements like document.getElementByid("") are defined in browser side but not sure about document.taskform?
You can’t access Struts ActionForms using JavaScript!
What you are seeing is JavaScript interaction with the HTML client side
<form>tag (something like this tutorial presents)The HTML
<form>tag happens to have the same attributenameandactionvalue as the ones from the<form-bean>and<action>tags ofstruts-config.xml.This is no coincidence!
ActionForms are the server side object representation of a client side HTML<form>tag and Struts server tags generate HTML which is then sent to the client.The HTML
<form>tag usually contains the name of the bean specified in<form-bean>ofstruts-config.xmltag, while theactionattribute of the<form>is the one specified in the corresponding<action>ofstruts-config.xml.Some names and values are preserved to maintain clarity of the code. This makes things homogeneous. But we are NOT talking about the same thing!