File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plugging variables

 
Ian Cox
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a page with the following script. The page needs to submit the form as I have hidden fields that need to be passed back to the form.

<script type="text/javascript">
function doLocationSelect(location){
var loc = document.forms[0].getElementById("location");
loc.value = location;
document.forms[0].submit();
}
</script>

In order to trigger the form I have a series of <a> tags as seen below

<a href='javascript oLocationSelect("<plug>");'><bean:write name="location" property="name"/> - <bean:write name="location" property="wardName"/></a>

These are output by a <logic:iterate> block. I want to replace the <plug> part with a property from the iterated object.

I seem unable to oget a combination of quotes, etc that will work. Any ideas more than welcome.

Thanks
Ian
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In : <a href='javascript: oLocationSelect("<plug>");'>
Your choice of " and ' is fine. If you've got one type outside then you need to have the other type occurring within. [though the "good" practice is s'posed to be one where " is outside and ' occurs within]
Now, you can simply put in <bean:write name="iterator_id" value="property"/> inplace of the <plug>. Even though if you're using a smart IDE then there's a chance that it'll point out an error on this line, but you can ignore it. This is so because, the container will first compile the JSP to its corresponding HTML content. During this process all taglibs and scriptlets are resolved to their corresponding values. So when the content reaches the browser, the <bean:write> would have resolved to a simple string which won't throw up any errors.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic