You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by CLEMENT Sébastien GC EUR <se...@globecast.com> on 2005/03/24 12:48:08 UTC

commandLink and javascript question

Hi,
I have a commandLink with an actionListener. This action deletes an entry in
a table. I would like to have a confirmation popup.
I tried to add an onmousedown attribute with confirm method (in javascript).
The javascript is called but my actionListener is never called.
Any ideas?

Thanks.


Antwort: Re: commandLink and javascript question

Posted by ch...@globus.ch.
Here's the way I do it:

<h:commandButton 
styleClass="ButtonNormal NormalText" 
value="#{msg.common_cancel}" 
action="#{WVSForm.cancelWVS}" 
immediate="true" 
accesskey="Z" 
onclick="javascript:if(!confirm(document.forms[0].elements[0].value)){return 
false;};
"/>
<h:inputHidden value="#{msg.common_confirm_lose}"  transient="true" />

greets

 Chris





Eric Wahlforss <er...@wahlforss.com>
26.03.2005 00:30
Bitte antworten an "MyFaces Discussion"
 
        An:     MyFaces Discussion <my...@incubator.apache.org>
        Kopie:  "'Manfred Geiler'" <ma...@gmail.com>
        Thema:  Re: commandLink and javascript question


hi,
not sure if this solves your problem, but you shouldn't write
"javascript:" inside of element event handlers (onload,onmouseup etc).
so your commandLink should be:
<h:commandLink
actionListener="#{pspDocumentationBean.deletePreStudyAction}"
onmousedown="confirmDelete('body:preStudyPSPRequirementsForm:
confirmDelete');">
<f:param name="documentTypePSP" value="0" />
<h:graphicImage url="/images/delete.gif" style="border: 0;"
alt="#{appBundle.documentPSPDelete}" />
</h:commandLink>

regards // eric

On 2005-03-25, at 10.00, CLEMENT Sébastien GC EUR wrote:

> Thanks for your reply Manfred.
> But it doesn't work....:-(
>
> My code is :
>
> <f:loadBundle basename="com.globecast.web.action.bundle.Resources"
> var="appBundle"/>
>
> <h:form id="preStudyPSPRequirementsForm">
> <h:inputHidden id="confirmDelete"
> value="#{appBundle.confirmDeleteDocument}
> "/>
>
> <x:dataTable id="requirementList"
>       styleClass="tableBorder"
>       headerClass="rowHeader"
>       footerClass="standardTable_Header"
>       rowClasses="rowNormal,rowAlternate"
>       columnClasses="standardTable_ColumnCentered"
>       cellpadding="10"
>       width="100%"
>       var="currentPSPDocument"
>       value="#{pspPreStudyBean.requirementList}"
>       preserveDataModel="false">
>
>       <h:column>
>               <f:facet name="header"></f:facet>
>               <h:commandLink
> actionListener="#{pspDocumentationBean.deletePreStudyAction}"
> onmousedown="javascript:
> confirmDelete('body:preStudyPSPRequirementsForm:confirmDelete');">
>                       <f:param name="documentTypePSP" value="0" />
>                       <h:graphicImage url="/images/delete.gif" 
style="border: 0;"
> alt="#{appBundle.documentPSPDelete}" />
>               </h:commandLink>
>       </h:column>
> </x:dataTable>
> </h:form>
>
> and my javascript function :
>
> function confirmDelete(obj) {
>       var confirmMsg = document.getElementById(obj);
>       if (confirm(confirmMsg.value)) {
>               return true;
>       }
>       else
>               return false;
> }
>
> what's wrong?
>
> Thanks.
> sebastien.
>
> -----Message d'origine-----
> De : Manfred Geiler [mailto:manfred.geiler@gmail.com]
> Envoyé : jeudi 24 mars 2005 20:08
> À : MyFaces Discussion
> Objet : Re: commandLink and javascript question
>
>
> You must return true from your onmousedown method for the javascript
> event to be carried out by the browser.
>
> HTH
> -M
>
>
> On Thu, 24 Mar 2005 12:48:08 +0100, CLEMENT Sébastien GC EUR
> <se...@globecast.com> wrote:
>> Hi,
>> I have a commandLink with an actionListener. This action deletes an
>> entry
> in
>> a table. I would like to have a confirmation popup.
>> I tried to add an onmousedown attribute with confirm method (in
> javascript).
>> The javascript is called but my actionListener is never called.
>> Any ideas?
>>
>> Thanks.
>>
>>
>
>
--------------------------------------------
Eric Wahlforss
http://eric.wahlforss.com/
eric@wahlforss.com
+46 70 363 99 00
jabber: ericwahlforss@jabber.cn
skype, aim: ericwahlforss
--------------------------------------------


Re: commandLink and javascript question

Posted by Eric Wahlforss <er...@wahlforss.com>.
hi,
not sure if this solves your problem, but you shouldn't write  
"javascript:" inside of element event handlers (onload,onmouseup etc).  
so your commandLink should be:
<h:commandLink
actionListener="#{pspDocumentationBean.deletePreStudyAction}"
onmousedown="confirmDelete('body:preStudyPSPRequirementsForm: 
confirmDelete');">
<f:param name="documentTypePSP" value="0" />
<h:graphicImage url="/images/delete.gif" style="border: 0;"
alt="#{appBundle.documentPSPDelete}" />
</h:commandLink>

regards // eric

On 2005-03-25, at 10.00, CLEMENT Sébastien GC EUR wrote:

