struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brice Ruth <br...@fiskars.com>
Subject Re: Refer to an <html:form> by name ?
Date Mon, 10 Nov 2003 18:03:30 GMT
The form name attribute is set to the name of the ActionForm that your 
Action takes as its input. This is done automagically, without 
specifying a name="" attribute in the html:form tag itself. This is to 
support javascript validation, I believe.

Gleichmann, Mario wrote:

>Dear Struts-Community,
>
>assumed we use a composite-view, which is composed by multiple 'tiles'
>delivered by several Design-Team members. 
>Every of this tile is free to define it's own form-areas (<html:form...>)
>and appropriate action(s).
>Furthermore we have a 'Menu-Tile' which Buttons/Links refers to certain
>tiles in the content area. Clickin' such a Link should submit a certain
>Action (using more than one Action within a form and therefore a
>DispatchAction) in a certain form (including all the properties within the
>form).
>
>This could work like this ...
>
><jsp-snipet>
>...
><SCRIPT>
>	function callAction(targetAction) {
>		setAction(targetAction);
>		document.forms[0].submit();
>	}
>
>	function setAction(targetAction) {
>		document.forms[0].dispatch.value=target;
>	}
>
></SCRIPT>
>...
><!-- Menu-Tile -->
>...			
>	<td width="30%">
>		MENU
>		<br>
>		<br>
>		<html:link href="#" onclick="javascript:callAction( 'add'
>)"> Add </html:link>
>		<br>
>		<html:link href="#" onclick="javascript:callAction( 'delete'
>)"> Delete </html:link>
>		<br>
>		<html:image src="/Struts_WEB/images/fix.jpg"
>onclick="callAction('fix');" />
>	</td>
>...
><!-- my content-Tile ..>
>...
>	<html:form action="/processMultiButton.do" >
>
>		<html:hidden property="dispatch" value="error"/> 
>	
>		first name <html:text value="" property="firstname"/>
>		last name <html:text value="" property="lastname"/>
>		
>		<html:submit
>onclick="setAction('add');">Hinzufuegen</html:submit>
>		<html:submit
>onclick="setAction('delete');">Entfernen</html:submit>
>
>		<html:image src="/Struts_WEB/images/fix.jpg"
>onclick="setAction('fix');" />
>	
>	</html:form>	
>...
><!-- here comes another contet-Tile with another form-definition and so on
>-->
>...
></jsp-snipet>
>
>My Problem is the fact, that i have to refer to a certain form by an index
>(document.forms[0]...) but not by name (document.forms[myFormName]).
>Since we have more than one form in the content area (and this could change
>dynamically, so i do not know how many form definitions we have after all)
>it is not assured that i always refer for sure to the same form by using an
>index. 
>If i could assign a name to a form-definition (like <form
>name="myFormName"...> - see 'pure HTML form-tag attributes') than the
>position of the form within the content-area would be irelevant since i
>refer to that certain form by using its name, like ...
>
><snipet>
>
>function callAction(targetAction, formName) {
>	document.forms[0].dispatch.value=targetAction;
>	document.forms[0].submit();
>}
>
>...
><!-- Menu-Tile -->
>...
><html:link href="#" onclick="javascript:callAction( 'delete', 'myFormName'
>)"> Loeschen </html:link>
>...
></snipet>
>
>...but the <html:form ...> tag does not offer an attribute to set a forms
>name ...
>Is there any chance to achive this (refer to a form by name but not by
>index) or may be another / better solution for this problem? Any help is
>appreciated !!! :o)
>
>Thanks in adcance :o))
>
>
>Mario Gleichmann
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>

-- 
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message