Example usage for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior

List of usage examples for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior

Introduction

In this page you can find the example usage for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior.

Prototype

public AjaxEventBehavior(String event) 

Source Link

Document

Construct.

Usage

From source file:at.molindo.wicketutils.utils.MockRenderCallbackTest.java

License:Apache License

@Test(expected = WicketRuntimeException.class)
public void renderStateful() {
    DummyApplication testApp = new DummyApplication();
    try {//from  w ww  . j  a  va2  s .c  om
        testApp.getMarkupSettings().setStripWicketTags(true);
        testApp.getMarkupSettings().setStripComments(true);

        // throw WicketRuntimeException
        MockUtils.withNewRequest(testApp, new MockRenderCallback() {

            @Override
            public void configure(MockRequest request) {
            }

            @Override
            protected Component newComponent(String id) {
                return new Label(id, "Hello World").add(new AjaxEventBehavior("on click") {
                    private static final long serialVersionUID = 1L;

                    @Override
                    protected void onEvent(AjaxRequestTarget target) {
                    }
                });
            }

        });
    } finally {
        testApp.destroy();
    }
}

From source file:com.axway.ats.testexplorer.pages.model.ColumnsDialog.java

License:Apache License

@SuppressWarnings({ "rawtypes" })
public ColumnsDialog(String id, final DataGrid grid, List<TableColumn> columnDefinitions) {

    super(id);/*  w ww .  j  av  a 2s  . com*/
    setOutputMarkupId(true);

    this.dbColumnDefinitions = columnDefinitions;

    DataView<TableColumn> table = new DataView<TableColumn>("headers",
            new ListDataProvider<TableColumn>(dbColumnDefinitions), 100) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<TableColumn> item) {

            final TableColumn column = item.getModelObject();

            item.add(new CheckBox("visible", new PropertyModel<Boolean>(column, "visible")));
            item.add(new Label("columnName", new PropertyModel<String>(column, "columnName")));

            item.add(new AjaxEventBehavior("click") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {

                    TableColumn tableColumn = (TableColumn) this.getComponent().getDefaultModelObject();
                    tableColumn.setVisible(!tableColumn.isVisible());

                    if (tableColumn.isVisible()) {
                        item.add(AttributeModifier.replace("class", "selected"));
                    } else {
                        item.add(AttributeModifier.replace("class", "notSelected"));
                    }
                    grid.getColumnState().setColumnVisibility(tableColumn.getColumnId(),
                            tableColumn.isVisible());
                    target.add(grid);
                    target.add(this.getComponent());

                    open(target);
                }
            });
            item.setOutputMarkupId(true);

            if (column.isVisible()) {
                item.add(AttributeModifier.replace("class", "selected"));
            } else {
                item.add(AttributeModifier.replace("class", "notSelected"));
            }
        }
    };
    add(table);

    final Form<Void> columnDefinitionsForm = new Form<Void>("columnDefinitionsForm");
    add(columnDefinitionsForm);

    AjaxSubmitLink saveButton = new AjaxSubmitLink("saveButton", columnDefinitionsForm) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {

            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener();
            ajaxCallListener.onPrecondition("getTableColumnDefinitions(); ");
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            String columnDefinitionsString = form.getRequest().getPostParameters()
                    .getParameterValue("columnDefinitions").toString();

            List<TableColumn> jsColDefinitions = asList(columnDefinitionsString);
            orderTableColumns(dbColumnDefinitions, jsColDefinitions);

            try {
                saveColumnDefinitionsToDb(jsColDefinitions);

                modifyDBColumnDefinitionList(jsColDefinitions);

            } catch (DatabaseAccessException dae) {
                throw new RuntimeException("Unable to save table Column definitions in db: "
                        + ((TestExplorerSession) Session.get()).getDbName(), dae);
            } catch (SQLException sqle) {
                throw new RuntimeException("Unable to save table Column definitions in db: "
                        + ((TestExplorerSession) Session.get()).getDbName(), sqle);
            }

            close(target);
        }
    };
    add(AttributeModifier.append("class", "runsTableColDialogDivWrapper"));
    columnDefinitionsForm.add(saveButton);

    add(new Behavior() {

        private static final long serialVersionUID = 1L;

        @Override
        public void renderHead(Component component, IHeaderResponse response) {

            if (autoAddToHeader()) {

                String script = "jQuery.fn.center=function(){" + "this.css(\"position\",\"absolute\");"
                        + "this.css(\"top\",(jQuery(window).height()-this.height())/2+jQuery(window).scrollTop()+\"px\");"
                        + "this.css(\"left\",(jQuery(window).width()-this.width())/2+jQuery(window).scrollLeft()+\"px\");"
                        + "return this};";

                String css = "#settingsoverlay,.settingsoverlay,#settingsoverlay_high,"
                        + ".settingsoverlay_high{filter:Alpha(Opacity=40);"
                        + "-moz-opacity:.4;opacity:.4;background-color:#444;display:none;position:absolute;"
                        + "left:0;top:0;width:100%;height:100%;text-align:center;z-index:5000;}"
                        + "#settingsoverlay_high,.settingsoverlay_high{z-index:6000;}"
                        + "#settingsoverlaycontent,#settingsoverlaycontent_high{display:none;z-index:5500;"
                        + "text-align:center;}.settingsoverlaycontent,"
                        + ".settingsoverlaycontent_high{display:none;z-index:5500;text-align:left;}"
                        + "#settingsoverlaycontent_high,.settingsoverlaycontent_high{z-index:6500;}"
                        + "#settingsoverlaycontent .modalborder,"
                        + "#settingsoverlaycontent_high .modalborder{padding:15px;width:300px;"
                        + "border:1px solid #444;background-color:white;"
                        + "-webkit-box-shadow:0 0 10px rgba(0,0,0,0.8);-moz-box-shadow:0 0 10px rgba(0,0,0,0.8);"
                        + "box-shadow:0 0 10px rgba(0,0,0,0.8);"
                        + "filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray');"
                        + "-ms-filter:\"progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray')\";}";

                response.render(JavaScriptHeaderItem.forScript(script, null));
                response.render(CssHeaderItem.forCSS(css, null));
                if (isSupportIE6()) {
                    response.render(JavaScriptHeaderItem
                            .forReference(new PackageResourceReference(getClass(), "jquery.bgiframe.js")));
                }
            }

            response.render(OnDomReadyHeaderItem.forScript(getJS()));
        }

        private String getJS() {

            StringBuilder sb = new StringBuilder();
            sb.append("if (jQuery('#").append(getDivId())
                    .append("').length == 0) { jQuery(document.body).append('")
                    .append(getDiv().replace("'", "\\'")).append("'); }");
            return sb.toString();
        }

        private String getDivId() {

            return getMarkupId() + "_ovl";
        }

        private String getDiv() {

            if (isClickBkgToClose()) {
                return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\" onclick=\""
                        + getCloseString() + "\"></div>");
            } else {
                return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\"></div>");
            }
        }
    });

}

