I have a confirm mixin that I use.  I can added it to a <t:submit/> and it
works fine.  When I try to use it with a <t:LinkSubmit/> the confirmation
box is displayed but the cancel button doesn't stop the submit.

<t:Submit t:id="clear" value="Clear"
        t:mixins="Confirm" t:message="Are you sure you want to remove all
entered serial numbers without saving?" />

Dose anyone know how to make this work with a LinkSubmit or know of another
way to do this?

Confirm.java
/**
 * A simple mixin for attaching a javascript confirmation box to the
onclick event of any component that implements
 * ClientElement.
 *
 * @author <a href="mailto:ch...@thegodcode.net";>Chris Lewis</a> Apr 18,
2008
 */
//This annotation tells Tapestry to declare the js file in the page so that
the browser will pull it in.
@IncludeJavaScriptLibrary("confirm.js")
public class Confirm {

        @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.
LITERAL)
        private String message;

        @Inject
        private RenderSupport renderSupport;

        @InjectContainer
        private ClientElement element;

        @AfterRender
        public void afterRender() {
                renderSupport.addScript(String.format("new Confirm('%s',
'%s');", element.getClientId(), message));
        }
}

Confirm.js

// A class that attaches a confirmation box (with logic)  to
// the 'onclick' event of any HTML element.
// @author Chris Lewis Apr 18, 2008 <ch...@thegodcode.net>

var Confirm = Class.create();
Confirm.prototype = {

        initialize: function(elementId, message) {
            this.message = message;
            Event.observe($(elementId), 'click', this.doConfirm.
bindAsEventListener(this));
        },

        doConfirm: function(e) {
            if (! confirm(this.message)) {
                    e.stop();
            }
        }

}

Michael Williamson
Analyst Sr Applications Developer
Phone: 816/997-5994


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to