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: [email protected]
For additional commands, e-mail: [email protected]