Author: fdesbois Date: 2010-06-12 17:05:57 +0200 (Sat, 12 Jun 2010) New Revision: 13 Url: http://nuiton.org/repositories/revision/nuiton-web/13 Log: Update confirm mixin to use condition Modified: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js Modified: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java 2010-06-10 17:56:00 UTC (rev 12) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java 2010-06-12 15:05:57 UTC (rev 13) @@ -25,6 +25,9 @@ @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.MESSAGE) private String message; + @Parameter(value = "true") + private boolean condition; + @Inject private RenderSupport renderSupport; @@ -37,8 +40,8 @@ @AfterRender public void afterRender() { if (!wDisabled) { - renderSupport.addScript(String.format("new Confirm('%s', '%s');", - element.getClientId(), message.replace("'", "\\'"))); + renderSupport.addScript(String.format("new Confirm('%s', '%s', %b);", + element.getClientId(), message.replace("'", "\\'"), condition)); } } Modified: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js =================================================================== --- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js 2010-06-10 17:56:00 UTC (rev 12) +++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js 2010-06-12 15:05:57 UTC (rev 13) @@ -6,15 +6,18 @@ * element : Element DOM depuis lequel le dialogue de confirmation va s'ouvrir * message : Message à afficher dans la boîte de dialogue */ - initialize: function(element, message) { + initialize: function(element, message, condition) { this.message = message; + this.condition = condition; Event.observe($(element), 'click', this.doConfirm.bindAsEventListener(this)); }, doConfirm: function(e) { //Tapestry.debug('click ' + element); - if(! confirm(this.message)) { - //Tapestry.debug('STOP ' + e); - Event.stop(e); + if (this.condition) { + if (!confirm(this.message)) { + //Tapestry.debug('STOP ' + e); + Event.stop(e); + } } } }); \ No newline at end of file