List of usage examples for org.apache.wicket.markup.html WebComponent setVisible
public final Component setVisible(final boolean visible)
From source file:org.apache.isis.viewer.wicket.ui.components.footer.FooterPanel.java
License:Apache License
/** * Adds a component that shows a warning sign next to "About" link in development mode * @param container The parent component *//*from www .j a v a 2 s . c o m*/ private void addDevModeWarning(final MarkupContainer container) { final WebComponent devModeWarning = new WebComponent("devModeWarning"); devModeWarning.setVisible(getApplication().usesDevelopmentConfig()); container.add(devModeWarning); }
From source file:org.devproof.portal.core.module.common.page.TemplatePage.java
License:Apache License
private WebComponent createGoogleAnalytics() { boolean googleEnabled = configurationService.findAsBoolean(CommonConstants.CONF_GOOGLE_ANALYTICS_ENABLED); WebComponent googleAnalytics2 = newGoogleAnalytics(); googleAnalytics2.setVisible(googleEnabled); return googleAnalytics2; }
From source file:org.efaps.ui.wicket.components.date.DateTimePanel.java
License:Apache License
/** * @param _wicketId wicket id of this component * @param _dateObject object containing a DateTime, if null or not DateTime * a new DateTime will be instantiated * @param _fieldName Name of the field this DateTimePanel belongs to * @param _fieldLabel Label to e used in case of error * @param _time must the time be rendered also * @param _inputSize size of the input/*w w w .j a v a2 s . c o m*/ * @throws EFapsException on error */ public DateTimePanel(final String _wicketId, final Model<AbstractUIField> _model, final FieldConfiguration _fieldConf, final Object _dateObject, final boolean _time) throws EFapsException { super(_wicketId, Model.<DateTime>of()); this.uiField = _model.getObject(); this.fieldConfig = _fieldConf; this.datetime = _dateObject == null || !(_dateObject instanceof DateTime) ? new DateTime(Context.getThreadContext().getChronology()) : (DateTime) _dateObject; if (this.uiField != null) { setLabel(Model.of(getFieldConfig().evalLabel(this.uiField.getValue(), this.uiField.getInstance()))); } else { setLabel(Model.of(getFieldConfig().getLabel())); } this.converter = new StyleDateConverter(false) { private static final long serialVersionUID = 1L; @Override protected DateTimeZone getTimeZone() { DateTimeZone ret = null; try { ret = Context.getThreadContext().getTimezone(); } catch (final EFapsException e) { DateTimePanel.LOG.error("EFapsException", e); } finally { if (ret == null) { super.getTimeZone(); } } return ret; } }; final DateTextField dateField = new DateTextField("date", new Model<>(this.datetime.toDate()), this.converter) { private static final long serialVersionUID = 1L; @Override public String getInputName() { return DateTimePanel.this.getDateFieldName(); } }; this.add(dateField); if (getFieldConfig().hasProperty(UIFormFieldProperty.COLUMNS)) { add(new AttributeModifier("maxlength", getFieldConfig().getProperty(UIFormFieldProperty.COLUMNS))); } if (getFieldConfig().hasProperty(UIFormFieldProperty.WIDTH) && this.uiField != null && !(this.uiField.getParent() instanceof UITable)) { add(new AttributeAppender("style", "width:" + getFieldConfig().getWidth(), ";")); } this.datePicker = new DatePickerBehavior(); dateField.add(this.datePicker); final WebComponent hour = new WebComponent("hours") { private static final long serialVersionUID = 1L; @Override protected void onComponentTag(final ComponentTag _tag) { super.onComponentTag(_tag); int hourTmp = DateTimePanel.this.datetime.getHourOfDay(); if (use12HourFormat()) { if (hourTmp == 0) { hourTmp = 12; } if (hourTmp > 12) { hourTmp = hourTmp - 12; } } _tag.put("value", String.format("%02d", hourTmp)); _tag.put("name", DateTimePanel.this.getHourFieldName()); _tag.put("maxlength", 2); } }; this.add(hour); hour.setVisible(_time); final WebComponent minutes = new WebComponent("minutes") { private static final long serialVersionUID = 1L; @Override protected void onComponentTag(final ComponentTag _tag) { super.onComponentTag(_tag); _tag.put("value", String.format("%02d", DateTimePanel.this.datetime.getMinuteOfHour())); _tag.put("name", DateTimePanel.this.getMinuteFieldName()); _tag.put("maxlength", 2); } }; this.add(minutes); minutes.setVisible(_time); final WebComponent ampm = new WebComponent("ampm") { private static final long serialVersionUID = 1L; @Override protected void onComponentTag(final ComponentTag _tag) { super.onComponentTag(_tag); _tag.put("name", DateTimePanel.this.getAmPmFieldName()); } /** * set an am or pm option */ @Override public void onComponentTagBody(final MarkupStream _markupStream, final ComponentTag _openTag) { super.onComponentTagBody(_markupStream, _openTag); final StringBuilder html = new StringBuilder(); html.append("<option "); final int hourTmp = DateTimePanel.this.datetime.getHourOfDay(); if (hourTmp < 12) { html.append("selected=\"true\""); } html.append(">am</option>").append("<option "); if (hourTmp > 11) { html.append("selected=\"true\""); } html.append(">pm</option>"); replaceComponentTagBody(_markupStream, _openTag, html); } }; this.add(ampm); ampm.setVisible(_time); if (!use12HourFormat()) { ampm.setVisible(false); } if (getFieldConfig() != null && getFieldConfig().getField().hasEvents(EventType.UI_FIELD_UPDATE)) { final List<EventDefinition> events = getFieldConfig().getField().getEvents(EventType.UI_FIELD_UPDATE); String eventName = "change"; for (final EventDefinition event : events) { eventName = event.getProperty("Event") == null ? "change" : event.getProperty("Event"); } dateField.add(new AjaxFieldUpdateBehavior(eventName, Model.of(this.uiField), false)); if (_time) { hour.add(new AjaxFieldUpdateBehavior(eventName, Model.of(this.uiField), false)); minutes.add(new AjaxFieldUpdateBehavior(eventName, Model.of(this.uiField), false)); if (use12HourFormat()) { ampm.add(new AjaxFieldUpdateBehavior(eventName, Model.of(this.uiField), false)); } } } this.add(new WebMarkupContainer("seperator").setVisible(_time)); }