Example usage for org.apache.wicket Component setOutputMarkupId

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

Introduction

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

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

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

Usage

From source file:com.visural.wicket.behavior.beautytips.BeautyTipBehavior.java

License:Apache License

@Override
public void bind(Component component) {
    componentIds.add(component.getMarkupId());
    component.setOutputMarkupId(true);
}

From source file:com.visural.wicket.behavior.dateinput.DateInputBehavior.java

License:Apache License

@Override
public void bind(Component component) {
    setLocale(component.getLocale());
    bound.add(component);
    component.setOutputMarkupId(true);
}

From source file:com.visural.wicket.behavior.inputhint.InputHintBehavior.java

License:Apache License

@Override
public void bind(Component component) {
    bound.add(component);//from w ww. jav a 2 s . co  m
    component.setOutputMarkupId(true);
    form.add(new InputHintFormBehavior(component.getMarkupId()));
}

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

License:Apache License

/**
 * /*  www  .ja va 2  s  . c  o m*/
 * @param response
 * @param markupId
 *            id of client-side dom element
 * @param component
 *            component to render
 */
private void respondComponent(final Response response, final String markupId, final Component component,
        StringBuffer writer) {
    if (component.getRenderBodyOnly() == true) {
        throw new IllegalStateException(
                "Ajax render cannot be called on component that has setRenderBodyOnly enabled. Component: "
                        + component.toString());
    }

    component.setOutputMarkupId(true);

    // substitute our encoding response for the real one so we can capture
    // component's markup in a manner safe for transport inside CDATA block
    final Response originalResponse = response;
    encodingBodyResponse.reset();
    RequestCycle.get().setResponse(encodingBodyResponse);

    // Initialize temporary variables
    final Page page = component.findParent(Page.class);
    if (page == null) {
        // dont throw an exception but just ignore this component, somehow
        // it got
        // removed from the page.
        // throw new IllegalStateException(
        // "Ajax request attempted on a component that is not associated
        // with a Page");
        LOG.debug("component: " + component + " with markupid: " + markupId
                + " not rendered because it was already removed from page");
        return;
    }

    page.startComponentRender(component);

    try {
        component.prepareForRender();

        // render any associated headers of the component
        respondHeaderContribution(response, component, writer);
    } catch (RuntimeException e) {
        try {
            component.afterRender();
        } catch (RuntimeException e2) {
            // ignore this one could be a result off.
        }
        // Restore original response
        RequestCycle.get().setResponse(originalResponse);
        encodingBodyResponse.reset();
        throw e;
    }

    try {
        component.renderComponent();
    } catch (RuntimeException e) {
        RequestCycle.get().setResponse(originalResponse);
        encodingBodyResponse.reset();
        throw e;
    }

    page.endComponentRender(component);

    // Restore original response
    RequestCycle.get().setResponse(originalResponse);

    writer.append("<component id=\"");
    writer.append(markupId);
    writer.append("\" ");
    if (encodingBodyResponse.isContentsEncoded()) {
        writer.append(" encoding=\"");
        writer.append(getEncodingName());
        writer.append("\" ");
    }
    writer.append("><![CDATA[");
    writer.append(encodingBodyResponse.getContents());
    writer.append("]]></component>");

    encodingBodyResponse.reset();
}

From source file:de.alpharogroup.wicket.behaviors.FocusRequestBehavior.java

License:Apache License

/**
 * {@inheritDoc}// ww w . j  av  a  2  s .co m
 */
@Override
public void renderHead(final Component component, final IHeaderResponse response) {
    super.renderHead(component, response);
    component.setOutputMarkupId(true);
    response.render(OnLoadHeaderItem.forScript(newJavaScript(component)));
}

From source file:de.alpharogroup.wicket.behaviors.JqueryStatementsBehavior.java

License:Apache License

/**
 * Factory method to create the rendered statement.
 *
 * @param component//from  w w w  . j a v  a 2 s  .  co m
 *            the component
 * @return the char sequence
 */
public CharSequence newRenderedStatement(final Component component) {
    JsStatement statement;
    if (component != null) {
        component.setOutputMarkupId(true);
        statement = new JsStatement().$(component);
    } else {
        statement = new JsStatement();
    }

    for (final ChainableStatement defaultChainableStatement : chainableStatement) {
        statement.chain(defaultChainableStatement);
    }
    this.renderedStatement = statement.render();
    this.rendered = true;
    return this.renderedStatement;
}

From source file:de.alpharogroup.wicket.components.examples.fragment.replacewith.ReplaceWithPanel.java

License:Apache License