> Thanks for your reply Manfred.
> But it doesn't work....:-(
>
> My code is :
>
> <f:loadBundle basename="com.globecast.web.action.bundle.Resources"
> var="appBundle"/>
>
> <h:form id="preStudyPSPRequirementsForm">
> <h:inputHidden id="confirmDelete"  
> value="#{appBundle.confirmDeleteDocument}
> "/>
>
> <x:dataTable id="requirementList"
> 	styleClass="tableBorder"
> 	headerClass="rowHeader"
> 	footerClass="standardTable_Header"
> 	rowClasses="rowNormal,rowAlternate"
> 	columnClasses="standardTable_ColumnCentered"
> 	cellpadding="10"
> 	width="100%"
> 	var="currentPSPDocument"
> 	value="#{pspPreStudyBean.requirementList}"
> 	preserveDataModel="false">
>
> 	<h:column>
> 		<f:facet name="header"></f:facet>
> 		<h:commandLink
> actionListener="#{pspDocumentationBean.deletePreStudyAction}"
> onmousedown="javascript:
> confirmDelete('body:preStudyPSPRequirementsForm:confirmDelete');">
> 			<f:param name="documentTypePSP" value="0" />
> 			<h:graphicImage url="/images/delete.gif" style="border: 0;"
> alt="#{appBundle.documentPSPDelete}" />
> 		</h:commandLink>
> 	</h:column>
> </x:dataTable>
> </h:form>
>
> and my javascript function :
>
> function confirmDelete(obj) {
> 	var confirmMsg = document.getElementById(obj);
> 	if (confirm(confirmMsg.value)) {
> 		return true;
> 	}
> 	else
> 		return false;
> }
>
> what's wrong?
>
> Thanks.
> sebastien.
>
> -----Message d'origine-----
> De : Manfred Geiler [mailto:manfred.geiler@gmail.com]
> Envoyé : jeudi 24 mars 2005 20:08
> À : MyFaces Discussion
> Objet : Re: commandLink and javascript question
>
>
> You must return true from your onmousedown method for the javascript
> event to be carried out by the browser.
>
> HTH
> -M
>
>
> On Thu, 24 Mar 2005 12:48:08 +0100, CLEMENT Sébastien GC EUR
> <se...@globecast.com> wrote:
>> Hi,
>> I have a commandLink with an actionListener. This action deletes an  
>> entry
> in
>> a table. I would like to have a confirmation popup.
>> I tried to add an onmousedown attribute with confirm method (in
> javascript).
>> The javascript is called but my actionListener is never called.
>> Any ideas?
>>
>> Thanks.
>>
>>
>
>
--------------------------------------------
Eric Wahlforss
http://eric.wahlforss.com/
eric@wahlforss.com
+46 70 363 99 00
jabber: ericwahlforss@jabber.cn
skype, aim: ericwahlforss
--------------------------------------------


RE: commandLink and javascript question

Posted by CLEMENT Sébastien GC EUR <se...@globecast.com>.
Thanks for your reply Manfred.
But it doesn't work....:-(

My code is :

<f:loadBundle basename="com.globecast.web.action.bundle.Resources"
var="appBundle"/>

<h:form id="preStudyPSPRequirementsForm">
<h:inputHidden id="confirmDelete" value="#{appBundle.confirmDeleteDocument}
"/>

<x:dataTable id="requirementList"
	styleClass="tableBorder"
	headerClass="rowHeader"
	footerClass="standardTable_Header"
	rowClasses="rowNormal,rowAlternate"
	columnClasses="standardTable_ColumnCentered"
	cellpadding="10"
	width="100%"
	var="currentPSPDocument"
	value="#{pspPreStudyBean.requirementList}"
	preserveDataModel="false">

	<h:column>
		<f:facet name="header"></f:facet>
		<h:commandLink
actionListener="#{pspDocumentationBean.deletePreStudyAction}"
onmousedown="javascript:
confirmDelete('body:preStudyPSPRequirementsForm:confirmDelete');">
			<f:param name="documentTypePSP" value="0" />
			<h:graphicImage url="/images/delete.gif" style="border: 0;"
alt="#{appBundle.documentPSPDelete}" />
		</h:commandLink>
	</h:column>
</x:dataTable>
</h:form>

and my javascript function :

function confirmDelete(obj) {
	var confirmMsg = document.getElementById(obj);
	if (confirm(confirmMsg.value)) {
		return true;
	}
	else
		return false;
}

what's wrong?

Thanks.
sebastien.

-----Message d'origine-----
De : Manfred Geiler [mailto:manfred.geiler@gmail.com]
Envoyé : jeudi 24 mars 2005 20:08
À : MyFaces Discussion
Objet : Re: commandLink and javascript question


You must return true from your onmousedown method for the javascript
event to be carried out by the browser.

HTH
-M


On Thu, 24 Mar 2005 12:48:08 +0100, CLEMENT Sébastien GC EUR
<se...@globecast.com> wrote:
> Hi,
> I have a commandLink with an actionListener. This action deletes an entry
in
> a table. I would like to have a confirmation popup.
> I tried to add an onmousedown attribute with confirm method (in
javascript).
> The javascript is called but my actionListener is never called.
> Any ideas?
>
> Thanks.
>
>


Re: commandLink and javascript question

Posted by Manfred Geiler <ma...@gmail.com>.
You must return true from your onmousedown method for the javascript
event to be carried out by the browser.

HTH
-M


On Thu, 24 Mar 2005 12:48:08 +0100, CLEMENT Sébastien GC EUR
<se...@globecast.com> wrote:
> Hi,
> I have a commandLink with an actionListener. This action deletes an entry in
> a table. I would like to have a confirmation popup.
> I tried to add an onmousedown attribute with confirm method (in javascript).
> The javascript is called but my actionListener is never called.
> Any ideas?
> 
> Thanks.
> 
>