You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by lucast <lu...@hotmail.com> on 2011/11/29 14:52:45 UTC

Jquery Confirmation Dialog - or WiQuery Dialog?

Dear Forum,
I want to implement a modal window for confirming the deletion of objects. I
want to use Jquery confirmation dialog, just like on 
http://jqueryui.com/demos/dialog/modal-confirmation.html this example .

Is there a way to add this Jquery script to my code and to know if the
delete button has been clicked?
When I use jQuery widgets, I render them on load from renderHead function
but I never had to use dialogs. 

I thought of using wiQuery's functionality by creating a Dialog object and
adding DialogButton objects to it.
But I don't know how to how about adding the necessary code to record that
the delete button has been clicked.
I know I need to add the following code to the Dialog object:
  DialogButton deleteButton = new DialogButton("delete", jsScope);
but I don't know what I should put on jsScope.

I don't want to depend on wiQuery, if learning how to read a value from
javascript/jquery code gives me more freedom.

Thanks in advance,
Lucas



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4119238.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Lucas,

Glad to be of some help:-)

Ernesto

On Sat, Dec 3, 2011 at 10:11 AM, lucast <lu...@hotmail.com> wrote:
> Hi Ernesto,
> I have just implemented the solution suggested for 1.4.x wiquery and it
> works great, exactly what one needs!
> I just added the dialog.close(target); to the onButtonClicked method to exit
> the dialog.
> Thank you very much for this.
> Wiquery is very useful for folks like me.
> It's another incentive into looking at the source code to see how it works
> and to start doing more complex javascript integration with wicket.
>
> Thank you very much indeed.
> Lucas
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4152782.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by lucast <lu...@hotmail.com>.
Hi Ernesto,
I have just implemented the solution suggested for 1.4.x wiquery and it
works great, exactly what one needs!
I just added the dialog.close(target); to the onButtonClicked method to exit
the dialog.
Thank you very much for this. 
Wiquery is very useful for folks like me.
It's another incentive into looking at the source code to see how it works
and to start doing more complex javascript integration with wicket.

Thank you very much indeed.
Lucas

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4152782.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Lucas,

I just ported the solution to 1.4.x wiquery. Can you give it a try and
see if it solves your use case?

Regards,

Ernesto

On Wed, Nov 30, 2011 at 8:10 PM, lucast <lu...@hotmail.com> wrote:
> Hi Ernesto,
> Yes, I believe that porting it to 1.4.2 would be ideal. It means that I can
> finish this functionality and upgrade wicket at a later date.
> That, of course, would be most generous of you.
>
> I was going to do that myself by doing a diff between the two files but I
> noticed the new structure between wiquery 1.4.x and 1.5.x.
>
> Also, (although, this would be more suitable for a different post), I'm
> calling mvn -e package on wiquery-read-only and I'm getting some errors
> (attached, just in case,
> http://apache-wicket.1842946.n4.nabble.com/file/n4124319/mvnPackageBuild.log
> mvnPackageBuild.log ).
> It starts with
> ...wiquery-core/src/main/java/org/odlabs/wiquery/core/WiQuerySettings.java:[31,28]
> package org.apache.wicket.css does not exist. After that I get a long trace.
> I don't know why maven is complaining.
>
> But in short, having that functionality in 1.4.2 would be grand.
> Thank you very much,
> Lucas
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4124319.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by lucast <lu...@hotmail.com>.
Hi Ernesto,
Yes, I believe that porting it to 1.4.2 would be ideal. It means that I can
finish this functionality and upgrade wicket at a later date.
That, of course, would be most generous of you.

I was going to do that myself by doing a diff between the two files but I
noticed the new structure between wiquery 1.4.x and 1.5.x.

Also, (although, this would be more suitable for a different post), I'm
calling mvn -e package on wiquery-read-only and I'm getting some errors
(attached, just in case, 
http://apache-wicket.1842946.n4.nabble.com/file/n4124319/mvnPackageBuild.log
mvnPackageBuild.log ).
It starts with
...wiquery-core/src/main/java/org/odlabs/wiquery/core/WiQuerySettings.java:[31,28]
package org.apache.wicket.css does not exist. After that I get a long trace.
I don't know why maven is complaining.

But in short, having that functionality in 1.4.2 would be grand.
Thank you very much,
Lucas





--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4124319.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
The solution provided should also work for 1.4.x.  Porting it to 1.4.x
should be very easy: let me know if that would be useful to you.

Regards,

Ernesto

On Wed, Nov 30, 2011 at 7:25 PM, lucast <lu...@hotmail.com> wrote:
> Thank you, Ernesto.
> I have checked out wiQuery trunk. I am still to upgrade from wicket 1.4.19
> to 1.5.
> As soon as I have, I'll let you know how the dialog button functionality
> goes.
> Thank you very much for adding this functionality.
> I am sure other developers will find it of much use.
> Kind regards,
> Lucas
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4124155.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by lucast <lu...@hotmail.com>.
Thank you, Ernesto.
I have checked out wiQuery trunk. I am still to upgrade from wicket 1.4.19
to 1.5.
As soon as I have, I'll let you know how the dialog button functionality
goes.
Thank you very much for adding this functionality. 
I am sure other developers will find it of much use.
Kind regards,
Lucas

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4124155.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Lucas,

With commit [1] I have added AjaxButtons to wiQuery dialog. You can
use them as follow:

HTML AjaxDialogTestPage.html

<html xmlns:wicket>
<body>
	<div wicket:id="dialog">
		dddldddd!
	</div>	
</body>
</html>

Java:

public class AjaxDialogTestPage extends WebPage
{

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private Dialog dialog;