public ReplaceWithPanel(final String id, final IModel<PersonBean> model) {
    super(id, model);
    setDefaultModel(model);//  w w w  . j  av  a  2  s. co  m
    viewComponent = newViewPersonPanel(PLACEHOLDER_ID, model);
    editComponent = newEditPersonPanel(PLACEHOLDER_ID, model);
    final List<String> choices = new ArrayList<String>();
    choices.add("View person");
    choices.add("Edit person");
    final RadioChoice<String> radioChoice = ComponentFactory.newRadioChoice("radioChoice",
            new Model<String>(selectedPanel), choices);

    radioChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            Component newComponent = null;
            if ("View person".equals(radioChoice.getModelObject())) {
                newComponent = viewComponent;
            } else {
                newComponent = editComponent;
            }
            newComponent.setOutputMarkupId(true);
            placeholderComponent.replaceWith(newComponent);
            target.add(newComponent);
            placeholderComponent = newComponent;
        }
    });
    placeholderComponent = newViewPersonPanel(PLACEHOLDER_ID, model);
    placeholderComponent.setOutputMarkupId(true);
    final Form<String> form = new Form<String>("form");
    form.add(radioChoice);
    form.add(placeholderComponent);
    this.add(form);
}

From source file:de.inren.frontend.common.table.AjaxFallbackDefaultDataTableBuilder.java

License:Apache License

/**
 * /*from  w w  w  .j  av  a2  s .  c om*/
 * @param id
 * @return the table
 */
public Component build(String id) {
    if (Strings.isNullOrEmpty(id) || columns.isEmpty() || dataProvider == null) {
        throw new IllegalStateException(
                "Can't create Table, not all elements are available. id=" + id + ", " + toString());
    }
    Component table = new AjaxFallbackDefaultDataTable<T, String>(id, columns, dataProvider, numberOfRows);
    table.setOutputMarkupId(true);
    table.add(AttributeModifier.append("class", "table-bordered"));
    table.add(AttributeModifier.append("class", "table-hover"));
    table.add(AttributeModifier.append("class", "table-condensed"));
    table.add(AttributeModifier.append("class", "table-striped"));

    return table;
}

From source file:de.jetwick.ui.util.DefaultFocusBehaviour.java

License:Apache License

@Override
public void bind(Component component) {
    if (!(component instanceof FormComponent)) {
        throw new IllegalArgumentException("DefaultFocusBehavior: component must be instanceof FormComponent");
    }/*w  ww  .  ja  v  a2  s  .co m*/
    this.component = component;
    component.setOutputMarkupId(true);
}

From source file:dk.teachus.frontend.components.calendar.CalendarPanel.java

License:Apache License

