List of usage examples for org.apache.wicket Component replaceWith
public Component replaceWith(Component replacement)
From source file:au.org.theark.core.web.form.AbstractWizardStepPanel.java
License:Open Source License
protected void setContent(AjaxRequestTarget target, Component content) { if (!content.getId().equals(getContentId())) throw new IllegalArgumentException( "Expected content id is " + getContentId() + " but " + content.getId() + " was found."); Component current = get(getContentId()); if (current == null) { add(content);/*from ww w . j a v a2 s . c o m*/ } else { current.replaceWith(content); if (target != null) { target.add(get(getContentId())); } } }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
/** * Create the DataType dropdown. When the datatype is changed, the offsets will be recalculated and updated. *//*from ww w. j ava 2 s . c o m*/ private DropDownChoice<BinaryDataType> getDataTypeDropdown() { DropDownChoice<BinaryDataType> dropDown = new DropDownChoice<BinaryDataType>("dataType", BinaryDataType.getOptions(), new EnumChoiceRenderer<BinaryDataType>(this)) { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (hasErrorMessage()) { String style = "background-color:#ffff00;"; String oldStyle = tag.getAttribute("style"); tag.put("style", style + oldStyle); } } }; dropDown.setRequired(true); // When the datatype is changed, the offsets are recalculated and displayed dropDown.add(new OnChangeAjaxBehavior() { @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { // Recalculate and display the offsets updateOffsets(target); // Disable input fields when DataType is a special type. // Current state is determined by the enabled state of TextField("id") DropDownChoice<BinaryDataType> choice = (DropDownChoice<BinaryDataType>) getComponent(); MarkupContainer parent = choice.getParent(); Component idTextField = parent.get("id"); BinaryDataType dataType = choice.getConvertedInput(); if (dataType.isSpecial() && idTextField.isEnabled()) { // DataType changed to special type // Store current values ((TextField<Integer>) idTextField).getRawInput(); idTextField.replaceWith(getSpecialIdTextField().setEnabled(false)); target.add(parent.get("id")); target.add(parent.get("alias").setVisible(false)); } else if (!idTextField.isEnabled()) { idTextField.replaceWith(getIdTextField()); target.add(parent.get("id").setEnabled(true)); target.add(parent.get("alias").setVisible(true)); } target.add(parent.get("size").setEnabled(dataType.isArrayAllowed())); target.add(parent.get("tagLengthType").setEnabled(dataType.supportsVariableLength())); if (!dataType.supportsVariableLength()) { EditorListItem<TagConfig> listItem = getComponent().findParent(EditorListItem.class); if (listItem != null) { listItem.getModelObject().setTagLengthType(TagLengthType.FIXED_LENGTH); } } } }); dropDown.add(new UniqueListItemValidator<BinaryDataType>(dropDown) { @Override public String getValue(IValidatable<BinaryDataType> validatable) { return String.valueOf(validatable.getValue().name()); } }.setMessageKey("dataType.SpecialTypesValidator") .setFilterList(new String[] { BinaryDataType.MessageAge.name() })); return dropDown; }
From source file:com.tysanclan.site.projectewok.components.CalendarPanelNavigator.java
License:Open Source License
private void replacePanel(AjaxRequestTarget target, Date newDate) { Calendar cal = DateUtil.getCalendarInstance(); cal.setTime(newDate);//from ww w . j a v a 2 s . co m CalendarPanel newPanel = createNewPanel(panel.getId(), cal); panel.replaceWith(newPanel); panel = newPanel; Component oldLabel = get("month"); Label label = createMonthLabel(newDate); oldLabel.replaceWith(label); if (target != null) { target.add(panel); target.add(label); selectedDate = newDate; } }
From source file:com.tysanclan.site.projectewok.pages.member.CalendarPage.java
License:Open Source License
/** * //from w ww .j a v a 2 s . co m */ public CalendarPage() { super("Calendar"); add(new OtterSniperPanel("otterSniperPanel", 2)); WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); Date currTime = DateUtil.getMidnightCalendarInstance().getTime(); InlineDatePicker calendar = new InlineDatePicker("calendar", currTime) { /** * */ private static final long serialVersionUID = 1L; @Override protected void onDateSelected(Date date, AjaxRequestTarget target) { TimeZone tz = DateUtil.NEW_YORK; if (getUser().getTimezone() != null) { tz = TimeZone.getTimeZone(getUser().getTimezone()); } Calendar cal = Calendar.getInstance(tz); cal.setTime(date); Component oldEventView = getEventViewComponent(); Component oldTitle = getTitleComponent(); ListView<Event> eventView = createListView(cal.getTime()); getContainer().setVisible(!eventView.getModelObject().isEmpty()); Label newTitle = new Label("title", "Events for " + new SimpleDateFormat("EEEE d MMMM yyyy", Locale.US).format(date)); oldEventView.replaceWith(eventView); oldTitle.replaceWith(newTitle); Component component = get("schedule:description").setVisible(true); if (target != null) { target.appendJavaScript( "tinyMCE.execCommand('mceRemoveControl', false, '" + component.getMarkupId() + "')"); target.add(getContainer()); target.appendJavaScript( "tinyMCE.execCommand('mceAddControl', false, '" + component.getMarkupId() + "')"); } } }; container.add(calendar); add(container); ListView<Event> eventView = createListView(currTime); container.add(eventView); container.setVisible(!eventView.getModelObject().isEmpty()); container.add(new Label("title", "Events for " + new SimpleDateFormat("EEEE d MMMM yyyy", Locale.US).format(currTime))); Form<Event> scheduleEventForm = new Form<Event>("schedule") { private static final long serialVersionUID = 1L; @SpringBean private EventService eventService; @SuppressWarnings("unchecked") @Override protected void onSubmit() { TextField<String> titleComponent = (TextField<String>) get("title"); TextArea<String> descriptionComponent = (TextArea<String>) get("description"); DatePickerPanel dateComponent = (DatePickerPanel) get("dateselect"); DropDownChoice<Integer> hourComponent = (DropDownChoice<Integer>) get("hourselect"); DropDownChoice<Integer> minuteComponent = (DropDownChoice<Integer>) get("minuteselect"); String title = titleComponent.getModelObject(); String description = descriptionComponent.getModelObject(); Date selectedDate = dateComponent.getSelectedDate(); if (selectedDate == null) { error("No date selected"); return; } TimeZone tz = DateUtil.NEW_YORK; if (getUser().getTimezone() != null) { tz = TimeZone.getTimeZone(getUser().getTimezone()); } Calendar cal = Calendar.getInstance(tz); cal.setTime(DateUtil.getMidnightDate(selectedDate)); cal.add(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.HOUR_OF_DAY, hourComponent.getModelObject()); cal.add(Calendar.MINUTE, minuteComponent.getModelObject()); Event event = eventService.scheduleEvent(getUser(), cal.getTime(), title, description); if (event != null) { setResponsePage(new CalendarPage()); } } }; scheduleEventForm.add(new TextField<String>("title", new Model<String>("")).setRequired(true)); TextArea<String> descriptionEditor = new BBCodeTextArea("description", ""); descriptionEditor.setRequired(true); scheduleEventForm.add(descriptionEditor); DatePickerPanel datePanel = new DatePickerPanel("dateselect"); scheduleEventForm.add(datePanel); scheduleEventForm.add(new DropDownChoice<Integer>("hourselect", new Model<Integer>(0), DateUtil.getHours(), DateUtil.getTwoDigitRenderer()).setNullValid(false).setRequired(true)); scheduleEventForm.add(new DropDownChoice<Integer>("minuteselect", new Model<Integer>(0), DateUtil.getMinutes(), DateUtil.getTwoDigitRenderer()).setNullValid(false).setRequired(true)); TimeZone tz = DateUtil.NEW_YORK; if (getUser().getTimezone() != null) { tz = TimeZone.getTimeZone(getUser().getTimezone()); } scheduleEventForm.add(new Label("timezone", tz.getDisplayName(false, TimeZone.LONG, Locale.US))); add(scheduleEventForm); }
From source file:com.userweave.pages.components.studypanel.StudyPanel.java
License:Open Source License
private boolean replaceStudyFilterPanel(AjaxRequestTarget target, final StateChangeTrigger trigger) { Component filterPanel = getStateDependComponent(); if (filterPanel != null && filterPanel instanceof StudyFilterPanel) { StudyFilterPanel replacement = new StudyFilterPanel(STATE_DEPEND_COMPONENT_ID, getDefaultModel()) { private static final long serialVersionUID = 1L; @Override/*from w w w.j a va 2 s . c o m*/ protected void onFilter(AjaxRequestTarget target) { StudyPanel.this.onFilter(target, trigger); } }; replacement.setOutputMarkupId(true); filterPanel.replaceWith(replacement); setStateDependComponent(replacement); target.add(this); target.add(getStateDependComponent()); return true; } return false; }
From source file:de.voolk.marbles.web.pages.base.panel.ReplacingConfirmationActionPanel.java
License:Open Source License
public ReplacingConfirmationActionPanel(Component original, String text) { super(original.getId(), text); this.original = original; original.replaceWith(this); }
From source file:org.artifactory.webapp.wicket.page.security.profile.MavenSettingsPanel.java
License:Open Source License
public void displayEncryptedPassword(MutableUserInfo userInfo) { WebMarkupContainer settingsSnippet = new WebMarkupContainer("settingsSnippet"); String currentPassword = getUserProfile().getCurrentPassword(); SecretKey secretKey = CryptoHelper.generatePbeKeyFromKeyPair(userInfo.getPrivateKey(), userInfo.getPublicKey(), false); String encryptedPassword = CryptoHelper.encryptSymmetric(currentPassword, secretKey, false); settingsSnippet.add(createSettingXml(userInfo, encryptedPassword)); // With Base58 new encryption this not needed anymore Component nonMavenPasswordLabel = new WebMarkupContainer("nonMavenPassword"); settingsSnippet.add(nonMavenPasswordLabel); if (ConstantValues.securityUseBase64.getBoolean()) { nonMavenPasswordLabel.replaceWith(new Label("nonMavenPassword", "Non-maven clients should use a non-escaped password: " + encryptedPassword)); }//from ww w . j a v a 2 s .c om replace(settingsSnippet); }
From source file:org.efaps.ui.wicket.components.search.ResultPanel.java
License:Apache License
/** * Update.// w w w. ja v a 2s. c o m * * @param _target the target * @param _indexSearch the index search */ public void update(final AjaxRequestTarget _target, final IndexSearch _indexSearch) { ResultPanel.this.visitChildren(DimensionPanel.class, new IVisitor<Component, Void>() { @Override public void component(final Component _component, final IVisit<Void> _visit) { try { if (_indexSearch.getSearch().getConfigs().contains(SearchConfig.ACTIVATE_DIMENSION)) { _component.setVisible(true); } else { _component.setVisible(false); } } catch (final EFapsException e) { LOG.error("Catched error", e); } _visit.dontGoDeeper(); } }); ResultPanel.this.visitChildren(DataTable.class, new IVisitor<Component, Void>() { @Override public void component(final Component _component, final IVisit<Void> _visit) { if (_indexSearch.getResult().getElements().isEmpty()) { _component.setVisible(false); } else { _component.setVisible(true); } if (_indexSearch.isUpdateTable()) { _component.replaceWith(getDataTable(_indexSearch)); } _visit.dontGoDeeper(); } }); ResultPanel.this.visitChildren(Label.class, new IVisitor<Component, Void>() { @Override public void component(final Component _component, final IVisit<Void> _visit) { final String compid = _component.getId(); switch (compid) { case "hits": if (_indexSearch.getResult().getElements().isEmpty()) { _component.setVisible(false); } else { _component.setVisible(true); ((Label) _component).setDefaultModelObject( DBProperties.getFormatedDBProperty(ResultPanel.class.getName() + ".Hits", _indexSearch.getResult().getElements().size(), _indexSearch.getResult().getHitCount())); } break; case "noResult": if (_indexSearch.getResult().getElements().isEmpty()) { _component.setVisible(true); ((Label) _component).setDefaultModelObject( DBProperties.getProperty(ResultPanel.class.getName() + ".NoResult")); } else { _component.setVisible(false); } break; default: break; } } }); }
From source file:org.obiba.onyx.wicket.wizard.WizardStepPanel.java
License:Open Source License
protected void setContent(AjaxRequestTarget target, Component content) { if (!content.getId().equals(getContentId())) throw new IllegalArgumentException( "Expected content id is " + getContentId() + " but " + content.getId() + " was found."); Component current = get(getContentId()); if (current == null) { add(content);/*www . j av a2 s.c om*/ } else { current.replaceWith(content); if (target != null) { target.addComponent(get(getContentId())); } } }
From source file:org.sakaiproject.profile2.tool.pages.panels.MyContactDisplay.java
License:Educational Community License
public MyContactDisplay(final String id, final UserProfile userProfile) { super(id);// w w w . j av a2 s.c om //this panel stuff final Component thisPanel = this; //get info from userProfile since we need to validate it and turn things off if not set. String email = userProfile.getEmail(); String homepage = userProfile.getHomepage(); String workphone = userProfile.getWorkphone(); String homephone = userProfile.getHomephone(); String mobilephone = userProfile.getMobilephone(); String facsimile = userProfile.getFacsimile(); //heading add(new Label("heading", new ResourceModel("heading.contact"))); //email WebMarkupContainer emailContainer = new WebMarkupContainer("emailContainer"); emailContainer.add(new Label("emailLabel", new ResourceModel("profile.email"))); emailContainer.add(new Label("email", email)); add(emailContainer); if (StringUtils.isBlank(email)) { emailContainer.setVisible(false); } else { visibleFieldCount++; } //homepage WebMarkupContainer homepageContainer = new WebMarkupContainer("homepageContainer"); homepageContainer.add(new Label("homepageLabel", new ResourceModel("profile.homepage"))); homepageContainer.add(new ExternalLink("homepage", homepage, homepage)); add(homepageContainer); if (StringUtils.isBlank(homepage)) { homepageContainer.setVisible(false); } else { visibleFieldCount++; } //work phone WebMarkupContainer workphoneContainer = new WebMarkupContainer("workphoneContainer"); workphoneContainer.add(new Label("workphoneLabel", new ResourceModel("profile.phone.work"))); workphoneContainer.add(new Label("workphone", workphone)); add(workphoneContainer); if (StringUtils.isBlank(workphone)) { workphoneContainer.setVisible(false); } else { visibleFieldCount++; } //home phone WebMarkupContainer homephoneContainer = new WebMarkupContainer("homephoneContainer"); homephoneContainer.add(new Label("homephoneLabel", new ResourceModel("profile.phone.home"))); homephoneContainer.add(new Label("homephone", homephone)); add(homephoneContainer); if (StringUtils.isBlank(homephone)) { homephoneContainer.setVisible(false); } else { visibleFieldCount++; } //mobile phone WebMarkupContainer mobilephoneContainer = new WebMarkupContainer("mobilephoneContainer"); mobilephoneContainer.add(new Label("mobilephoneLabel", new ResourceModel("profile.phone.mobile"))); mobilephoneContainer.add(new Label("mobilephone", mobilephone)); add(mobilephoneContainer); if (StringUtils.isBlank(mobilephone)) { mobilephoneContainer.setVisible(false); } else { visibleFieldCount++; } //facsimile WebMarkupContainer facsimileContainer = new WebMarkupContainer("facsimileContainer"); facsimileContainer.add(new Label("facsimileLabel", new ResourceModel("profile.phone.facsimile"))); facsimileContainer.add(new Label("facsimile", facsimile)); add(facsimileContainer); if (StringUtils.isBlank(facsimile)) { facsimileContainer.setVisible(false); } else { visibleFieldCount++; } //edit button AjaxFallbackLink editButton = new AjaxFallbackLink("editButton") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { Component newPanel = new MyContactEdit(id, userProfile); newPanel.setOutputMarkupId(true); thisPanel.replaceWith(newPanel); if (target != null) { target.add(newPanel); //resize iframe target.appendJavaScript("setMainFrameHeight(window.name);"); } } }; editButton.add(new Label("editButtonLabel", new ResourceModel("button.edit"))); editButton.setOutputMarkupId(true); if (userProfile.isLocked() && !sakaiProxy.isSuperUser()) { editButton.setVisible(false); } add(editButton); //no fields message Label noFieldsMessage = new Label("noFieldsMessage", new ResourceModel("text.no.fields")); add(noFieldsMessage); if (visibleFieldCount > 0) { noFieldsMessage.setVisible(false); } }