Hello list,
 
Noah is correct...the code you provide in the onclick attribute of the commandLink is inserted before the generated _javascript_ of the commandLink.  Eivind, if you remove the "return false" code from the onclick of your commandLink, you should get the behavior you expected.
 
The Wiki explains how the commandLink works very well:
 
http://wiki.apache.org/myfaces/_javascript_WithJavaServerFaces
 

=========================================
Damon Weyant - Web Application Developer
Information Technology Department
New Enterprise Stone & Lime Co., Inc.
http://www.nesl.com
=========================================

 
-----Original Message-----
From: Sloan, Noah M [mailto:[EMAIL PROTECTED]
Sent: Monday, July 31, 2006 10:34 AM
To: MyFaces Discussion
Subject: RE: commandLink and onclick event

I think return false aborts the form submission.


From: Rønnevik, Eivind [mailto:[EMAIL PROTECTED]
Sent: Mon 31-Jul-06 9:28 AM
To: [email protected]
Subject: commandLink and onclick event

Hi!
 
Can anyone tell me why something like this would work:
<t:commandLink value="#{messages.deleteRow}" action="#{selectRowHandler.deleteRow}" onclick="if (!confirm('Are you sure you want to delete this record?')) return" />

But that a similar approach (firing the _javascript_ AND the action) doesn't?
 <t:commandLink value="#{messages.viewInfo}" action="#{selectRowHandler.setSelectedItem}" onclick="openPopupWindow(this); return false;" >
       
<t:updateActionListener property="#{selectRowHandler.selectedItem}" value="#{item}" />
</t:commandLink>

Basically, the first link fires BOTH the _javascript_ and the action, but the second one fires only the _javascript_. Why should the contents of the script have something to say for if the action is triggered or not?

I thought that the commandLink was capable of triggering both, anybody have some experiences with this?

Regards,

Eivind

 

 

 

 

Reply via email to