Yasushi Okubo wrote:
Hi, experts
I would like to create a simple text link that kicks off javascript by
onmouseover, but avoid to do submit() or go to another webpage, and I
also need to show the data stored in my backing bean.
The Html line could be like the following. I played with both
outputLink/outoutCommand, but it alway tries to display webpage or
submit a new request by clicking or onclick. I would like to disable
to submit for commandLink/outputLink for onclick. How could I do it ?
Or is there any other method other than outputLink/commandLink that can
avoid submit()/going to another page ?
a href=_blank onmouseover=doPopupMolWeight();
onmouseout=close_window_mol();
'NeedToDisplayDataStoredInBackingBeanHere' /a
I tried something like the following with outputLink, but it submits a
request to the server when I click the link after executing javascript
doNothing().
h:outputLink value=#{value} onclick=doNothing()
onmouseover=doPopupMolWeight(); onmouseout=close_window_mol(); /
h:commandLink value=#{value} onclick=doNothing()
onmouseover=doPopupMolWeight(); onmouseout=close_window_mol(); /
As with any Javascript event handler, you need to return false if you
want to prevent the default action from taking place. Add a 'return
false;' at the end of your doNothing() function [or, since that function
presumably doesn't do anything, you could just replace it with the
return in the onclick attribute.]
L.
Thanks for your reply. doNothing() actually returns false.
I checked the wiki website, and it looks like commanLink calls submit() no
matter what and I cannot change its behavior. And outputLink go to the
place defined in value anyway. So, I may try with commandButton instead
adding type=button (or just use f:varbatim).
http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces
JSF generates a block of Javascript and it is tied to the onclick
event. Disregarding the details, it basically calls submit() which post
the form to the server