Note that there are some explanatory texts on larger screens.

plurals
  1. PO<p:commandLink> is not working when i use onClick event
    text
    copied!<p>Hope you all will be fine. The scenerio is that i have a page on which you upload picture and then remove it. I used code like this</p> <pre><code> &lt;h:panelGrid columns="5" border="" width="20%" style="position: absolute; top: 50px;" columnClasses="asteriskColumns, nameColumns" &gt; &lt;h:outputText value="*" /&gt; &lt;h:outputText value="Map: " /&gt; &lt;p:fileUpload id="cityMap" description="Image" update="city messages" allowTypes="*.jpg;*.png;*.gif;*.jpeg;" auto="true" fileUploadListener="#{cityDetail.imageUpload}" &gt; &lt;/p:fileUpload&gt; &lt;p:graphicImage id="city" value="#{cityDetail.imagePath}" width="80" height="50" cache="false"&gt; &lt;f:event type="preRenderComponent" listener="#{cityDetail.putImage}" /&gt; &lt;/p:graphicImage&gt; &lt;p:commandLink update="city" action="#{cityDetail.removeImage}" style="color: #0d5b7f;text-decoration: underline" onclick=""&gt; &lt;h:outputText value="remove" /&gt; &lt;/p:commandLink&gt; &lt;h:outputText value="*" /&gt; &lt;h:outputText value="Image1: " /&gt; &lt;p:fileUpload id="cityImage1" description="Image" update="Image1 messages" allowTypes="*.jpg;*.png;*.gif;*.jpeg;" auto="true" fileUploadListener="#{cityDetail.imageUpload}" &gt; &lt;/p:fileUpload&gt; &lt;p:graphicImage id="Image1" value="#{cityDetail.imagePath}" width="80" height="50" cache="false" &gt; &lt;f:event type="preRenderComponent" listener="#{cityDetail.putImage}" /&gt; &lt;/p:graphicImage&gt; &lt;p:commandLink update="Image1" action="#{cityDetail.removeImage}" style="color: #0d5b7f;text-decoration: underline" onclick="if (! confirm('Are you sure, you want to delete the picture?') ) { return false;}; return true; "&gt; &lt;h:outputText value="remove" /&gt; &lt;/p:commandLink&gt; &lt;h:outputText value="*" /&gt; &lt;h:outputText value="Image2: " /&gt; &lt;p:fileUpload id="cityImage2" description="Image" update="Image2 messages" allowTypes="*.jpg;*.png;*.gif;*.jpeg;" auto="true" fileUploadListener="#{cityDetail.imageUpload}" &gt; &lt;/p:fileUpload&gt; &lt;p:graphicImage id="Image2" value="#{cityDetail.imagePath}" width="80" height="50" cache="false" &gt; &lt;f:event type="preRenderComponent" listener="#{cityDetail.putImage}" /&gt; &lt;/p:graphicImage&gt; &lt;p:commandLink update="Image2" action="#{cityDetail.removeImage}" style="color: #0d5b7f;text-decoration: underline" onclick="if (! confirm('Are you sure, you want to delete the picture?') ) { return false;}; return true; "&gt; &lt;h:outputText value="remove" /&gt; &lt;/p:commandLink&gt; </code></pre> <p>.....</p> <p>The problem is every thing is working fine if i use </p> <blockquote> <p>onclick=""</p> </blockquote> <p>But when i use </p> <blockquote> <p>onclick="if (! confirm('Are you sure, you want to delete the picture?') ) { return false;}; return true; "</p> </blockquote> <p>Then the remove not work. Why? Please tell me what i am doing wrong.</p> <p>I am using PrimeFaces 2.2 Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload