Example usage for org.apache.wicket Component getOutputMarkupId

List of usage examples for org.apache.wicket Component getOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket Component getOutputMarkupId.

Prototype

public final boolean getOutputMarkupId() 

Source Link

Document

Gets whether or not component will output id attribute into the markup.

Usage

From source file:com.axway.ats.testexplorer.TestExplorerApplication.java

License:Apache License

@Override
protected void init() {

    Locale.setDefault(Locale.US);

    getApplicationSettings().setPageExpiredErrorPage(PageExpiredErrorPage.class);
    getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
    // show internal error page rather than default developer page
    //TODO: use this line in PRODUCTION mode, by default in development mode is used ExceptionSettings.SHOW_EXCEPTION_PAGE
    //        getExceptionSettings().setUnexpectedExceptionDisplay( ExceptionSettings.SHOW_INTERNAL_ERROR_PAGE );

    mountPage("/runs", RunsPage.class);
    mountPage("/suites", SuitesPage.class);
    mountPage("/scenarios", ScenariosPage.class);
    mountPage("/testcases", TestcasesPage.class);
    mountPage("/testcase", TestcasePage.class);

    mountPage("/charts", ChartsBasePage.class);

    mountPage("/compare", ComparePage.class);
    mountPage("/compareStatistics", CompareTestcaseSystemStatisticsPage.class);

    mountPage("/runMessages", RunMessagePage.class);
    mountPage("/suiteMessages", SuiteMessagePage.class);

    mountPage("/machines", MachinesPage.class);
    mountPage("/runCopy", RunCopyPage.class);
    mountPage("/testcasesCopy", TestcasesCopyPage.class);

    mountPage("/reportSelect", SelectTestcaseReportPage.class);

    mountPage("/pageExpired", PageExpiredErrorPage.class);
    mountPage("/error", InternalErrorPage.class);

    mountPage("/dashboardhome", RunsByTypeDashboardHomePage.class);
    mountPage("/dashboardrun", RunsByTypeDashboardRunPage.class);
    mountPage("/dashboardsuite", RunsByTypeDashboardSuitePage.class);

    mountPage("/groups", TestcasesByGroupsPage.class);

    try {//  w  w w.  j av a2s . c o  m
        configProperties = new Properties();
        configProperties.load(this.getClass().getClassLoader().getResourceAsStream("ats.config.properties"));
    } catch (IOException e) {
        LOG.error("Can't load config.properties file", e);
    }

    getAjaxRequestTargetListeners().add(new AjaxRequestTarget.IListener() {

        @Override
        public void onBeforeRespond(Map<String, Component> map, final AjaxRequestTarget target) {

            // if( !Session.get().getFeedbackMessages().isEmpty() ) {

            target.getPage().visitChildren(IFeedback.class, new IVisitor<Component, Void>() {
                public void component(final Component component, final IVisit<Void> visit) {

                    if (component.getOutputMarkupId()) {
                        target.appendJavaScript(
                                "$('#" + component.getMarkupId() + "').effect('bounce', { times:5 }, 200);");
                        target.add(component);
                        //visit.stop();
                    }
                    visit.dontGoDeeper();
                }
            });
        }

        @Override
        public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) {

            // Do nothing.
        }

        @Override
        public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior,
                AjaxRequestAttributes attributes) {

            // TODO Auto-generated method stub

        }
    });

    // load any available Test Explorer plugins
    TestExplorerPluginsRepo.getInstance();
}

From source file:com.conwax.ajax.SimpleAjaxRequestTarget.java

License:Apache License

public void setComponent(Component component) {
    Args.notNull(component, "component");

    if (component.getOutputMarkupId() == false && !(component instanceof Page)) {
        throw new IllegalArgumentException(
                "cannot update component that does not have setOutputMarkupId property set to true. Component: "
                        + component.toString());
    }//from   w w  w  . j av a 2  s . c  o  m
    this.component = component;
}

From source file:com.doculibre.constellio.wicket.components.visitors.FindOutputIdTrueVisitor.java

License:Open Source License

@Override
public Object component(Component component) {
    Object result;/*from  w w  w. j av  a 2  s  .c  o m*/
    if (component.getOutputMarkupId()) {
        result = component;
    } else {
        result = CONTINUE_TRAVERSAL;
    }
    return result;
}