From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java

License:Apache License

private void addComponents() {

    // Select the first message for initial display
    if (getConfig().messages.isEmpty()) {
        // No messages configured. Create a new message with id=1.
        getConfig().addMessageConfig(new MessageConfig(1));
    }//from   w  w  w.j  a  va  2 s  .  c  om

    currentMessage = getConfig().getMessageList().get(0);
    currentMessage.calcOffsets(getConfig().getMessageIdType().getByteSize());
    currentMessageId = currentMessage.getMessageId();

    // *******************************************************************************************
    // *** Form for XML import
    final FileUploadField uploadField = new FileUploadField("upload-field", new ListModel<FileUpload>());

    Form<?> uploadForm = new Form<Object>("upload-form") {
        @Override
        protected void onSubmit() {
            try {
                FileUpload upload = uploadField.getFileUpload();
                if (upload != null) {
                    handleOnUpload(upload.getInputStream());
                } else {
                    warn(new StringResourceModel("warn.noFileToUpload", this, null).getString());
                }
            } catch (Exception e) {
                this.error(new StringResourceModel("import.error", this, null).getString() + " Exception: "
                        + e.toString());
            }
        }
    };
    uploadForm.add(uploadField);

    SubmitLink importLink = new SubmitLink("import-link");
    uploadForm.add(importLink);

    add(uploadForm);

    // *******************************************************************************************
    // *** The message configuration
    currentMessageModel = new PropertyModel<MessageConfig>(this, "currentMessage");
    editForm = new Form<MessageConfig>("edit-form",
            new CompoundPropertyModel<MessageConfig>(currentMessageModel)) {
        @Override
        protected void onError() {
            // Validation error - reset the message dropdown to the original value
            // Clear input causes the component to reload the model
            currentMessageIdDropdown.clearInput();
            super.onError();
        }
    };

    editForm.add(new MessageFormValidator());

    WebMarkupContainer tableContainer = new WebMarkupContainer("table-container");

    messageIdTypeDropDown = getMessageIdTypeDropdown();
    tableContainer.add(messageIdTypeDropDown);

    currentMessageIdDropdown = getCurrentMessageIdDropdown();

    tableContainer.add(currentMessageIdDropdown);
    Button buttonNew = new Button("new");
    buttonNew.add(new AjaxFormSubmitBehavior("onclick") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            handleNew(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            handleError(target);
        }
    });
    tableContainer.add(buttonNew);

    Button buttonCopy = new Button("copy");
    buttonCopy.add(new AjaxFormSubmitBehavior("onclick") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            handleCopy(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            handleError(target);
        }
    });
    tableContainer.add(buttonCopy);

    Button deleteButton = new Button("delete");
    deleteButton.add(new AjaxEventBehavior("onclick") {
        @Override
        protected void onEvent(AjaxRequestTarget target) {
            handleDelete(target);
        }
    });
    tableContainer.add(deleteButton);

    messageTypeDropdown = getMessageTypeDropdown();
    tableContainer.add(messageTypeDropdown);

    tableContainer.add(getQueueModeDropdown());

    tableContainer.add(new CheckBox("usePersistance").setOutputMarkupId(true));

    WebMarkupContainer listEditorContainer = new WebMarkupContainer("list-editor");

    messageIdTextField = getMessageIdTextField();
    listEditorContainer.add(messageIdTextField);

    messageAliasTextField = getMessageAliasTextField();
    listEditorContainer.add(messageAliasTextField);

    // Create the list editor
    editor = new ListEditor<TagConfig>("tags",
            new PropertyModel<List<TagConfig>>(currentMessageModel, "tags")) {
        @Override
        protected void onPopulateItem(EditorListItem<TagConfig> item) {

            item.setModel(new CompoundPropertyModel<TagConfig>(item.getModelObject()));

            BinaryDataType dataType = item.getModelObject().getDataType();
            boolean enable = dataType.isSpecial() ? false : true;

            // Offset is displayed only for information
            item.add(new Label("offset").setOutputMarkupId(true));

            if (enable) {
                item.add(getIdTextField());
            } else {
                // The static TextField has no validation. Validation would fail for special tags.
                item.add(getSpecialIdTextField().setEnabled(false));
            }

            item.add(getAliasTextField().setVisible(enable));

            item.add(getSizeTextField().setEnabled(dataType.isArrayAllowed()));

            item.add(getTagLengthTypeDropDown().setEnabled(dataType.supportsVariableLength()));

            item.add(getDataTypeDropdown());

            // Create the edit links to be used in the list editor
            item.add(getInsertLink());
            item.add(getDeleteLink());
            item.add(getMoveUpLink().setVisible(item.getIndex() > 0));
            item.add(getMoveDownLink().setVisible(item.getIndex() < getList().size() - 1));
        }
    };
    listEditorContainer.add(editor);

    Label noItemsLabel = new Label("no-items-label", new StringResourceModel("noitems", this, null)) {
        @Override
        public boolean isVisible() {
            return editor.getList().size() == 0;
        }
    };

    listEditorContainer.add(noItemsLabel);

    listEditorContainer.add(new EditorSubmitLink("add-row-link") {
        @Override
        public void onSubmit() {
            editor.addItem(new TagConfig());

            // Adjust the visibility of the edit links
            updateListEditor(editor);
        }
    });

    listEditorContainer.setOutputMarkupId(true);

    tableContainer.add(listEditorContainer);
    editForm.add(tableContainer);

    // XML export
    SubmitLink exportLink = new SubmitLink("export-link", editForm) {
        @Override
        public void onSubmit() {
            ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(getResourceStream(),
                    getFileName());
            handler.setContentDisposition(ContentDisposition.ATTACHMENT);
            handler.setCacheDuration(Duration.NONE);
            getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
        }

        private String getFileName() {
            return String.format("MsgConfig_%s.xml", currentMessageModel.getObject().getMessageId());
        }

        private IResourceStream getResourceStream() {
            String config = currentMessageModel.getObject().toXMLString();
            return new StringResourceStream(config, "text/xml");
        }
    };
    editForm.add(exportLink);

    uploadForm.add(editForm);
}