public CalendarPanel(String id, IModel<DateMidnight> weekDateModel) {
    super(id, weekDateModel);

    /*/*  w w w  .j a v  a  2s . c om*/
     * Navigation
     */
    Link<DateMidnight> previousWeekLink = new Link<DateMidnight>("previousWeek", weekDateModel) { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setModelObject(getModelObject().minusWeeks(1));
        }
    };
    previousWeekLink.add(new Label("label", TeachUsSession.get().getString("CalendarPanelV2.previousWeek"))); //$NON-NLS-1$ //$NON-NLS-2$
    add(previousWeekLink);
    Link<DateMidnight> thisWeekLink = new Link<DateMidnight>("thisWeek", weekDateModel) { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setModelObject(new DateMidnight());
        }
    };
    thisWeekLink.add(new Label("label", TeachUsSession.get().getString("CalendarPanelV2.thisWeek"))); //$NON-NLS-1$ //$NON-NLS-2$
    add(thisWeekLink);
    Link<DateMidnight> nextWeekLink = new Link<DateMidnight>("nextWeek", weekDateModel) { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setModelObject(getModelObject().plusWeeks(1));
        }
    };
    nextWeekLink.add(new Label("label", TeachUsSession.get().getString("CalendarPanelV2.nextWeek"))); //$NON-NLS-1$ //$NON-NLS-2$
    add(nextWeekLink);

    /*
     * Calendar
     */
    IModel<List<DateMidnight>> daysModel = new LoadableDetachableModel<List<DateMidnight>>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<DateMidnight> load() {
            DateMidnight thisMonday = CalendarPanel.this.getModelObject()
                    .withDayOfWeek(DateTimeConstants.MONDAY);
            List<DateMidnight> days = new ArrayList<DateMidnight>();
            for (int i = 0; i < 7; i++) {
                days.add(thisMonday);
                thisMonday = thisMonday.plusDays(1);
            }
            return days;
        }
    };

    final IModel<List<LocalTime>> timesModel = new LoadableDetachableModel<List<LocalTime>>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<LocalTime> load() {
            int minutesDivider = 30;
            LocalTime localTime = getCalendarStartTime();
            final List<LocalTime> times = new ArrayList<LocalTime>();
            for (int i = 0; i < calculateNumberOfCalendarHours() * (60 / minutesDivider); i++) {
                times.add(localTime);
                localTime = localTime.plusMinutes(minutesDivider);
            }

            return times;
        }
    };

    // Headers
    add(new ListView<DateMidnight>("headers", daysModel) { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<DateMidnight> item) {
            item.add(new Label("label", new AbstractReadOnlyModel<String>() { //$NON-NLS-1$
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return HEADER_FORMAT.withLocale(TeachUsSession.get().getLocale())
                            .print(item.getModelObject());
                }
            }).setRenderBodyOnly(true));
        }
    });

    // Body
    // Times
    add(new ListView<LocalTime>("times", timesModel) { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<LocalTime> item) {
            Label label = new Label("label", new AbstractReadOnlyModel<String>() { //$NON-NLS-1$
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getModelObject().getMinuteOfHour() == 0) {
                        return TIME_FORMAT.withLocale(TeachUsSession.get().getLocale())
                                .print(item.getModelObject());
                    } else {
                        return null;
                    }
                }
            });
            item.add(label);

            IModel<String> appendModel = new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getModelObject().getMinuteOfHour() == 0) {
                        return "timehour"; //$NON-NLS-1$
                    } else {
                        return null;
                    }
                }
            };
            item.add(AttributeModifier.append("class", appendModel)); //$NON-NLS-1$
        }
    });

    // Days
    add(new ListView<DateMidnight>("days", daysModel) { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<DateMidnight> dayItem) {
            // Times
            dayItem.add(new ListView<LocalTime>("times", timesModel) { //$NON-NLS-1$
                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(final ListItem<LocalTime> item) {
                    IModel<String> appendModel = new AbstractReadOnlyModel<String>() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public String getObject() {
                            if (item.getModelObject().getMinuteOfHour() == 0) {
                                return "daytimehour"; //$NON-NLS-1$
                            } else {
                                return null;
                            }
                        }
                    };
                    item.add(AttributeModifier.append("class", appendModel)); //$NON-NLS-1$
                }
            });

            /*
             * Entries
             */
            dayItem.add(new ListView<TimeSlot<T>>("timeSlots", getTimeSlotModel(dayItem.getModelObject())) { //$NON-NLS-1$
                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(final ListItem<TimeSlot<T>> timeSlotItem) {
                    timeSlotItem.setOutputMarkupId(true);

                    final LocalTime startTime = timeSlotItem.getModelObject().getStartTime();
                    final LocalTime endTime = timeSlotItem.getModelObject().getEndTime();
                    int dividerPixelHeight = 25;
                    double minutesPerDivider = calculateNumberOfCalendarHours() * 60
                            / timesModel.getObject().size();

                    // Calculate top/y (start time)
                    double minutesStart = startTime.getHourOfDay() * 60 + startTime.getMinuteOfHour();
                    minutesStart -= getCalendarStartTime().getHourOfDay() * 60
                            + getCalendarStartTime().getMinuteOfHour();
                    double pixelStart = minutesStart / minutesPerDivider;
                    long top = Math.round(pixelStart * dividerPixelHeight) - 1;

                    // Calculate height (end time)
                    final double minutesEnd = (endTime.getHourOfDay() * 60 + endTime.getMinuteOfHour())
                            - minutesStart - getCalendarStartTime().getHourOfDay() * 60
                            + getCalendarStartTime().getMinuteOfHour();
                    double pixelEnd = minutesEnd / minutesPerDivider;
                    long height = Math.round(pixelEnd * dividerPixelHeight) - 1;

                    timeSlotItem.add(AttributeModifier.replace("style", //$NON-NLS-1$
                            "left: 0; top: " + top + "px; height: " + height + "px;")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

                    // Time slot content
                    IModel<List<String>> timeSlotContentModel = new LoadableDetachableModel<List<String>>() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected List<String> load() {
                            return getTimeSlotContent(dayItem.getModelObject(), timeSlotItem.getModelObject(),
                                    timeSlotItem);
                        }
                    };

                    timeSlotItem.add(new ListView<String>("timeSlotContent", timeSlotContentModel) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void populateItem(ListItem<String> item) {
                            item.add(new Label("content", item.getModel()));
                            item.add(AttributeModifier.replace("title", item.getModel()));
                        }
                    });

                    // Details
                    final Component dayTimeLessonDetails = createTimeSlotDetailsComponent(
                            "dayTimeLessonDetails", timeSlotItem.getModelObject());
                    dayTimeLessonDetails.setOutputMarkupId(true);
                    timeSlotItem.add(dayTimeLessonDetails);
                    timeSlotItem.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public String getObject() {
                            if (dayTimeLessonDetails.isVisible()) {
                                return "popover-external";
                            }
                            return null;
                        }
                    }));
                    timeSlotItem.add(
                            AttributeModifier.replace("data-content-id", new AbstractReadOnlyModel<String>() { //$NON-NLS-1$
                                private static final long serialVersionUID = 1L;

                                @Override
                                public String getObject() {
                                    if (dayTimeLessonDetails.isVisible()) {
                                        return "#" + dayTimeLessonDetails.getMarkupId(); //$NON-NLS-1$
                                    } else {
                                        return null;
                                    }
                                }
                            }));
                }
            });
        }
    });
}