Re: Confirm mixin with form validation errors

2012-09-17 Thread Ray Nicholus
You should be using the on function instead of bind, in jquery 1.7+
On Sep 17, 2012 5:41 AM, "Taha Siddiqi"  wrote:

> Hi
>
> You are using tapestry-jquery and trying to access a prototype library
> method. Try bind instead of observe
>
> regards
> Taha
>
> On Sep 17, 2012, at 4:00 PM, ZKN __ wrote:
>
> >
> > Thank you!
> > I tried to implement this but not much success for now. I'm not really
> good at js and jQuery so perhaps I'm doing something wrong.
> > Here is my code
> > initialize: function(element)
> >
> >{
> >
> >
> > var el = $(element);
> >
> >
> > var form = jQuery(el).closest("form");
> form.observe(Tapestry.FORM_VALIDATE_EVENT,
> >   function()
> >   {
> >   console.log("Hey, we're
> observing!");
> >
> > ...
> > I get the following error: Uncaught exception: TypeError: 'form.observe'
> is not a function
> >
> > I have to mention I'm on a bit older version of Tapestry: 5.1.05. There
> is no
> > Tapestry.FORM_VALIDATE_FIELDS_EVENT defined but there are
> > Tapestry.FORM_VALIDATE_EVENT and
> > Tapestry.FIELD_VALIDATE_EVENT
> > which I guess should do the same thing.
> >
> >
> >
> >
> >
> >
> >  Оригинално писмо 
> >
> > От: Josh Canfield joshcanfi...@gmail.com
> >
> > Относно: Re: Confirm mixin with form validation errors
> >
> > До: Tapestry users
> >
> > Изпратено на: Петък, 2012, Септември 14 07:07:20 EEST
> >
> >
> > I don't think this addresses the problem though, right?
> >
> >
> >
> > If client-side form validation fails you still are in a state where you
> >
> > can't click the submit button again after fixing the error.
> >
> >
> >
> > Tapestry doesn't have an event for "validation failed", and I don't know
> of
> >
> > an approved way to workaround that. But! What you can do is add an
> observer
> >
> > for Tapestry.FORM_VALIDATE_FIELDS_EVENT and set a timeout (1/4 of a
> >
> > second?) to re-enable the field if you don't get a
> >
> > Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT before the timeout.
> >
> >
> >
> > Here is a prototype based on Geoff's example from jumpstart. This was
> >
> > created for submit buttons, you'd have to adjust for links (find the
> >
> > form...)
> >
> >
> >
> > ClickOnce = Class.create( {
> >
> >
> >
> >initialize: function(elementId) {
> >
> >var el = $(elementId);
> >
> >el.clickOnce = this;
> >
> >if ( el['form'] ) {
> >
> >el.form.observe(Tapestry.FORM_VALIDATE_FIELDS_EVENT,
> function()
> >
> > {
> >
> >console.log("Hey, we're observing!");
> >
> >el.clickOnce.clickOnceTimeout =
> >
> > window.setTimeout(function(){
> >
> >console.log("Let them click again")
> >
> >el.clickOnce.alreadyClickedOnce = false;
> >
> >}, 250)
> >
> >});
> >
> >
> >
> >el.form.observe(Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT,
> >
> > function() {
> >
> >window.clearTimeout(el.clickOnce.clickOnceTimeout);
> >
> >});
> >
> >}
> >
> >this.alreadyClickedOnce = false;
> >
> >
> >
> >Event.observe(el, 'click',
> >
> > this.doClickOnce.bindAsEventListener(this));
> >
> >},
> >
> >
> >
> >doClickOnce: function(e) {
> >
> >var element = Event.element(event);
> >
> >console.log("Clicked");
> >
> >if (element.clickOnce.alreadyClickedOnce) {
> >
> >console.log("and cancelled");
> >
> >e.stop();
> >
> >}
> >
> >element.clickOnce.alreadyClickedOnce = true;
> >
> >}
> >
> >
> >
> > } );
> >
> >
> >
> >
> >
> > // Extend the Tapestry.Initializer with a static method that
> instantiates a
> >
> > ClickOnce.
> >
> >
> >
> > Tapestry.Initializer.clickOnce = function(spec) {
> >
> >new ClickOnce(spec.elementId);
> >
> > };
> >
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Confirm mixin with form validation errors

2012-09-17 Thread ZKN __


Thank you guys. With your help now it's working. If anyone is interested here 
is my final version (including code for confirmation): 
var Confirm = Class.create();
Confirm.prototype = 
{
initialize: function(element, message) 
{
console.log("initialize -> " + element + " ---> " + message);

this.alreadyClickedOnce = false;
this.message = message;
var el = $(element);
var form = jQuery(el).closest("form");

Event.observe(el, 'click', 
this.doConfirm.bindAsEventListener(this));

var self = this;
form.bind('submit', 
function() 
{
if (self.clickOnceTimeout != null)
{

window.clearTimeout(self.clickOnceTimeout);
}
});
},

doConfirm: function(e) 
{
console.log("Clicked");

if (this.alreadyClickedOnce)
{
e.stop();
console.log("and cancelled");
return;
}

if(!confirm(this.message))
{
e.stop();
return;
}
console.log("Confirmed");

this.alreadyClickedOnce = true;

var self = this;
this.clickOnceTimeout = window.setTimeout(
function()
{
console.log("Let them click again")
self.alreadyClickedOnce = false;
}, 
3000);
}
};
 






  Оригинално писмо 

От: Taha Siddiqi tawus.tapes...@gmail.com

Относно: Re: Confirm mixin with form validation errors

До: "Tapestry users"  

Изпратено на: Понеделник, 2012, Септември 17 13:40:26 EEST


Hi



You are using tapestry-jquery and trying to access a prototype library method. 
Try bind instead of observe



regards

Taha



On Sep 17, 2012, at 4:00 PM, ZKN __ wrote:



> 

> Thank you! 

> I tried to implement this but not much success for now. I'm not really good 
> at js and jQuery so perhaps I'm doing something wrong. 

> Here is my code 

> initialize: function(element)

> 

>{

> 

> 

> var el = $(element);

> 

>   

> var form = jQuery(el).closest("form"); 
> form.observe(Tapestry.FORM_VALIDATE_EVENT, 

>   function() 

>   {

>   console.log("Hey, we're observing!");

> 

> ... 

> I get the following error: Uncaught exception: TypeError: 'form.observe' is 
> not a function

> 

> I have to mention I'm on a bit older version of Tapestry: 5.1.05. There is no

> Tapestry.FORM_VALIDATE_FIELDS_EVENT defined but there are

> Tapestry.FORM_VALIDATE_EVENT and 

> Tapestry.FIELD_VALIDATE_EVENT 

> which I guess should do the same thing. 

> 

> 

> 

> 

> 

> 

>  Оригинално писмо 

> 

> От: Josh Canfield  joshcanfi...@gmail.com 

> 

> Относно: Re: Confirm mixin with form validation errors

> 

> До: Tapestry users  

> 

> Изпратено на: Петък, 2012, Септември 14 07:07:20 EEST

> 

> 

> I don't think this addresses the problem though, right?

> 

> 

> 

> If client-side form validation fails you still are in a state where you

> 

> can't click the submit button again after fixing the error.

> 

> 

> 

> Tapestry doesn't have an event for "validation failed", and I don't know of

> 

> an approved way to workaround that. But! What you can do is add an observer

> 

> for Tapestry.FORM_VALIDATE_FIELDS_EVENT and set a timeout (1/4 of a

> 

> second?) to re-enable the field if you don't get a

> 

> Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT before the timeout.

> 

> 

> 

> Here is a prototype based on Geoff's example from jumpstart. This was

> 

> created for submit buttons, you'd have to adjust for links (find the

> 

> form...)

> 

> 

> 

> ClickOnce = Class.create( {

> 

> 

> 

>initialize: function(elementId) {

> 

>var el = 

Re: Confirm mixin with form validation errors

2012-09-17 Thread Taha Siddiqi
Hi

You are using tapestry-jquery and trying to access a prototype library method. 
Try bind instead of observe

regards
Taha

On Sep 17, 2012, at 4:00 PM, ZKN __ wrote:

> 
> Thank you! 
> I tried to implement this but not much success for now. I'm not really good 
> at js and jQuery so perhaps I'm doing something wrong. 
> Here is my code 
> initialize: function(element)
> 
>{
> 
> 
> var el = $(element);
> 
>   
> var form = jQuery(el).closest("form"); 
> form.observe(Tapestry.FORM_VALIDATE_EVENT, 
>   function() 
>   {
>   console.log("Hey, we're observing!");
> 
> ... 
> I get the following error: Uncaught exception: TypeError: 'form.observe' is 
> not a function
> 
> I have to mention I'm on a bit older version of Tapestry: 5.1.05. There is no
> Tapestry.FORM_VALIDATE_FIELDS_EVENT defined but there are
> Tapestry.FORM_VALIDATE_EVENT and 
> Tapestry.FIELD_VALIDATE_EVENT 
> which I guess should do the same thing. 
> 
> 
> 
> 
> 
> 
>  Оригинално писмо 
> 
> От: Josh Canfield joshcanfi...@gmail.com
> 
> Относно: Re: Confirm mixin with form validation errors
> 
> До: Tapestry users  
> 
> Изпратено на: Петък, 2012, Септември 14 07:07:20 EEST
> 
> 
> I don't think this addresses the problem though, right?
> 
> 
> 
> If client-side form validation fails you still are in a state where you
> 
> can't click the submit button again after fixing the error.
> 
> 
> 
> Tapestry doesn't have an event for "validation failed", and I don't know of
> 
> an approved way to workaround that. But! What you can do is add an observer
> 
> for Tapestry.FORM_VALIDATE_FIELDS_EVENT and set a timeout (1/4 of a
> 
> second?) to re-enable the field if you don't get a
> 
> Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT before the timeout.
> 
> 
> 
> Here is a prototype based on Geoff's example from jumpstart. This was
> 
> created for submit buttons, you'd have to adjust for links (find the
> 
> form...)
> 
> 
> 
> ClickOnce = Class.create( {
> 
> 
> 
>initialize: function(elementId) {
> 
>var el = $(elementId);
> 
>el.clickOnce = this;
> 
>if ( el['form'] ) {
> 
>el.form.observe(Tapestry.FORM_VALIDATE_FIELDS_EVENT, function()
> 
> {
> 
>console.log("Hey, we're observing!");
> 
>el.clickOnce.clickOnceTimeout =
> 
> window.setTimeout(function(){
> 
>console.log("Let them click again")
> 
>el.clickOnce.alreadyClickedOnce = false;
> 
>}, 250)
> 
>});
> 
> 
> 
>el.form.observe(Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT,
> 
> function() {
> 
>window.clearTimeout(el.clickOnce.clickOnceTimeout);
> 
>});
> 
>}
> 
>this.alreadyClickedOnce = false;
> 
> 
> 
>Event.observe(el, 'click',
> 
> this.doClickOnce.bindAsEventListener(this));
> 
>},
> 
> 
> 
>doClickOnce: function(e) {
> 
>var element = Event.element(event);
> 
>console.log("Clicked");
> 
>if (element.clickOnce.alreadyClickedOnce) {
> 
>console.log("and cancelled");
> 
>e.stop();
> 
>}
> 
>element.clickOnce.alreadyClickedOnce = true;
> 
>}
> 
> 
> 
> } );
> 
> 
> 
> 
> 
> // Extend the Tapestry.Initializer with a static method that instantiates a
> 
> ClickOnce.
> 
> 
> 
> Tapestry.Initializer.clickOnce = function(spec) {
> 
>new ClickOnce(spec.elementId);
> 
> };
> 


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



Re: Confirm mixin with form validation errors

2012-09-17 Thread ZKN __

Thank you! 
I tried to implement this but not much success for now. I'm not really good at 
js and jQuery so perhaps I'm doing something wrong. 
Here is my code 
initialize: function(element)

{

   
var el = $(element);


var form = jQuery(el).closest("form"); 
form.observe(Tapestry.FORM_VALIDATE_EVENT, 
function() 
{
console.log("Hey, we're observing!");

... 
I get the following error: Uncaught exception: TypeError: 'form.observe' is not 
a function
 
I have to mention I'm on a bit older version of Tapestry: 5.1.05. There is no
 Tapestry.FORM_VALIDATE_FIELDS_EVENT defined but there are
 Tapestry.FORM_VALIDATE_EVENT and 
Tapestry.FIELD_VALIDATE_EVENT 
which I guess should do the same thing. 

 




  Оригинално писмо 

От: Josh Canfield joshcanfi...@gmail.com

Относно: Re: Confirm mixin with form validation errors

До: Tapestry users  

Изпратено на: Петък, 2012, Септември 14 07:07:20 EEST


I don't think this addresses the problem though, right?



If client-side form validation fails you still are in a state where you

can't click the submit button again after fixing the error.



Tapestry doesn't have an event for "validation failed", and I don't know of

an approved way to workaround that. But! What you can do is add an observer

for Tapestry.FORM_VALIDATE_FIELDS_EVENT and set a timeout (1/4 of a

second?) to re-enable the field if you don't get a

Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT before the timeout.



Here is a prototype based on Geoff's example from jumpstart. This was

created for submit buttons, you'd have to adjust for links (find the

form...)



ClickOnce = Class.create( {



initialize: function(elementId) {

var el = $(elementId);

el.clickOnce = this;

if ( el['form'] ) {

el.form.observe(Tapestry.FORM_VALIDATE_FIELDS_EVENT, function()

{

console.log("Hey, we're observing!");

el.clickOnce.clickOnceTimeout =

window.setTimeout(function(){

console.log("Let them click again")

el.clickOnce.alreadyClickedOnce = false;

}, 250)

});



el.form.observe(Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT,

function() {

window.clearTimeout(el.clickOnce.clickOnceTimeout);

});

}

this.alreadyClickedOnce = false;



Event.observe(el, 'click',

this.doClickOnce.bindAsEventListener(this));

},



doClickOnce: function(e) {

var element = Event.element(event);

console.log("Clicked");

if (element.clickOnce.alreadyClickedOnce) {

console.log("and cancelled");

e.stop();

}

element.clickOnce.alreadyClickedOnce = true;

}



} );





// Extend the Tapestry.Initializer with a static method that instantiates a

ClickOnce.



Tapestry.Initializer.clickOnce = function(spec) {

new ClickOnce(spec.elementId);

};



Re: Confirm mixin with form validation errors

2012-09-13 Thread Josh Canfield
I don't think this addresses the problem though, right?

If client-side form validation fails you still are in a state where you
can't click the submit button again after fixing the error.

Tapestry doesn't have an event for "validation failed", and I don't know of
an approved way to workaround that. But! What you can do is add an observer
for Tapestry.FORM_VALIDATE_FIELDS_EVENT and set a timeout (1/4 of a
second?) to re-enable the field if you don't get a
Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT before the timeout.

Here is a prototype based on Geoff's example from jumpstart. This was
created for submit buttons, you'd have to adjust for links (find the
form...)

ClickOnce = Class.create( {

initialize: function(elementId) {
var el = $(elementId);
el.clickOnce = this;
if ( el['form'] ) {
el.form.observe(Tapestry.FORM_VALIDATE_FIELDS_EVENT, function()
{
console.log("Hey, we're observing!");
el.clickOnce.clickOnceTimeout =
window.setTimeout(function(){
console.log("Let them click again")
el.clickOnce.alreadyClickedOnce = false;
}, 250)
});

el.form.observe(Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT,
function() {
window.clearTimeout(el.clickOnce.clickOnceTimeout);
});
}
this.alreadyClickedOnce = false;

Event.observe(el, 'click',
this.doClickOnce.bindAsEventListener(this));
},

doClickOnce: function(e) {
var element = Event.element(event);
console.log("Clicked");
if (element.clickOnce.alreadyClickedOnce) {
console.log("and cancelled");
e.stop();
}
element.clickOnce.alreadyClickedOnce = true;
}

} );


// Extend the Tapestry.Initializer with a static method that instantiates a
ClickOnce.

Tapestry.Initializer.clickOnce = function(spec) {
new ClickOnce(spec.elementId);
};


Re: Confirm mixin with form validation errors

2012-09-13 Thread trsvax
Here is my jQuery one that is added to a form

@MixinAfter
@Import( library={"submitonce.js"})
public class SubmitOnce {

@Inject
private Logger logger;

@Inject
private JavaScriptSupport javaScriptSupport;

@InjectContainer
private ClientElement clientElement;

private String id;

void beginRender() {
id = clientElement.getClientId();
}

void afterRender(MarkupWriter writer) {

JSONObject params = new JSONObject();
params.put("id",id);
javaScriptSupport.addInitializerCall("submitonce", params);
}

}

(function( $ ) {
$.extend(Tapestry.Initializer, {


submitonce: function(specs) {
$('#'+specs.id + ' :submit').removeAttr('disabled');


$('#'+specs.id).bind('tapestry:formprepareforsubmit',function() {
$('#'+specs.id + ' 
:submit').attr('disabled', 'disabled');
});

}
});
}) ( jQuery );

You need to look for the formprepareforsubmit event.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Confirm-mixin-with-form-validation-errors-tp5716265p5716266.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Confirm Mixin

2011-01-13 Thread Josh Canfield
The answer is somewhere on the list. Essentially you need to put your
confirm on a span around the text of the link because you can't
prevent other handlers on the same element from running (browser/js
limitation).

something like:
myconfirm

Josh

On Thu, Jan 13, 2011 at 10:01 AM,   wrote:
> I have a confirm mixin that I use.  I can added it to a  and it
> works fine.  When I try to use it with a  the confirmation
> box is displayed but the cancel button doesn't stop the submit.
>
>         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 mailto:ch...@thegodcode.net";>Chris Lewis 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 
>
> 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
>
>

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



Re: Confirm Mixin

2011-01-13 Thread Shing Hing Man
Have you tried the confirm Mixin in Tapx ?

  https://github.com/hlship/tapx/

Shing 

--- On Fri, 14/1/11, mwilliam...@kcp.com  wrote:

> From: mwilliam...@kcp.com 
> Subject: Confirm Mixin
> To: "Tapestry users" 
> Date: Friday, 14 January, 2011, 2:01
> I have a confirm mixin that I
> use.  I can added it to a  and it
> works fine.  When I try to use it with a
>  the confirmation
> box is displayed but the cancel button doesn't stop the
> submit.
> 
>      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 mailto:ch...@thegodcode.net";>Chris
> Lewis 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 
> 
> 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
> 
> 




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



Re: "Confirm" mixin won't cancel when in zone

2010-05-14 Thread Geoff Callender
Thanks Josh, you led me to the answer. As you said, e.stop() stops bubble-up, 
so all I had to do was move the Confirm to an element within the EvenLink. I 
replaced this...

Delete...

with this...



Delete...



and it works like a charm!

Cheers,

Geoff


On 15/05/2010, at 1:18 AM, Josh Canfield wrote:

> Whoops, I was looking at an old version of tapestry.js, back when they
> onclick function was replaced and there wasn't the observe.
> 
> You can look at the code for stopObserving in prototype.js... but, you
> really can't know what order the events are going to get fired in so
> you can't just remove it from your event. You might be able to wrap
> something around all the events for your link... but it's getting
> complicated.
> 
> On Fri, May 14, 2010 at 7:31 AM, Geoff Callender
>  wrote:
>> I see what you mean. The "Tapestry.waitForPage(event)" is not a problem. The 
>> real problem is that Tapestry.init (which is added to the bottom of the page 
>> after "new Confirm(...)") sets up the linkZone, part of which is adding 
>> "element.observe("click", function(event) { some XHR stuff happens here })". 
>> That's all in tapestry.js.
>> 
>> So ideally Confirm.doConfirm would remove or add Tapestry's linkZone click 
>> observer depending on whether you confirm or cancel the dialog box.
>> 
>> BUT, how do I get a list of event observers in this version of prototype 
>> (1.6.0)?
>> 
>> Geoff
>> 
>> On 14/05/2010, at 4:59 PM, Josh Canfield wrote:
>> 
>>> event.stop() prevents bubbling up to parent elements, but I don't
>>> believe you can prevent other event handlers from firing (you can test
>>> to see if the event.stopped property is set but it's up to the other
>>> events to implement the check).
>>> 
>>> That said, the linkZone method sets the onclick function on the object
>>> directly instead of using Event.observe. I haven't looked at it hard
>>> enough to pass judgement but this gives you the opportunity to chain
>>> the onclick handler by saving a copy in your object and replacing it
>>> with your own function. Since you can't enforce ordering for observed
>>> events, or prevent them from running maybe this is why onclick is set
>>> directly.
>>> 
>>> Josh
>>> 
>>> 
>>> On Thu, May 13, 2010 at 5:22 PM, Geoff Callender
>>>  wrote:
 I have a Confirm mixin that works fine until I put it in a zone. It still 
 pops up a confirmation dialog but when Cancel is pressed the mixin fails 
 to stop the event.
 
 My mixin adds javascript that observes the element, but the zone seems to 
 upset it by adding javascript directly to the element, eg:
 
>>> shape="rect" href="./simplewithzone:delete">Delete...
 
 What do I need to change in Confirm to make it stop the event when there's 
 a zone?
 
 Here's source for confirm.js and Confirm.java:
 
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();
}
}
 
}
 
package jumpstart.web.mixins;
 
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ClientElement;
import org.apache.tapestry5.RenderSupport;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.InjectContainer;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
 
@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));
}
 
}
 
 Thanks in advance,
 
 Geoff
>>> 
>>> 
>>> 
>>> --
>>> --
>>> http://www.bodylabgym.com - a private, by appointment only, one-on-one
>>> health and fitness facility.
>>> --
>>> http://www.ectransition.com - Quality Electronic Ciga

Re: "Confirm" mixin won't cancel when in zone

2010-05-14 Thread Josh Canfield
Whoops, I was looking at an old version of tapestry.js, back when they
onclick function was replaced and there wasn't the observe.

You can look at the code for stopObserving in prototype.js... but, you
really can't know what order the events are going to get fired in so
you can't just remove it from your event. You might be able to wrap
something around all the events for your link... but it's getting
complicated.

On Fri, May 14, 2010 at 7:31 AM, Geoff Callender
 wrote:
> I see what you mean. The "Tapestry.waitForPage(event)" is not a problem. The 
> real problem is that Tapestry.init (which is added to the bottom of the page 
> after "new Confirm(...)") sets up the linkZone, part of which is adding 
> "element.observe("click", function(event) { some XHR stuff happens here })". 
> That's all in tapestry.js.
>
> So ideally Confirm.doConfirm would remove or add Tapestry's linkZone click 
> observer depending on whether you confirm or cancel the dialog box.
>
> BUT, how do I get a list of event observers in this version of prototype 
> (1.6.0)?
>
> Geoff
>
> On 14/05/2010, at 4:59 PM, Josh Canfield wrote:
>
>> event.stop() prevents bubbling up to parent elements, but I don't
>> believe you can prevent other event handlers from firing (you can test
>> to see if the event.stopped property is set but it's up to the other
>> events to implement the check).
>>
>> That said, the linkZone method sets the onclick function on the object
>> directly instead of using Event.observe. I haven't looked at it hard
>> enough to pass judgement but this gives you the opportunity to chain
>> the onclick handler by saving a copy in your object and replacing it
>> with your own function. Since you can't enforce ordering for observed
>> events, or prevent them from running maybe this is why onclick is set
>> directly.
>>
>> Josh
>>
>>
>> On Thu, May 13, 2010 at 5:22 PM, Geoff Callender
>>  wrote:
>>> I have a Confirm mixin that works fine until I put it in a zone. It still 
>>> pops up a confirmation dialog but when Cancel is pressed the mixin fails to 
>>> stop the event.
>>>
>>> My mixin adds javascript that observes the element, but the zone seems to 
>>> upset it by adding javascript directly to the element, eg:
>>>
>>>        >> shape="rect" href="./simplewithzone:delete">Delete...
>>>
>>> What do I need to change in Confirm to make it stop the event when there's 
>>> a zone?
>>>
>>> Here's source for confirm.js and Confirm.java:
>>>
>>>        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();
>>>                        }
>>>                }
>>>
>>>        }
>>>
>>>        package jumpstart.web.mixins;
>>>
>>>        import org.apache.tapestry5.BindingConstants;
>>>        import org.apache.tapestry5.ClientElement;
>>>        import org.apache.tapestry5.RenderSupport;
>>>        import org.apache.tapestry5.annotations.AfterRender;
>>>        import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
>>>        import org.apache.tapestry5.annotations.InjectContainer;
>>>        import org.apache.tapestry5.annotations.Parameter;
>>>        import org.apache.tapestry5.ioc.annotations.Inject;
>>>
>>>       �...@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));
>>>                }
>>>
>>>        }
>>>
>>> Thanks in advance,
>>>
>>> Geoff
>>
>>
>>
>> --
>> --
>> http://www.bodylabgym.com - a private, by appointment only, one-on-one
>> health and fitness facility.
>> --
>> http://www.ectransition.com - Quality Electronic Cigarettes at a
>> reasonable price!
>> --
>> TheDailyTube.com. Sign up and get the best new videos on the internet
>> delivered fresh to your inbox.
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at