From source file:com.evolveum.midpoint.web.component.box.InfoBoxPanel.java

License:Apache License

private void initLayout(final IModel<InfoBoxType> model, final Class<? extends IRequestablePage> linkPage) {

    WebMarkupContainer infoBox = new WebMarkupContainer(ID_INFO_BOX);
    add(infoBox);/*from ww w .  j av a 2 s  . co m*/
    infoBox.add(AttributeModifier.append("class",
            new PropertyModel<String>(model, InfoBoxType.BOX_BACKGROUND_COLOR)));

    WebMarkupContainer infoBoxIcon = new WebMarkupContainer(ID_INFO_BOX_ICON);
    infoBox.add(infoBoxIcon);
    infoBoxIcon.add(AttributeModifier.append("class",
            new PropertyModel<String>(model, InfoBoxType.ICON_BACKGROUND_COLOR)));

    WebMarkupContainer image = new WebMarkupContainer(ID_IMAGE_ID);
    image.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.IMAGE_ID)));
    infoBoxIcon.add(image);

    Label message = new Label(ID_MESSAGE, new PropertyModel<String>(model, InfoBoxType.MESSAGE));
    infoBox.add(message);

    Label number = new Label(ID_NUMBER, new PropertyModel<String>(model, InfoBoxType.NUMBER));
    infoBox.add(number);

    WebMarkupContainer progress = new WebMarkupContainer(ID_PROGRESS);
    infoBox.add(progress);
    progress.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return model.getObject().getProgress() != null;
        }
    });
    ProgressbarPanel progressBar = new ProgressbarPanel(ID_PROGRESS_BAR,
            new PropertyModel<Integer>(model, InfoBoxType.PROGRESS));
    progress.add(progressBar);

    Label description = new Label(ID_DESCRIPTION, new PropertyModel<String>(model, InfoBoxType.DESCRIPTION));
    infoBox.add(description);

    if (linkPage != null) {
        add(new AjaxEventBehavior("click") {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onEvent(AjaxRequestTarget target) {
                setResponsePage(linkPage);
            }
        });
    }
}