From source file:com.doculibre.constellio.wicket.utils.WicketResourceUtils.java

License:Open Source License

public static Component findOutputMarkupIdParent(Component child) {
    Component matchingParent;//from ww  w  . j  a  v a 2s.  co  m
    Component firstParent = child.getParent();
    if (firstParent != null) {
        if (firstParent.getOutputMarkupId()) {
            matchingParent = firstParent;
        } else {
            // Starts with current object despite what method name lets you think...
            matchingParent = (Component) firstParent.visitParents(Component.class, new IVisitor() {
                @Override
                public Object component(Component component) {
                    if (component.getOutputMarkupId()) {
                        return component;
                    } else {
                        return CONTINUE_TRAVERSAL;
                    }
                }
            });
        }
    } else {
        matchingParent = null;
    }
    return matchingParent;
}

From source file:com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn.java

License:Apache License

public static CheckBoxPanel findCheckBoxColumnHeader(DataTable table) {
    WebMarkupContainer topToolbars = table.getTopToolbars();
    ComponentHierarchyIterator iterator = topToolbars.visitChildren(TableHeadersToolbar.class);
    if (!iterator.hasNext()) {
        return null;
    }//from  ww  w  . ja  v  a2 s . co  m

    TableHeadersToolbar toolbar = (TableHeadersToolbar) iterator.next();
    // simple attempt to find checkbox which is header for our column
    // todo: this search will fail if there are more checkbox header columns (which is not supported now,
    // because Selectable.F_SELECTED is hardcoded all over the place...
    iterator = toolbar.visitChildren(CheckBoxPanel.class);
    while (iterator.hasNext()) {
        Component c = iterator.next();
        if (!c.getOutputMarkupId()) {
            continue;
        }

        return (CheckBoxPanel) c;
    }

    return null;
}

From source file:com.wiquery.plugins.jqgrid.component.XMLDataRequestTarget.java

License:Apache License

/**
 * Adds a component to the list of components to be rendered
 * /*from   w  w  w  . ja v a 2s.c om*/
 * @param component
 *            component to be rendered
 */
public void addComponent(Component component) {
    if (component == null) {
        throw new IllegalArgumentException("component cannot be null");
    }
    if (component.getOutputMarkupId() == false) {
        throw new IllegalArgumentException(
                "cannot update component that does not have setOutputMarkupId property set to true. Component: "
                        + component.toString());
    }
    addComponent(component, component.getMarkupId());
}

From source file:com.wiquery.plugins.jqgrid.component.XMLDataRequestTarget.java

License:Apache License

/**
 * Sets the focus in the browser to the given component. The markup id must be set. If the
 * component is null the focus will not be set to any component.
 * //from   www  .  j a v  a 2 s .c  om
 * @param component
 *            The component to get the focus or null.
 */
public final void focusComponent(Component component) {
    if (component != null && component.getOutputMarkupId() == false) {
        throw new IllegalArgumentException(
                "cannot update component that does not have setOutputMarkupId property set to true. Component: "
                        + component.toString());
    }
    final String id = component != null ? ("'" + component.getMarkupId() + "'") : "null";
    appendJavascript("Wicket.Focus.setFocusOnId(" + id + ");");
}

From source file:net.dontdrinkandroot.wicket.bootstrap.component.button.ButtonLink.java

License:Apache License

/**
 * Appends any anchor to the url if the url is not null and the url does not already contain an
 * anchor (url.indexOf('#') != -1). This implementation looks whether an anchor component was
 * set, and if so, it will append the markup id of that component. That markup id is gotten by
 * either calling {@link Component#getMarkupId()} if {@link Component#getOutputMarkupId()}
 * returns true, or if the anchor component does not output it's id, this method will try to
 * retrieve the id from the markup directly. If neither is found, an
 * {@link WicketRuntimeException exception} is thrown. If no anchor component was set, but the
 * link component is attached to a &lt;a element, this method will append what is in the href
 * attribute <i>if</i> there is one, starts with a '#' and has more than one character.
 * <p>//from  ww  w.j a  va  2s .c  om
 * You can override this method, but it means that you have to take care of whatever is done
 * with any set anchor component yourself. You also have to manually append the '#' at the right
 * place.
 * </p>
 * 
 * @param tag
 *            The component tag
 * @param url
 *            The url to start with
 * @return The url, possibly with an anchor appended
 */