Re: "Confirm" mixin won't cancel when in zone

2010-05-14 Thread Geoff Callender
I see what you mean. The "Tapestry.waitForPage(event)" is not a problem. The 
real problem is that Tapestry.init (which is added to the bottom of the page 
after "new Confirm(...)") sets up the linkZone, part of which is adding 
"element.observe("click", function(event) { some XHR stuff happens here })". 
That's all in tapestry.js.

So ideally Confirm.doConfirm would remove or add Tapestry's linkZone click 
observer depending on whether you confirm or cancel the dialog box.

BUT, how do I get a list of event observers in this version of prototype 
(1.6.0)?

Geoff

On 14/05/2010, at 4:59 PM, Josh Canfield wrote:

> event.stop() prevents bubbling up to parent elements, but I don't
> believe you can prevent other event handlers from firing (you can test
> to see if the event.stopped property is set but it's up to the other
> events to implement the check).
> 
> That said, the linkZone method sets the onclick function on the object
> directly instead of using Event.observe. I haven't looked at it hard
> enough to pass judgement but this gives you the opportunity to chain
> the onclick handler by saving a copy in your object and replacing it
> with your own function. Since you can't enforce ordering for observed
> events, or prevent them from running maybe this is why onclick is set
> directly.
> 
> Josh
> 
> 
> On Thu, May 13, 2010 at 5:22 PM, Geoff Callender
>  wrote:
>> I have a Confirm mixin that works fine until I put it in a zone. It still 
>> pops up a confirmation dialog but when Cancel is pressed the mixin fails to 
>> stop the event.
>> 
>> My mixin adds javascript that observes the element, but the zone seems to 
>> upset it by adding javascript directly to the element, eg:
>> 
>>> shape="rect" href="./simplewithzone:delete">Delete...
>> 
>> What do I need to change in Confirm to make it stop the event when there's a 
>> zone?
>> 
>> Here's source for confirm.js and Confirm.java:
>> 
>>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();
>>}
>>}
>> 
>>}
>> 
>>package jumpstart.web.mixins;
>> 
>>import org.apache.tapestry5.BindingConstants;
>>import org.apache.tapestry5.ClientElement;
>>import org.apache.tapestry5.RenderSupport;
>>import org.apache.tapestry5.annotations.AfterRender;
>>import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
>>import org.apache.tapestry5.annotations.InjectContainer;
>>import org.apache.tapestry5.annotations.Parameter;
>>import org.apache.tapestry5.ioc.annotations.Inject;
>> 
>>@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));
>>}
>> 
>>}
>> 
>> Thanks in advance,
>> 
>> Geoff
> 
> 
> 
> -- 
> --
> http://www.bodylabgym.com - a private, by appointment only, one-on-one
> health and fitness facility.
> --
> http://www.ectransition.com - Quality Electronic Cigarettes at a
> reasonable price!
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 



