I'm trying to retrieve values with struts tags inside JavaScript function, because it's being called a lot of times, and I won't go each line making respective changes when needed. I want to make it once.
I have this working in the same JSP:
function myNewWindow(file_type, file_name){
Window= window.open('MyClassAction_ac.do?metodo=Start&docType='+file_type+'&docName='+file_name,'_blank','width=810,menubar=no,toolbar=no,scrollable=yes,resizable=no');
}
....
<a href="javascript:myNewWindow('<bean:write name="MyClass" property="type"/>','<bean:write name="MyClass" property="name"/>');">
<img src="<%=path%>img/img1.jpg" width="14" height="14" hspace="0">
</a>
But I need something like this:
function myNewWindow(){
var file_Type= <%= <bean:write name="MyClass" property="type"/> %>
var file_name = <%= <bean:write name="MyClass" property="name"/> %>
Window= window.open('MyClassAction_ac.do?metodo=Start&docType='+file_type+'&docName='+file_name,'_blank','width=810,menubar=no,toolbar=no,scrollable=yes,resizable=no');
}
It should work :
var file_Type= '<bean:write name="instanceofMyClass" property="type"/>'
So you need to have instance of myclass in one of the scopes: request, session or application