protected CharSequence appendAnchor(final ComponentTag tag, CharSequence url) {

    if (url != null) {
        Component anchor = this.getAnchor();
        if (anchor != null) {
            if (url.toString().indexOf('#') == -1) {
                String id;
                if (anchor.getOutputMarkupId()) {
                    id = anchor.getMarkupId();
                } else {
                    id = anchor.getMarkupAttributes().getString("id");
                }

                if (id != null) {
                    url = url + "#" + anchor.getMarkupId();
                } else {
                    throw new WicketRuntimeException("an achor component was set on " + this
                            + " but it neither has outputMarkupId set to true "
                            + "nor has a id set explicitly");
                }
            }
        } else {
            if (tag.getName().equalsIgnoreCase("a")) {
                if (url.toString().indexOf('#') == -1) {
                    String href = tag.getAttributes().getString("href");
                    if (href != null && href.length() > 1 && href.charAt(0) == '#') {
                        url = url + href;
                    }
                }
            }
        }
    }
    return url;
}

From source file:org.apache.isis.viewer.wicket.ui.panels.FormExecutorDefault.java

License:Apache License

private void addComponentsToRedraw(final AjaxRequestTarget target) {
    final List<Component> componentsToRedraw = Lists.newArrayList();
    final List<Component> componentsNotToRedraw = Lists.newArrayList();

    final Page page = target.getPage();
    page.visitChildren(new IVisitor<Component, Object>() {
        @Override/*from w  w  w. j a  v  a 2  s .com*/
        public void component(final Component component, final IVisit<Object> visit) {
            if (component.getOutputMarkupId() && !(component instanceof Page)) {
                List<Component> listToAddTo = shouldRedraw(component) ? componentsToRedraw
                        : componentsNotToRedraw;
                listToAddTo.add(component);
            }
        }

        private boolean shouldRedraw(final Component component) {

            // hmm... this doesn't work, because I think that the components
            // get removed after they've been added to target.
            // so.. still getting WARN log messages from XmlPartialPageUpdate

            //                final Page page = component.findParent(Page.class);
            //                if(page == null) {
            //                    // as per logic in XmlPartialPageUpdate, this has already been
            //                    // removed from page so don't attempt to redraw it
            //                    return false;
            //                }

            final Object defaultModel = component.getDefaultModel();
            if (!(defaultModel instanceof ScalarModel)) {
                return true;
            }
            final ScalarModel scalarModel = (ScalarModel) defaultModel;
            final UnchangingFacet unchangingFacet = scalarModel.getFacet(UnchangingFacet.class);
            return unchangingFacet == null || !unchangingFacet.value();
        }
    });

    for (Component componentNotToRedraw : componentsNotToRedraw) {
        MarkupContainer parent = componentNotToRedraw.getParent();
        while (parent != null) {
            parent = parent.getParent();
        }

        componentNotToRedraw.visitParents(MarkupContainer.class, new IVisitor<MarkupContainer, Object>() {
            @Override
            public void component(final MarkupContainer parent, final IVisit<Object> visit) {
                componentsToRedraw.remove(parent); // no-op if not in that list
            }
        });
        if (componentNotToRedraw instanceof MarkupContainer) {
            final MarkupContainer containerNotToRedraw = (MarkupContainer) componentNotToRedraw;
            containerNotToRedraw.visitChildren(new IVisitor<Component, Object>() {
                @Override
                public void component(final Component parent, final IVisit<Object> visit) {
                    componentsToRedraw.remove(parent); // no-op if not in that list
                }
            });
        }
    }

    if (LOG.isDebugEnabled()) {
        debug(componentsToRedraw, componentsNotToRedraw);
    }

    for (Component component : componentsToRedraw) {
        target.add(component);
    }
}

From source file:org.artifactory.common.wicket.util.AjaxUtils.java

License:Open Source License

public static void refreshFeedback(final AjaxRequestTarget target) {
    Page page = WicketUtils.getPage();//from  ww  w . j a v  a 2 s .  c  o m
    if (page == null || target == null) {
        return;
    }
    page.visitChildren(IFeedback.class, new IVisitor<Component, Void>() {
        @Override
        public void component(Component component, IVisit<Void> visit) {
            if (component.getOutputMarkupId()) {
                target.add(component);
            }
        }
    });
}