wood burning stoves 2.0*
The moose likes JSP and the fly likes Passing jstl to javascript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing jstl to javascript function" Watch "Passing jstl to javascript function" New topic
Author

Passing jstl to javascript function

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I'm trying to pass jstl to javascript however when I attempt the following I get a syntax error

<c:forEach var="access" items="${dynamicArrayForm.map.access}">
<tr
<td><cut value="${access.action}"/></td>
<td><html:checkbox property="approve" indexed="true" name="access" onclic="chkApprove(this,this.form, <cut value='${access.action}' />)"/></td>

</tr>
</c:forEach>

and when I change the bold to double quotes I get Error: Attribute: ${access.action}" is not a valid attribute name

<html:checkbox property="approve" indexed="true" name="access" onclic="chkApprove(this,this.form, <cut value="${access.action}" />)"/>

Thank you for your time
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

This has nothing to do with the fact that the <cut> action is embedded in a Javascript snippet, but rather, because you are attempting to use a custom action in the attribute of another custom action.

This, you cannot do.

Forum instructions state that you should let us know what version of JSP and JSTL you are using.

Now would be a good time.

P.S. Also, please use UBB code tags to preserve the formatting of any posted code.
[ August 02, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
JSTL 1.0
JSP 2.3

Sorry how would I go about doing what I'm trying to do in a better way
[ August 02, 2006: Message edited by: john mattucci ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

There is no JSP 2.3. I assume you mean Servlets 2.3 and JSP 1.2?

What container are you using?

The answer is dependent upon the JSP version.
[ August 02, 2006: Message edited by: Bear Bibeault ]
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Oops sorry yes that would be jsp 1.2. Container would be Oracle 10.1.2
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can fix this by using the Struts-el version of the <html:xx> tags.

To do this, change your taglib declaration to:

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>

and make sure that struts-el.jar is in your WEB-INF/lib directory.

You can then write:

<td><html:checkbox property="approve" indexed="true" name="access" onclic="chkApprove(this,this.form, ${access.action})"/></td>
[ August 02, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Awesome that worked. I just had to add \' around the expression i.e.



because without it I was getting a javascript runtime error 'string' is undefined.
[ August 03, 2006: Message edited by: john mattucci ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing jstl to javascript function