File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Plugging variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Plugging variables" Watch "Plugging variables" New topic
Author

Plugging variables

Ian Cox
Greenhorn

Joined: Feb 11, 2008
Posts: 9
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

Joined: Feb 22, 2005
Posts: 261
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
 
subject: Plugging variables