This is because you can't mix the value of an attribute of a custom tag with both string literal and run time expressions.
Instead of this:
<html:submit onclick="this.form.hiddenId.value='<%=(String) theCode %>'; " value="Edit" />
something like this should work:
<c_rt:set var="theCode" value="<%=(String) theCode %>"/>
<c:set var="theCode" value="this.form.hiddenId.value=${theCode}"/>
<htm-ell:submit onclick="${theCode}" value="Edit" />

however, based on your use case I would suggest making use of the property attribute of <html:submit. This way, a value will automically be submitted with the form based on which button you select.

hth,
Ben

From: [EMAIL PROTECTED]
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: Iterate and onClick problem for html:submit
Date: Fri, 12 Dec 2003 16:45:53 +0100

Hi,

I have a problem at the moment where I wish to set a hidden field on a form depending on which button a users selects. So my JSP loads with N number of possible rows in a table. Each row has a button (Edit) associated with it. When the user hits the Submit button I want a hidden field to be set so my Action class can read it from the form and act appropriately. The problem is that after defining my bean I cannot evaluate the property - the parameter I retrieve in my Action class is set to <%= (String) theCode %> and not the value I require!

Here is an extract of the code:

<logic:iterate id="item" scope="session" indexId="index" collection='<%=session.getAttribute("theList")%>'>
<tr>
<TD class="body_text"><bean:write name="item" property="section"/>
<bean:define id="theCode" name="item" property="title"></bean:define>
<html:submit onclick="this.form.hiddenId.value='<%=(String) theCode %>'; " value="Edit" />
</TD>
</TR>
</logic:iterate>


The problem is compounded by the fact that the page works using standard html as follows:

<input type=button onclick="this.form.hiddenId.value='<%= (String) theCode %>'; value="Edit" />

but I need to use Struts Html if my DynaValidatorActionForm is to work (I think!).

I have looked through the archives and although I have found people having similar problems I cannot get a solution. I have also tried all combinations of quotes and escaping quotes etc with no success.

I'd appreciate any help people could give.

Regards,
Simon.


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

rta

_________________________________________________________________
Wonder if the latest virus has gotten to your computer? Find out. Run the FREE McAfee online computer scan! http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to