You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by dick_hu <di...@gmail.com> on 2012/01/04 04:50:08 UTC

mixins Confirm is invalid

I add a mixins "Confirm" to a EventLink,When the eventlink request is xhr
will return a zone,the mixins 
is invalid.

the mixins's  java is
@Import(library = "confirm.js")
public class Confirm {

	@InjectContainer
	private ClientElement container;

	@Inject
	private JavaScriptSupport javaScriptSupport;

	@Parameter(value = "confirm.message", defaultPrefix =
BindingConstants.MESSAGE)
	private String confirmMessage;

	@Parameter(defaultPrefix = BindingConstants.LITERAL, value = "click")
	private String clientEvent;

	@org.apache.tapestry5.annotations.BeforeRenderTemplate
	void addScript() {
		JSONObject json = new JSONObject();
		json.put("id", container.getClientId());
		json.put("message", confirmMessage);
		json.put("event", clientEvent);

		javaScriptSupport.addScript("new ConfirmDialog(%s);", json.toString());
	}
}


js is 
ConfirmDialog = Class.create({initialize:function (spec) {
	Event.observe($(spec.id), spec.event, function (event) {
		var result = confirm(spec.message);
		if (result == false) {
			alert(event);
			Event.stop(event);
			return false;
		}
	});
}});

Can anyone help me,is there another mixins like the "ConFirm" provide



--
View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5118652.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: mixins Confirm is invalid

Posted by Taha Hafeez <ta...@gmail.com>.
This is what works for me in jquery

(function($) {

    $.extend(Tapestry.Initializer, {
        confirm: function(params) {
            $("#" + params.element).bind(params.event, function(event) {

                if (!confirm(params.message)) {
                    event.preventDefault();
                }

            });
        }
    });

})(jQuery);


On Wed, Jan 4, 2012 at 11:13 AM, dick_hu <di...@gmail.com> wrote:
>
> Taha Hafeez wrote
>>
>> Try  event.preventDefault() instead of Event.stop(event)
>>
>> I think that will do
>>
>>
>>
>
> It failed also.
> thank you.
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5118771.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
Regards

Taha Hafeez Siddiqi (tawus)
http://tawus.wordpress.com

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


Re: mixins Confirm is invalid

Posted by dick_hu <di...@gmail.com>.
Taha Hafeez wrote
> 
> Try  event.preventDefault() instead of Event.stop(event)
> 
> I think that will do
> 
> 
> 

It failed also. 
thank you.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5118771.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: mixins Confirm is invalid

Posted by Taha Hafeez <ta...@gmail.com>.
Try  event.preventDefault() instead of Event.stop(event)

I think that will do


On Wed, Jan 4, 2012 at 10:16 AM, dick_hu <di...@gmail.com> wrote:
> No, it means the confirm does not stop the event when I click the cancel
> button in the dialog.
> Taha Hafeez wrote
>>
>> Hi
>>
>> What do you mean when you say it is invalid ?
>>
>> Is there any error ?
>>
>>
>>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5118712.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
Regards

Taha Hafeez Siddiqi (tawus)
http://tawus.wordpress.com

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


Re: mixins Confirm is invalid

Posted by dick_hu <di...@gmail.com>.
No, it means the confirm does not stop the event when I click the cancel
button in the dialog.
Taha Hafeez wrote
> 
> Hi
> 
> What do you mean when you say it is invalid ?
> 
> Is there any error ?
> 
> 
> 


--
View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5118712.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: mixins Confirm is invalid

Posted by Taha Hafeez <ta...@gmail.com>.
Hi

What do you mean when you say it is invalid ?

Is there any error ?


On Wed, Jan 4, 2012 at 9:20 AM, dick_hu <di...@gmail.com> wrote:
> I add a mixins "Confirm" to a EventLink,When the eventlink request is xhr
> will return a zone,the mixins
> is invalid.
>
> the mixins's  java is
> @Import(library = "confirm.js")
> public class Confirm {
>
>        @InjectContainer
>        private ClientElement container;
>
>        @Inject
>        private JavaScriptSupport javaScriptSupport;
>
>        @Parameter(value = "confirm.message", defaultPrefix =
> BindingConstants.MESSAGE)
>        private String confirmMessage;
>
>        @Parameter(defaultPrefix = BindingConstants.LITERAL, value = "click")
>        private String clientEvent;
>
>        @org.apache.tapestry5.annotations.BeforeRenderTemplate
>        void addScript() {
>                JSONObject json = new JSONObject();
>                json.put("id", container.getClientId());
>                json.put("message", confirmMessage);
>                json.put("event", clientEvent);
>
>                javaScriptSupport.addScript("new ConfirmDialog(%s);", json.toString());
>        }
> }
>
>
> js is
> ConfirmDialog = Class.create({initialize:function (spec) {
>        Event.observe($(spec.id), spec.event, function (event) {
>                var result = confirm(spec.message);
>                if (result == false) {
>                        alert(event);
>                        Event.stop(event);
>                        return false;
>                }
>        });
> }});
>
> Can anyone help me,is there another mixins like the "ConFirm" provide
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5118652.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
Regards

Taha Hafeez Siddiqi (tawus)
http://tawus.wordpress.com

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


Re: mixins Confirm is invalid

Posted by dick_hu <di...@gmail.com>.
Geoff Callender-2 wrote
> 
> Yes, there's a trick to it  - search for  t:event="delete"
> in this example:
> 
> 
> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/componentscrud/persons
> 
> There's an explanation below it.
> 
> 
> 
Thank you very much , you are right.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5121497.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: mixins Confirm is invalid

Posted by Geoff Callender <ge...@gmail.com>.
Yes, there's a trick to it  - search for  t:event="delete"
in this example:

	http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/componentscrud/persons

There's an explanation below it.

Cheers,

Geoff

On 04/01/2012, at 2:50 PM, dick_hu wrote:

> I add a mixins "Confirm" to a EventLink,When the eventlink request is xhr
> will return a zone,the mixins 
> is invalid.
> 
> the mixins's  java is
> @Import(library = "confirm.js")
> public class Confirm {
> 
> 	@InjectContainer
> 	private ClientElement container;
> 
> 	@Inject
> 	private JavaScriptSupport javaScriptSupport;
> 
> 	@Parameter(value = "confirm.message", defaultPrefix =
> BindingConstants.MESSAGE)
> 	private String confirmMessage;
> 
> 	@Parameter(defaultPrefix = BindingConstants.LITERAL, value = "click")
> 	private String clientEvent;
> 
> 	@org.apache.tapestry5.annotations.BeforeRenderTemplate
> 	void addScript() {
> 		JSONObject json = new JSONObject();
> 		json.put("id", container.getClientId());
> 		json.put("message", confirmMessage);
> 		json.put("event", clientEvent);
> 
> 		javaScriptSupport.addScript("new ConfirmDialog(%s);", json.toString());
> 	}
> }
> 
> 
> js is 
> ConfirmDialog = Class.create({initialize:function (spec) {
> 	Event.observe($(spec.id), spec.event, function (event) {
> 		var result = confirm(spec.message);
> 		if (result == false) {
> 			alert(event);
> 			Event.stop(event);
> 			return false;
> 		}
> 	});
> }});
> 
> Can anyone help me,is there another mixins like the "ConFirm" provide
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/mixins-Confirm-is-invalid-tp5118652p5118652.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>