List of usage examples for org.apache.wicket Component getMarkupId
public String 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. * /*ww w.ja v a2 s . c o m*/ * @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:de.alpharogroup.wicket.ajax.call.listeners.DisableAjaxButtonAjaxCallListener.java
License:Apache License
private String getJsScript(final Component component) { final StringBuilder sb = new StringBuilder(); if (this.value != null) { sb.append("component.value=\"").append(this.value).append("\";"); }/*from w w w . j a va2s.c o m*/ final String jsscript = "var component = document.getElementById(\"" + component.getMarkupId() + "\");" + "component.disabled=true;" + sb.toString(); return jsscript; }
From source file:de.alpharogroup.wicket.behaviors.FocusRequestBehavior.java
License:Apache License
/** * Factory method that creates the java script code for request focus. * * @param component/* w w w.j a va 2s .co m*/ * the component * @return the string */ protected String newJavaScript(final Component component) { final StringBuilder sb = new StringBuilder(); sb.append("setTimeout(" + "function() {" + "var component = document.getElementById(\"") .append(component.getMarkupId()).append("\");"); if (clearValue) { sb.append("component.value = \"\";"); } sb.append("component.focus();"); sb.append("}, " + this.delay + ")"); return sb.toString(); }
From source file:de.alpharogroup.wicket.components.report.Effects.java
License:Apache License
/** * Replace.//from w w w. ja v a 2 s. c o m * * @param target * the target * @param component * the component */ public static void replace(final AjaxRequestTarget target, final Component component) { component.add(new DisplayNoneBehavior()); target.add(component); target.appendJavaScript("jQuery('#" + component.getMarkupId() + "').slideDown(100);"); }
From source file:de.flapdoodle.wicket.behavior.AjaxUpdateable.java
License:Apache License
@Override public String getAjaxRegionMarkupId(Component component) { return component.getMarkupId() + "_border"; }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.util.JavascriptUtils.java
License:Apache License
public static String getFocusScript(Component component) { return "document.getElementById('" + component.getMarkupId() + "').focus();"; }
From source file:de.tudarmstadt.ukp.clarin.webanno.support.DefaultFocusBehavior2.java
License:Apache License
@Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.render(OnLoadHeaderItem.forScript("$('#" + component.getMarkupId() + "').focus();")); }
From source file:de.tudarmstadt.ukp.csniper.webapp.support.wicket.ExtendedIndicatingAjaxButton.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes aAttributes) { AjaxCallListener listener = new AjaxCallListener() { private static final long serialVersionUID = 8211975176278631439L; @Override/*from w w w.ja v a 2s.c om*/ public CharSequence getSuccessHandler(Component aComponent) { return getJs(aComponent.getMarkupId(), model.getObject(), false); } @Override public CharSequence getFailureHandler(Component aComponent) { return getJs(aComponent.getMarkupId(), failureModel.getObject(), false); } @Override public CharSequence getAfterHandler(Component aComponent) { return getJs(aComponent.getMarkupId(), busyModel.getObject(), true); } }; aAttributes.getAjaxCallListeners().add(listener); }
From source file:dk.frankbille.scoreboard.components.Select2Enabler.java
License:Open Source License
@Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.render(OnDomReadyHeaderItem.forScript("$(\"#" + component.getMarkupId() + "\").select2();")); }
From source file:dk.teachus.frontend.components.calendar.CalendarPanel.java
License:Apache License
public CalendarPanel(String id, IModel<DateMidnight> weekDateModel) { super(id, weekDateModel); /*//from w w w .ja v a2s .co m * 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; } } })); } }); } }); }