Package org.apache.click.ajax

Examples of org.apache.click.ajax.DefaultAjaxBehavior


        form.add(ageField);
        form.add(dateField);
        form.add(save);
        form.add(cancel);

        save.addBehavior(new DefaultAjaxBehavior() {

            @Override
            public ActionResult onAction(Control source) {
                // Update the form which might contain errors
                return new ActionResult(form.toString(), ActionResult.HTML);
            }
        });

        cancel.addBehavior(new DefaultAjaxBehavior() {

            @Override
            public ActionResult onAction(Control source) {
                // Update the form and ensure errors and values have been cleared
                form.clearValues();
View Full Code Here


     * Create the field Ajax behavior instance.
     *
     * @return the field Ajax behavior instance
     */
    protected Behavior createBehavior() {
        AjaxBehavior internalBehavior = new DefaultAjaxBehavior() {

            @Override
            public ActionResult onAction(Control source) {
                ActionResult actionResult = new ActionResult();

View Full Code Here

        MockContext.initContext();
        ControlRegistry registry = ControlRegistry.getThreadLocalRegistry();

        TextField field = new TextField("field");
        assertFalse(registry.hasAjaxTargetControls());
        field.addBehavior(new DefaultAjaxBehavior());
        assertTrue(registry.hasAjaxTargetControls());
    }
View Full Code Here

        TextField field = new TextField("field");

        // Test that adding behavior registers control as ajax target
        assertFalse(registry.hasAjaxTargetControls());
        field.addBehavior(new DefaultAjaxBehavior());
        assertTrue(registry.hasAjaxTargetControls());
        assertEquals(1, registry.getAjaxTargetControls().size());

        // Test that adding another behavior does not register the control twice
        field.addBehavior(new DefaultAjaxBehavior());
        assertEquals(1, registry.getAjaxTargetControls().size());

        // Test that invoking onInit does not register the control twice
        field.onInit();
        assertEquals(1, registry.getAjaxTargetControls().size());
View Full Code Here

        MockContext.initContext();
        ControlRegistry registry = ControlRegistry.getThreadLocalRegistry();

        TextField field = new TextField("field");

        Behavior interceptor = new DefaultAjaxBehavior();

        // Check interceptor is registered with registry
        assertFalse(registry.hasInterceptors());
        ControlRegistry.registerInterceptor(field, interceptor);
        assertTrue(registry.hasInterceptors());
View Full Code Here

        MockContext.initContext();
        ControlRegistry registry = ControlRegistry.getThreadLocalRegistry();

        TextField field = new TextField("field");

        Behavior interceptor = new DefaultAjaxBehavior();

        // Check interceptor is registered with registry
        assertFalse(registry.hasInterceptors());
        ControlRegistry.registerInterceptor(field, interceptor);
        assertTrue(registry.hasInterceptors());
View Full Code Here

        submitCalled = false;

        Submit submit = new Submit("save");
        // Register an ajax behavior
        submit.addBehavior(new DefaultAjaxBehavior() {

            @Override
            public ActionResult onAction(Control source) {
                // When action is invoked, set flag to true
                submitCalled = true;
View Full Code Here

        MockRequest request = context.getMockRequest();
        request.setParameter("save", "save");

        Submit submit = new Submit("save");
        // Register an ajax behavior
        submit.addBehavior(new DefaultAjaxBehavior() {

            @Override
            public ActionResult onAction(Control source) {
                // When action is invoked, set flag to true
                return new ActionResult();
View Full Code Here

        submitCalled = false;
        preRenderHeadElementsCalled = false;
        preResponseCalled = false;
        preDestroyCalled = false;

        submit.addBehavior(new DefaultAjaxBehavior() {

            @Override
            public ActionResult onAction(Control source) {
                // When action is invoked, set flag to true
                submitCalled = true;
View Full Code Here

        link.setId("link-id");

        addControl(link);

        // If JavaScript is enabled, the AjaxBehavior will be called
        link.addBehavior(new DefaultAjaxBehavior() {

            @Override
            public ActionResult onAction(Control source) {
                // Formatted date instance that will be added to the
                String now = format.currentDate("MMM, yyyy dd HH:MM:ss");
View Full Code Here

TOP

Related Classes of org.apache.click.ajax.DefaultAjaxBehavior

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.