If I were you I will use the border color style attribute to manipulate the rectangle on hover. It is much easy. Anyway, I do not see the reason why this might be a part of component behavior. It is pure application level task.
Thank you for the quick answer .
I did not mean that solution should be encapsulated in mediaOutput. But so far I even can't realize how to put another image over mediaOutput at given coords, or e.g. draw a line using Ajax4Jsf.
Now the requirement is porting to Ajax4Jsf. I am new to this technology, but guess that at least one goal among others was to provide independency of raw JS , similar to GWT .
<div style="border:1px solid white" onmouseover="this.style.borderColor='black'" onmouseout="this.style.borderColor='white'"> However here. </div>
Unfortunately lack of JS knowledge does not let me to understand, how use provided code for drawing the rectalnle of given coordinates and size within already displayed a4j:mediaOutput.
When user clicks to some point on image and moves the mouse, the rectangular frame should appear and resize accordingly. I.e. should act as standard area selection function in graphic editors.
JS study seems inevitable in this case.