struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lorrin Nelson <lhn-s...@the-fam.net>
Subject Re: html:link with dynamic javascript confirmation
Date Tue, 27 May 2003 18:54:14 GMT
Thanks David! That solved my problem and sounds like something I never 
would have figured out on my own..

-Lorrin

At 12:49 PM 5/24/2003, you wrote:
> >>>>> "Lorrin" == Lorrin Nelson <lhn-spam@the-fam.net> writes:
>
>     Lorrin> I have a table displaying a list of items, and on each row 
> there is a "delete"
>     Lorrin> link that pops up a confirmation dialog and then deletes the 
> item. This works:
>
>
>     Lorrin> <c:forEach var="template" items="${templates}">
>     Lorrin>     <tr>
>     Lorrin>             <td><c:out value="${template.name}" 
> escapeXml="true"/></td>
>     Lorrin>             <td>
>     Lorrin>                     <html:link action="/user/template/delete"
>     Lorrin>                             paramId="id" paramName="template" 
> paramProperty="id"
>     Lorrin>                             onclick="return confirm('Really?')">
>     Lorrin>                             <fmt:message 
> key="template.list.action.delete"/>
>     Lorrin>                     </html:link>
>     Lorrin>             </td>
>     Lorrin>             </tr>
>     Lorrin> </c:forEach>
>
>     Lorrin> My problem is the hardcoded 'Really?' -- instead, I want to 
> use a message
>     Lorrin> resource and plug in the name of the item in the row, like so:
>
>     Lorrin> <fmt:message key="temple.delete.confirm"><fmt:param
>     Lorrin> value="${template.name}"/></fmt:message>
>
>     Lorrin> That works fine if it's not inside the <html:link> tag, but 
> inside the
>     Lorrin> <html:link> it doesn't get parsed at all. In fact, if I do 
> 'Really <%=4+4%>?' I
>     Lorrin> don't even get 'Really 8', I get the unparsed text in the 
> confirmation dialog..
>
>     Lorrin> Any suggestions? I'm not married to this approach; if I've 
> gotta use old-skool
>     Lorrin> Struts tags instead of JSTL or do it as a form instead of a 
> html:link that's
>     Lorrin> alright.
>
>Well, the simple fix is to understand that expression scriptlets have to 
>be the
>entire attribute value, not just a portion.  Instead of:
>
>   'Really <%=4+4%>?'
>
>you would need
>
>   '<%= "Really" + (4 + 4) + %>?'
>
>Alternatively, if you are using the nightly build of Struts, you could use the
>"Struts-EL" contrib library, which gives you the ability to reference EL
>expressions in the attributes of the Struts tags.
>
>--
>===================================================================
>David M. Karr          ; Java/J2EE/XML/Unix/C++
>dmkarr@earthlink.net   ; SCJP; SCWCD
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
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