You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Neha <pu...@gmail.com> on 2014/04/23 22:32:06 UTC

Wicket Message Dialog Behavior, close on click

Hi,

I am using wicket message dialog box, which is a jquery ui widget dialog.

I want to close the dialog box , when user clicks on "confirm
 button. Even if the operation takes time, the dialog box must close.

When I press "Cancel" dialog box closes immedialtely, but when I click
"confirm", and the operation takes longer , then the dialog box is still
open. I don't want this behanvior, 

I am doing something like this:

final MessageDialogAjaxBehavior confirmDialog = new
MessageDialogAjaxBehavior("confirmDialog", Model.of("Warning"), message,
DialogButtons.YES_NO, DialogIcon.WARN) {


 @Override
public void onClose(AjaxRequestTarget target, DialogButton button) {
 String js2 = this.getMarkupId() + ".dialog('close')";             

target.appendJavaScript(js2);
         

if (button != null && "YES".equalsIgnoreCase(button.toString())) 

labTestTypeService.delete(labTestTemplateType.getState(), EnoviaId.create)

target.add(container);
}

}

};



I created MessageDialogAjaxBehavior as below to add indicator appender:
public class MessageDialogAjaxBehavior extends MessageDialog implements
IAjaxIndicatorAware {

    private static final long serialVersionUID = 1L;
    private final AjaxIndicatorAppender indicatorAppender = new
AjaxIndicatorAppender();
    DialogButtons buttons;

    public MessageDialogAjaxBehavior(String id, IModel<String> title,
IModel<String> message, DialogButtons buttons, DialogIcon icon) {

        super(id, title, message, buttons, icon);
        this.buttons = buttons;
        this.add(indicatorAppender);
    }

    @Override
    public String getAjaxIndicatorMarkupId() {
        return indicatorAppender.getMarkupId();
    }

    @Override
    public void onClose(AjaxRequestTarget target, DialogButton button) {

    }

    @Override
    public void onClick(AjaxRequestTarget target, DialogButton button) {

        super.onClick(target, button);

    }

But , this doesn't close the dialog box, til opertation is complete.

Kindly help


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Message-Dialog-Behavior-close-on-click-tp4665557.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: Wicket Message Dialog Behavior, close on click

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

In your MessageDialogAjaxBehavior you need to override
#updateAjaxAttributes(AjaxRequestAttributes
attributes)
and do as in HandlebarsButton.java sample.

Martin Grigorov
Wicket Training and Consulting


On Fri, Apr 25, 2014 at 11:40 AM, Neha <pu...@gmail.com> wrote:

> Thanks Martin,
>
> I am not clear still to how to implement "onBeforeSend",
> Cant i add this "onBeforeSend" behavior to target.appendjavascript in some
> manner?? or do i need to create n extent a particular class
>
> Regards
> Neha
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-Message-Dialog-Behavior-close-on-click-tp4665557p4665572.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: Wicket Message Dialog Behavior, close on click

Posted by Neha <pu...@gmail.com>.
Thanks Martin,

I am not clear still to how to implement "onBeforeSend", 
Cant i add this "onBeforeSend" behavior to target.appendjavascript in some
manner?? or do i need to create n extent a particular class

Regards
Neha

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Message-Dialog-Behavior-close-on-click-tp4665557p4665572.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: Wicket Message Dialog Behavior, close on click

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

#onClose() is executed only when the Ajax request is processed at the
server side.
The JavaScript created with String js2 = this.getMarkupId() +
".dialog('close')"; target.appendJavaScript(js2);  will be executed when
the Ajax response is processed in the browser.

To close the dialog immediately you need to use 'onBeforeSend' JavaScript
callback.
See
https://github.com/martin-g/blogs/blob/master/wicket6-ajax-demo/src/main/java/com/wicketinaction/HandlebarsButton.java#L104for
a demo of 'before' callback.
Read also http://wicket.apache.org/guide/guide/ajax.html#ajax_5 for more
info.

Martin Grigorov
Wicket Training and Consulting


On Wed, Apr 23, 2014 at 11:32 PM, Neha <pu...@gmail.com> wrote:

> Hi,
>
> I am using wicket message dialog box, which is a jquery ui widget dialog.
>
> I want to close the dialog box , when user clicks on "confirm
>  button. Even if the operation takes time, the dialog box must close.
>
> When I press "Cancel" dialog box closes immedialtely, but when I click
> "confirm", and the operation takes longer , then the dialog box is still
> open. I don't want this behanvior,
>
> I am doing something like this:
>
> final MessageDialogAjaxBehavior confirmDialog = new
> MessageDialogAjaxBehavior("confirmDialog", Model.of("Warning"), message,
> DialogButtons.YES_NO, DialogIcon.WARN) {
>
>
>  @Override
> public void onClose(AjaxRequestTarget target, DialogButton button) {
>  String js2 = this.getMarkupId() + ".dialog('close')";
>
> target.appendJavaScript(js2);
>
>
> if (button != null && "YES".equalsIgnoreCase(button.toString()))
>
> labTestTypeService.delete(labTestTemplateType.getState(), EnoviaId.create)
>
> target.add(container);
> }
>
> }
>
> };
>
>
>
> I created MessageDialogAjaxBehavior as below to add indicator appender:
> public class MessageDialogAjaxBehavior extends MessageDialog implements
> IAjaxIndicatorAware {
>
>     private static final long serialVersionUID = 1L;
>     private final AjaxIndicatorAppender indicatorAppender = new
> AjaxIndicatorAppender();
>     DialogButtons buttons;
>
>     public MessageDialogAjaxBehavior(String id, IModel<String> title,
> IModel<String> message, DialogButtons buttons, DialogIcon icon) {
>
>         super(id, title, message, buttons, icon);
>         this.buttons = buttons;
>         this.add(indicatorAppender);
>     }
>
>     @Override
>     public String getAjaxIndicatorMarkupId() {
>         return indicatorAppender.getMarkupId();
>     }
>
>     @Override
>     public void onClose(AjaxRequestTarget target, DialogButton button) {
>
>     }
>
>     @Override
>     public void onClick(AjaxRequestTarget target, DialogButton button) {
>
>         super.onClick(target, button);
>
>     }
>
> But , this doesn't close the dialog box, til opertation is complete.
>
> Kindly help
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-Message-Dialog-Behavior-close-on-click-tp4665557.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
>
>