Example usage for org.apache.wicket.markup.html.link AbstractLink AbstractLink

List of usage examples for org.apache.wicket.markup.html.link AbstractLink AbstractLink

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.link AbstractLink AbstractLink.

Prototype

public AbstractLink(String id) 

Source Link

Document

Construct.

Usage

From source file:fr.openwide.maven.artifact.notifier.web.application.project.form.ProjectFormPopupPanel.java

@Override
protected Component createFooter(String wicketId) {
    DelegatedMarkupPanel footer = new DelegatedMarkupPanel(wicketId, ProjectFormPopupPanel.class);

    // Validate button
    AjaxButton validate = new AjaxButton("save", form) {
        private static final long serialVersionUID = 1L;

        @Override//w  ww.j a  v a  2s  .co m
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            Project project = ProjectFormPopupPanel.this.getModelObject();

            if (StringUtils.hasText(project.getName())) {
                try {
                    Project duplicate = projectService.getByUri(StringUtils.urlize(project.getName()));

                    if (isAddMode()) {
                        if (duplicate == null) {
                            projectService.create(project);
                            getSession().success(getString("project.add.success"));
                            closePopup(target);
                            target.add(getPage());
                        } else {
                            LOGGER.warn("A project with the same name already exists");
                            getSession().error(getString("project.add.notUnique"));
                        }
                    } else {
                        if (duplicate == null || project.equals(duplicate)) {
                            projectService.update(project);
                            getSession().success(getString("project.edit.success"));
                            closePopup(target);
                            throw LinkFactory.get()
                                    .getAssortedProjectPageLinkDescriptor(getPage().getPageClass(),
                                            ProjectFormPopupPanel.this.getModel())
                                    .newRestartResponseException();
                        } else {
                            LOGGER.warn("A project with the same name already exists");
                            getSession().error(getString("project.add.notUnique"));
                        }
                    }
                } catch (RestartResponseException e) {
                    throw e;
                } catch (Exception e) {
                    if (isAddMode()) {
                        LOGGER.error("Error occured while adding the project", e);
                        getSession().error(getString("project.add.error"));
                    } else {
                        LOGGER.error("Error occured while updating the project", e);
                        getSession().error(getString("project.edit.error"));
                    }
                }
            }
            FeedbackUtils.refreshFeedback(target, getPage());
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            FeedbackUtils.refreshFeedback(target, getPage());
        }
    };
    validate.add(new Label("validateLabel", new ResourceModel("common.action.save")));
    footer.add(validate);

    // Cancel button
    AbstractLink cancel = new AbstractLink("cancel") {
        private static final long serialVersionUID = 1L;
    };
    addCancelBehavior(cancel);
    footer.add(cancel);

    return footer;
}

From source file:org.projectforge.web.wicket.components.ContentMenuEntryPanel.java

License:Open Source License

/**
 * @see org.apache.wicket.Component#onInitialize()
 *//*from  w  w  w. j av  a  2  s .  c o m*/
@SuppressWarnings("serial")
@Override
protected void onInitialize() {
    super.onInitialize();
    if (link == null) {
        this.link = new AbstractLink(LINK_ID) {
        };
    } else {
        this.hasLink = true;
    }
    li.add(link);
    link.add(labelComponent);
    caret = new WebMarkupContainer("caret");
    if (subMenu.hasEntries() == true) {
        // Children available.
        link.add(AttributeModifier.append("class", "dropdown-toggle"));
        link.add(AttributeModifier.append("data-toggle", "dropdown"));
        li.add(AttributeModifier.append("class", "dropdown"));
    } else {
        dropDownMenu.setVisible(false);
        caret.setVisible(false);
    }
    link.add(caret);
}

From source file:org.wicketstuff.jquery.tabs.JQTabbedPanel.java

License:Apache License

/**
 * Constructs a JQTabbedPanel with the given id, list of tabs and options.
 * <p>/*from  w  ww  .  j  ava 2  s  . c o  m*/
 * The options are used when initializing the tabs.
 * <p>
 * See <a href="http://stilbuero.de/jquery/tabs/">tabs documentation</a> for
 * details on the available options.
 * <p>
 * Some examples:<br/>
 * <code>{ fxSlide: true }</code><br/>
 * <code>{ fxFade: true, fxSpeed: 'fast' }</code><br/>
 * 
 * @param id
 *            the id of this component. Must not be null.
 * @param tabs
 *            the list of tabs to use in this component. Must not be null.
 * @param options
 *            the options to use to init the tabs component. May be null.
 */
