Hi all,
I'm implementing tests with WicketTester for Apache Syncope console.
How can I simulate a click on my confirmation modal?
This is my java class
public class ConfirmationModalBehavior extends Behavior {
private final String message;
public ConfirmationModalBehavior() {
this("confirmDelete");
}
public ConfirmationModalBehavior(final String msg) {
message = new ResourceModel(msg, "Are you sure?").getObject();
}
@Override
public void renderHead(final Component component, final
IHeaderResponse response) {
super.renderHead(component, response);
response.render(JavaScriptHeaderItem.forScript("var confirm =
false;", null));
response.render($(component).on("click",
new JavaScriptInlineFunction(""
+ "var element = $(this);"
+ "evt.preventDefault();"
+ "if(confirm == false){"
+ "evt.stopImmediatePropagation();"
+ "bootbox.confirm(\"" + message + "\",
function(result){"
+ "if(result == true){"
+ "confirm = true;"
+ "element.click();"
+ "}"
+ "else{confirm = false;}"
+ "return true;"
+ "})} "
+ "else {confirm = false;};"
)).asDomReadyScript());
}
}
and this is the generated html
<div role="dialog" tabindex="-1" class="bootbox modal fade
bootbox-confirm in" style="display: block; padding-right: 16px;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button aria-hidden="true" data-dismiss="modal"
class="bootbox-close-button close" type="button" style="margin-top:
-10px;">×</button>
<div class="bootbox-body">Do you really want to delete
the selected item(s)?</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" type="button"
data-bb-handler="cancel">Cancel</button>
<button class="btn btn-primary" type="button"
data-bb-handler="confirm">OK</button>
</div>
</div>
</div>
</div>
Any suggestions?
Regards
M
--
Dott. Marco Di Sabatino Di Diodoro
Tel. +39 3939065570
Tirasa S.r.l.
Viale D'Annunzio 267 - 65127 Pescara
Tel +39 0859116307 / FAX +39 0859111173
http://www.tirasa.net
Apache Syncope PMC Member
http://people.apache.org/~mdisabatino/