use of org.apache.wicket.behavior.AbstractAjaxBehavior in project wicket by apache.
the class AjaxEditableTest method testDisabledAjaxEditableLabel.
/**
* Tests whether disabling/enabling an AjaxEditableLabel also disables/enables the
* <code>LabelBehavior</code>
*/
@SuppressWarnings({ "unchecked" })
@Test
public void testDisabledAjaxEditableLabel() {
Page page = tester.getLastRenderedPage();
AjaxEditableLabel<String> ajaxLabel = (AjaxEditableLabel<String>) page.get("ajaxLabel");
AjaxLink<Void> toggle = (AjaxLink<Void>) page.get("toggle");
AbstractAjaxBehavior toggleBehavior = (AbstractAjaxBehavior) toggle.getBehaviors().get(0);
// check for correct rendering
tester.assertInvisible("ajaxLabel:editor");
tester.assertVisible("ajaxLabel:label");
// disable ajaxLabel
tester.executeBehavior(toggleBehavior);
// check for the *absence* of the ajax onclick call
String markup = tester.getTagById(ajaxLabel.getMarkupId()).getMarkup();
assertFalse(markup.matches(".*onclick=\"var wcall=wicketAjaxGet.*"));
// enable ajaxLabel
tester.executeBehavior(toggleBehavior);
// check for the *presence* of the ajax onclick call
// TODO Wicket.next - re-enable
// markup = tester.getTagById(ajaxLabel.getMarkupId()).getMarkup();
// assertTrue(markup.matches(".*onclick=\"var wcall=Wicket.Ajax.get.*"));
}
use of org.apache.wicket.behavior.AbstractAjaxBehavior in project wicket by apache.
the class AjaxEditableTest method testAjaxEditableLabel.
/**
* Tests default AjaxEditableLabel behavior
*/
@SuppressWarnings({ "unchecked" })
@Test
public void testAjaxEditableLabel() {
Page page = tester.getLastRenderedPage();
AjaxEditableLabel<String> ajaxLabel = (AjaxEditableLabel<String>) page.get("ajaxLabel");
AbstractAjaxBehavior labelBehavior = (AbstractAjaxBehavior) ajaxLabel.get("label").getBehaviors().get(0);
AbstractAjaxBehavior editorBehavior = (AbstractAjaxBehavior) ajaxLabel.get("editor").getBehaviors().get(0);
// "click" on the label and check for valid visibility
tester.executeBehavior(labelBehavior);
tester.assertVisible("ajaxLabel:editor");
tester.assertInvisible("ajaxLabel:label");
// "leave" the editor and check for valid visibility
tester.executeBehavior(editorBehavior);
tester.assertInvisible("ajaxLabel:editor");
tester.assertVisible("ajaxLabel:label");
}
Aggregations