	private AjaxDialogButton ok;

	private AjaxDialogButton cancel;

	/**
	 *
	 */
	public AjaxDialogTestPage()
	{
		ok = new AjaxDialogButton("Ok")
		{

			private static final long serialVersionUID = 1L;

			@Override
			protected void onButtonClicked(AjaxRequestTarget target)
			{
				//do your cancel  logic here

			}
		};
		cancel = new AjaxDialogButton("Cancel")
		{

			private static final long serialVersionUID = 1L;

			@Override
			protected void onButtonClicked(AjaxRequestTarget target)
			{
				//do your cancel  logic here
			}
		};
		dialog = new Dialog("dialog");
		dialog.setTitle("Test");
		add(dialog);
		dialog.setAutoOpen(true);
		dialog.setButtons(ok, cancel);
	}

}

Hope this helps:-)

Regards,

Ernesto

References

1-http://code.google.com/p/wiquery/source/detail?r=1950

On Tue, Nov 29, 2011 at 2:52 PM, lucast <lu...@hotmail.com> wrote:
> Dear Forum,
> I want to implement a modal window for confirming the deletion of objects. I
> want to use Jquery confirmation dialog, just like on
> http://jqueryui.com/demos/dialog/modal-confirmation.html this example .
>
> Is there a way to add this Jquery script to my code and to know if the
> delete button has been clicked?
> When I use jQuery widgets, I render them on load from renderHead function
> but I never had to use dialogs.
>
> I thought of using wiQuery's functionality by creating a Dialog object and
> adding DialogButton objects to it.
> But I don't know how to how about adding the necessary code to record that
> the delete button has been clicked.
> I know I need to add the following code to the Dialog object:
>  DialogButton deleteButton = new DialogButton("delete", jsScope);
> but I don't know what I should put on jsScope.
>
> I don't want to depend on wiQuery, if learning how to read a value from
> javascript/jquery code gives me more freedom.
>
> Thanks in advance,
> Lucas
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4119238.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Lucas,

I think you will have to do something similar to what AjaxSlider does.

1- Attach a div to  your page and an AbstractDefaultAjaxBehavior to that div.
2- Use that behavior to construct callback URL for buttons and on Buttons

protected void execute(JsScopeContext scopeContext)
		{
			scopeContext.append(new
StringBuffer().append("wicketAjaxGet(url+"?button=Ok)"))
				.toString());

		}
So that you can "see" which button was clicked at server side

Regards,

Ernesto


On Tue, Nov 29, 2011 at 2:52 PM, lucast <lu...@hotmail.com> wrote:
> Dear Forum,
> I want to implement a modal window for confirming the deletion of objects. I
> want to use Jquery confirmation dialog, just like on
> http://jqueryui.com/demos/dialog/modal-confirmation.html this example .
>
> Is there a way to add this Jquery script to my code and to know if the
> delete button has been clicked?
> When I use jQuery widgets, I render them on load from renderHead function
> but I never had to use dialogs.
>
> I thought of using wiQuery's functionality by creating a Dialog object and
> adding DialogButton objects to it.
> But I don't know how to how about adding the necessary code to record that
> the delete button has been clicked.
> I know I need to add the following code to the Dialog object:
>  DialogButton deleteButton = new DialogButton("delete", jsScope);
> but I don't know what I should put on jsScope.
>
> I don't want to depend on wiQuery, if learning how to read a value from
> javascript/jquery code gives me more freedom.
>
> Thanks in advance,
> Lucas
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4119238.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Jquery Confirmation Dialog - or WiQuery Dialog?

Posted by "sauli.ketola" <sa...@mbnet.fi>.
I'm not sure if you need this for an ajax button but I think you can do
something similar for a normal button too. I achieved the same thing like
this:

1. Create a class ConfirmBehavior that extends AbstractBehavior.
2. Override onRendered -method with this (adds the div containing the dialog
html after the button):

super.onRendered( component );
		component
				.getResponse()
				.write(
						String
								.format(
										"\n<div style=\"display: none;\" id=\"dialog-confirm_%s\"
title=\"%s\"><p>%s</p></div>",
										component.getMarkupId( true ),
										"Title for the dialog",
										"Content for the dialog" ) );

3. override bind -method with this (wraps the ajax call with the jquery
dialog by an AjaxCallDecorator):
		super.bind( component );

		AjaxButton button = (AjaxButton) component;
		this.markupId = button.getMarkupId( true );
		
		button.addAjaxCallDecorator( new IAjaxCallDecorator()
		{

			@Override
			public CharSequence decorateScript( CharSequence originalScript )
			{       // wraps the original script with the jquery dialog
				String javascript = "$( '#dialog-confirm_%s' ).dialog({" + "resizable:
false,"
						+ "height:%d," + "modal: true," + "buttons: {" + "'%s': function() {"
						+ "$( this ).dialog( 'close' ); %s;" + "}," + "'%s': function() {"
						+ "$( this ).dialog( 'close' );" + "}" + "}" + "});";

				String formatted = String.format(
						javascript,
						ConfirmBehavior.this.markupId,
						height,
						"Ok",
						originalScript,
						"Cancel" );
				return formatted;
			}

			@Override
			public CharSequence decorateOnSuccessScript( CharSequence script )
			{
				return script;
			}

			@Override
			public CharSequence decorateOnFailureScript( CharSequence script )
			{
				return script;
			}
		} );

4. add this behavior to the button.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Jquery-Confirmation-Dialog-or-WiQuery-Dialog-tp4119238p4121974.html
Sent from the Users forum mailing list archive at Nabble.com.

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