1

I have a question concerning struts2 and javascript. I have declared this struts2 component for example:

<s:select  name="test" headerValue="Choosing"                  
   label="MyChoosing"
   list="#{'myKey':'MyValue'}"
   onmouseover="myJavaScriptFunction(this)"
   disabled="false" />

One the attribut onmouseover a javascript function "myJavaScriptFunction()" is binding. I this function i would work directly with the struts component.

Is there a way to pass this component into the javascript function and work with them? Is there a way of solution? My example doesn´t work !

2 Answers 2

1

Yes, when the struts2 components evalutated at server side they are replaced with similar html tag. You can check from client html generated code or from firebug that the <s:select>tag converted to <select> So simply give your struts tag an id and inside the javascript code get the tag by id and use it and make whatever you want with it you can use jquery any thing.

Sign up to request clarification or add additional context in comments.

Comments

0

No, there is not.

And if you click View Source in your page, you will see why: JSP EL and Tag libraries (Struts tags, JSTL, and so on) are evaluated server-side, then the generated HTML will be replaced to them in the page;

Javascript, instead, run client-side, when the page will be rendered, so they are in two completely different scopes.

Javascript will be able to work with the HTML select tag, btw.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.