I like to avoid putting javascript logic in the JSP tag itself (although
you can usually do it if you get the syntax right).
I usually pull the script out of the tag like this:
<script>
function deleteEvent()
{
if (confirm('Do you want to delete this event?'))
{
location = '/EventDelete.do?e=' +
document.all("eventId").value;
}
}
</script>
<html-el:form name="eventForm"
<html-el:hidden property="eventId"
value="${requestScope.eventForm.eventId}"/>
<html-el:link href="javascript:deleteEvent();" styleClass="eventheaderlink"/>
</html-el:form>
I know that's a bit different to what you are doing but that is how I
would do it and your javascript is nice and clear (you can even put it in
a separate file).
Heya Gosper
CSC Australia
212 Northbourne Ave, Braddon ACT 2612
Ph: +61 (0) 2 6246 8155 Fax: +61 (0) 2 62468100
MOB: 0401 611779
----------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit
written agreement or government initiative expressly permitting the use of
e-mail for such purpose.
----------------------------------------------------------------------------------------
"Ricky Purnomo" <[EMAIL PROTECTED]>
14/01/2004 02:00 PM
Please respond to "Struts Users Mailing List"
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
cc:
Subject: converting <a href> with variable target into <html:link>
I am converting a pure JSP page into Struts, and am having problem
converting links which calls a javascript and has dynamically specified
target. The particular line is below:
<a href="javascript:if (confirm('Do you want to delete this event?'))
location = 'delete.jsp?e=<%= EventId %>'"
class="eventheaderlink">Delete</a>
My current converted line reads:
<a href="javascript:if (confirm('Do you want to delete this event?'))
location = '/EventDelete.do?e=<bean:write name="EventForm"
property="eventId"/>'" class="eventheaderlink">
but I cannot find an equivalent using <html:link>, problem being I cannot
add the closing single quote back (or more generally stated, I cannot have
"constant"+variable+"constant" in the link). My attempt:
<html:link href="javascript:if (confirm('Do you want to delete this
event?')) location = '/EventDelete.do" paramId="e" paramName="EventForm"
paramProperty="eventId" styleClass="eventheaderlink">
is missing the last ' and causes error.
So is there a way to do this in <html:link>?
And is there a need to convert all <a> to <html:link> in the first place?
Because I am also having problem converting
<a href="mailto:<%= htmlescape(contactemail) %>"
class="eventemaillink"><%=
htmlescape(evcontactemail) %></a>
into <html:link>, since there is no paramId that I can specify, and using
paramId always automatically add a ? to the created link.
Thanks in advance on any pointers,
Ricky Purnomo
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]