From source file:com.evolveum.midpoint.web.component.option.OptionPanel.java

License:Apache License

public OptionPanel(String id, IModel<String> title, final Boolean hidden) {
    super(id);//ww  w .j av a  2s.  c  o  m
    this.hidden = hidden;
    WebMarkupContainer parent = new WebMarkupContainer("parent");
    parent.setOutputMarkupId(true);
    addToBorder(parent);
    parent.add(new Label("title", title));
    WebMarkupContainer bar = new WebMarkupContainer("bar");
    bar.setOutputMarkupId(true);
    bar.add(new AjaxEventBehavior("onClick") {

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            Page page = OptionPanel.this.getPage();
            setHidden(page, !getHiddenFromSession());
        }
    });
    addToBorder(bar);
}

From source file:com.evolveum.midpoint.web.component.prism.PrismObjectPanel.java

License:Apache License

private AjaxEventBehavior createHeaderOnClickBehaviour(final IModel<ObjectWrapper> model) {
    return new AjaxEventBehavior("onClick") {

        @Override//w w  w.ja  va 2s . c  om
        protected void onEvent(AjaxRequestTarget target) {
            headerOnClickPerformed(target, model);
        }
    };
}

From source file:com.evolveum.midpoint.web.component.prism.show.ScenePanel.java

License:Apache License

private AjaxEventBehavior createHeaderOnClickBehaviour(final IModel<SceneDto> model) {
    return new AjaxEventBehavior("click") {
        @Override/*  www . jav  a 2 s. c o  m*/
        protected void onEvent(AjaxRequestTarget target) {
            headerOnClickPerformed(target, model);
        }
    };
}

From source file:com.evolveum.midpoint.web.page.admin.reports.PageAuditLogDetails.java

License:Apache License