public JQTabbedPanel(String id, List<ITab> tabs, String options) {
    super(id);
    this.options = options == null ? "" : options;

    add(new JQueryBehavior());
    final WebMarkupContainer parent = new WebMarkupContainer("tabs");
    parent.setOutputMarkupId(true);
    add(parent);

    /*
     * we inject the script in the component body and not as a header
     * contribution because the script needs to be called each time the
     * component is refreshed using wicket ajax support.
     */
    add(new Label("script", new Model<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return "$('#" + parent.getMarkupId() + "').tabs(" + getTabsOptions() + ");";
        }
    }).setEscapeModelStrings(false));

    RepeatingView titles = new RepeatingView("tab");
    parent.add(titles);
    RepeatingView contents = new RepeatingView("content");
    parent.add(contents);

    for (int i = 0; i < tabs.size(); i++) {
        final WebMarkupContainer content = tabs.get(i).getPanel(TAB_PANEL_ID + i);
        content.setOutputMarkupId(true);
        contents.add(content);
        WebMarkupContainer title = new WebMarkupContainer(TAB_PANEL_ID + "-title" + i);
        title.setOutputMarkupId(true);
        title.add(new AbstractLink("link") {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onComponentTag(ComponentTag tag) {
                super.onComponentTag(tag);
                tag.put("href", "#" + content.getMarkupId());
            }
        }.add(new Label("title", tabs.get(i).getTitle())));
        titles.add(title);
    }
}

From source file:org.xaloon.wicket.component.jquery.JQueryTabPanel.java

License:Apache License

public void init(List<? extends ITab> tabs, JQueryBehavior queryBehavior) {
    if (queryBehavior.isCreatedFromComponent()) {
        add(queryBehavior);/*from w  w  w . ja  v  a  2s.  co  m*/
    }
    final WebMarkupContainer container = new WebMarkupContainer("tabs");
    container.setOutputMarkupId(true);
    add(container);
    queryUITabBehaviorItem = new JQueryUITabBehaviorItem() {
        private static final long serialVersionUID = 1L;

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

        @Override
        public String getTheme() {
            return (theme != null) ? theme : super.getTheme();
        }
    };
    queryBehavior.addChild(queryUITabBehaviorItem);

    RepeatingView titles = new RepeatingView("tab");
    titleContainer = new WebMarkupContainer("tc");
    titleContainer.setOutputMarkupId(true);
    container.add(titleContainer);
    titleContainer.add(titles);

    contentContainer = new WebMarkupContainer("cc");
    contentContainer.setOutputMarkupId(true);
    container.add(contentContainer);

    RepeatingView contents = new RepeatingView("content");
    contentContainer.add(contents);

    for (int i = 0; i < tabs.size(); i++) {
        final Panel content = tabs.get(i).getPanel(TAB_ID + i);
        WebMarkupContainer title = new WebMarkupContainer(TAB_ID + TAB_TITLE_ID + i);
        title.setOutputMarkupId(true);
        titles.add(title);
        content.setOutputMarkupId(true);
        contents.add(content);

        if (content instanceof PageTabContainerPanel) {
            /**
             * generate <li><a href="url">title</a></li>
             * page will be loaded instead of panel
             */
            final PageTabContainerPanel panel = (PageTabContainerPanel) content;
            AbstractLink link = new AbstractLink("link") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("href", urlFor(panel.getPageClass(), panel.getParameters()));
                }
            };
            link.add(new Label("title", tabs.get(i).getTitle()));
            title.add(link);
        } else {
            /**
             * generate <li><a href="#markupId">title</a></li>
             * panel will be loaded
             */
            AbstractLink link = new AbstractLink("link") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("href", "#" + content.getMarkupId());
                }
            };
            link.add(new Label("title", tabs.get(i).getTitle()));
            title.add(link);
        }
    }
}