Re: "Confirm" mixin won't cancel when in zone

2010-05-14 Thread Josh Canfield
event.stop() prevents bubbling up to parent elements, but I don't
believe you can prevent other event handlers from firing (you can test
to see if the event.stopped property is set but it's up to the other
events to implement the check).

That said, the linkZone method sets the onclick function on the object
directly instead of using Event.observe. I haven't looked at it hard
enough to pass judgement but this gives you the opportunity to chain
the onclick handler by saving a copy in your object and replacing it
with your own function. Since you can't enforce ordering for observed
events, or prevent them from running maybe this is why onclick is set
directly.

Josh


On Thu, May 13, 2010 at 5:22 PM, Geoff Callender
 wrote:
> I have a Confirm mixin that works fine until I put it in a zone. It still 
> pops up a confirmation dialog but when Cancel is pressed the mixin fails to 
> stop the event.
>
> My mixin adds javascript that observes the element, but the zone seems to 
> upset it by adding javascript directly to the element, eg:
>
>         shape="rect" href="./simplewithzone:delete">Delete...
>
> What do I need to change in Confirm to make it stop the event when there's a 
> zone?
>
> Here's source for confirm.js and Confirm.java:
>
>        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();
>                        }
>                }
>
>        }
>
>        package jumpstart.web.mixins;
>
>        import org.apache.tapestry5.BindingConstants;
>        import org.apache.tapestry5.ClientElement;
>        import org.apache.tapestry5.RenderSupport;
>        import org.apache.tapestry5.annotations.AfterRender;
>        import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
>        import org.apache.tapestry5.annotations.InjectContainer;
>        import org.apache.tapestry5.annotations.Parameter;
>        import org.apache.tapestry5.ioc.annotations.Inject;
>
>       �...@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));
>                }
>
>        }
>
> Thanks in advance,
>
> Geoff



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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



Re: "Confirm" mixin won't cancel when in zone

2010-05-13 Thread Geoff Callender
I'm not doing that - Tapestry is when it adds zone support.

On 14/05/2010, at 10:54 AM, Paul Stanton wrote:

> just as an aside, you don't need to prefix your onclick with 'javascript:'
> 
> Geoff Callender wrote:
>>  > shape="rect" href="./simplewithzone:delete">Delete...
>>  
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 


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



Re: "Confirm" mixin won't cancel when in zone

2010-05-13 Thread Paul Stanton

just as an aside, you don't need to prefix your onclick with 'javascript:'

Geoff Callender wrote:

Delete...
  


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



Re: "Confirm" mixin won't cancel when in zone

2010-05-13 Thread Thiago H. de Paula Figueiredo
On Thu, 13 May 2010 21:22:25 -0300, Geoff Callender  
 wrote:


	shape="rect" href="./simplewithzone:delete">Delete...


I'm no JavaScript guru (very far from that, actually), but have you tried  
setting onclick to null?


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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