private void initAuditLogHistoryPanel(WebMarkupContainer eventPanel) {
    AuditEventRecordProvider provider = new AuditEventRecordProvider(PageAuditLogDetails.this, null,
            this::getAuditEventRecordProviderParameters);

    BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_HISTORY_PANEL,
            provider, initColumns(), UserProfileStorage.TableId.TASK_EVENTS_TABLE, TASK_EVENTS_TABLE_SIZE) {

        @Override//from  w w  w.  j av  a  2s .  c  o m
        protected Item<AuditEventRecordType> customizeNewRowItem(final Item<AuditEventRecordType> item,
                final IModel<AuditEventRecordType> rowModel) {

            if (rowModel.getObject().getTimestamp().equals(recordModel.getObject().getTimestamp())) {
                item.add(new AttributeAppender("style",
                        "background-color: #eee; border-color: #d6d6d6; color: #000"));
            }

            item.add(new AjaxEventBehavior("click") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    PageAuditLogDetails.this.rowItemClickPerformed(target, item, rowModel);
                }
            });
            return item;
        }
    };
    table.getFooterMenu().setVisible(false);
    table.getFooterCountLabel().setVisible(false);
    //TODO hidden temporarily
    table.setVisible(false);
    table.setOutputMarkupId(true);
    table.setAdditionalBoxCssClasses("without-box-header-top-border");
    eventPanel.addOrReplace(table);

}

From source file:com.evolveum.midpoint.web.page.self.component.ChangePasswordPanel.java

License:Apache License

private List<IColumn<PasswordAccountDto, String>> initColumns() {
    List<IColumn<PasswordAccountDto, String>> columns = new ArrayList<IColumn<PasswordAccountDto, String>>();

    IColumn column = new IconColumn<PasswordAccountDto>(new Model<String>()) {
        private static final long serialVersionUID = 1L;

        @Override/* w  w  w . j  ava 2s .  com*/
        protected IModel<String> createIconModel(final IModel<PasswordAccountDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    PasswordAccountDto item = rowModel.getObject();
                    if (item.getCssClass() == null || item.getCssClass().trim().equals("")) {
                        if (item.isMidpoint()) {
                            item.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        } else if (item.isPasswordOutbound()) {
                            item.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                        } else {
                            item.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        }
                    }
                    return item.getCssClass();
                }
            };
        }

        @Override
        public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId,
                final IModel<PasswordAccountDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            final ImagePanel imagePanel = (ImagePanel) item.get(0);

            final PasswordAccountDto passwordAccountDto = rowModel.getObject();

            imagePanel.add(new AjaxEventBehavior("click") {
                private static final long serialVersionUID = 1L;

                protected void onEvent(final AjaxRequestTarget target) {
                    if (!passwordAccountDto.isMidpoint()) {
                        if (passwordAccountDto.getCssClass().equals(PROPAGATED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)
                                && passwordAccountDto.isPasswordOutbound() && midpointAccountSelected) {
                            passwordAccountDto.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        }
                        target.add(imagePanel);
                    } else {
                        midpointAccountSelected = !midpointAccountSelected;
                        if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                            updatePropagatedAccountIconsCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                            target.add(imagePanel.findParent(SelectableDataTable.class));
                        } else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                            updatePropagatedAccountIconsCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                            target.add(imagePanel.findParent(SelectableDataTable.class));
                        }
                    }
                }
            });
        }
    };
    columns.add(column);

    columns.add(
            new AbstractColumn<PasswordAccountDto, String>(createStringResource("ChangePasswordPanel.name")) {
                private static final long serialVersionUID = 1L;

                @Override
                public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId,
                        final IModel<PasswordAccountDto> rowModel) {
                    item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public Object getObject() {
                            PasswordAccountDto dto = rowModel.getObject();
                            return dto.getDisplayName();
                        }
                    }));
                }
            });

    column = new PropertyColumn(createStringResource("ChangePasswordPanel.resourceName"),
            PasswordAccountDto.F_RESOURCE_NAME);
    columns.add(column);

    CheckBoxColumn enabled = new CheckBoxColumn(createStringResource("ChangePasswordPanel.enabled"),
            PasswordAccountDto.F_ENABLED);
    enabled.setEnabled(false);
    columns.add(enabled);

    return columns;
}

From source file:com.mycompany.RunAwayTextPage.java

License:Apache License

private AjaxEventBehavior getEventBehavior(final Component updateComponent) {
    return new AjaxEventBehavior("onMouseOver") {
        @Override//from  w  w w  .  j  av a2s.  com
        protected void onEvent(AjaxRequestTarget target) {
            this.getComponent().setDefaultModel(new Model<String>(""));
            this.getComponent().remove(this);
            String nextId = getNextId(this.getComponent().getId());
            Component nextComponent = RunAwayTextPage.this.get("updateComponent").get(nextId);
            nextComponent.add(getEventBehavior(updateComponent));
            nextComponent.setDefaultModel(new Model<String>("?"));
            target.add(updateComponent);
        }
    };
}