/** * @see org.apache.wicket.markup.html.form.FormComponent#convertValue(String[]) */ @Override protected final T convertValue(final String[] value) { String tmp = ((value != null) && (value.length > 0)) ? value[0] : null; return convertChoiceIdToChoice(tmp); }
/** * @see FormComponent#getModelValue() */ public String getModelValue() { final Object object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); return getChoiceRenderer().getIdValue(object, index); } return NO_SELECTION_VALUE; }
/** * Return the localization key for nullValid value * * @return getId() + ".nullValid" */ protected String getNullValidKey() { return getId() + ".nullValid"; }
/** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); return getChoiceRenderer().getIdValue(object, index); } return getNoSelectionValue().toString(); }
/** * Converts submitted choice id string back to choice object. * * @param id * string id of one of the choice objects in the choices list. can be null. * @return choice object. null if none match the specified id. */ protected T convertChoiceIdToChoice(String id) { final IModel<? extends List<? extends T>> choices = getChoicesModel(); final IChoiceRenderer<? super T> renderer = getChoiceRenderer(); T object = (T) renderer.getObject(id, choices); return object; }
private FormComponent<Short> createPositionColumn(final PaymentScheduleDO payment) { final List<Short> availablePositionNumbers = payment.getAuftrag().getPositionenExcludingDeleted().stream() .map(AuftragsPositionDO::getNumber) .collect(Collectors.toList()); return new DropDownChoice<>("positionNumber", new PropertyModel<>(payment, "positionNumber"), availablePositionNumbers) .setNullValid(true) .setRequired(true) .setLabel(new ResourceModel("fibu.auftrag.position")); } }
if (isNullValid()) String option = getLocalizer().getStringIgnoreSettings(getNullValidKey(), this, null, null); if (Strings.isEmpty(option)) option = getLocalizer().getString("nullValid", this, ""); if ((selected == null) || getNoSelectionValue().equals(selected) || selected.equals(EMPTY_STRING)) String option = getLocalizer().getStringIgnoreSettings(getNullKey(), this, null, null); option = getLocalizer().getString("null", this, CHOOSE_ONE);
if (isNullValid()) String option = getLocalizer().getString(getId() + ".nullValid", this, ""); if (Strings.isEmpty(option)) option = getLocalizer().getString("nullValid", this, ""); String option = getLocalizer().getString(getId() + ".null", this, ""); if (Strings.isEmpty(option)) option = getLocalizer().getString("null", this, CHOOSE_ONE);
.setNullValid(true).add(new RefreshMetaContextOnChangeBehaviour()); }.setNullValid(false).setRequired(true); } else if(customAttr.equals(CustomAttribute.PROP_INVERSE)) { IModel<OClass> linkedClassModel = (IModel<OClass>)getMetaComponentEnteredValueModel(OPropertyPrototyper.LINKED_CLASS);
/** * @see org.apache.wicket.markup.html.form.FormComponent#onComponentTag(org.apache.wicket.markup.ComponentTag) */ @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); // since this component cannot be attached to input tag the name // variable is illegal tag.remove("name"); }
/** * Converts submitted choice id string back to choice object. * * @param id * string id of one of the choice objects in the choices list. can be null. * @return choice object. null if none match the specified id. */ protected Object convertChoiceIdToChoice(String id) { final List choices = getChoices(); final IChoiceRenderer renderer = getChoiceRenderer(); for (int index = 0; index < choices.size(); index++) { // Get next choice final Object choice = choices.get(index); if (renderer.getIdValue(choice, index).equals(id)) { return choice; } } return null; }
final DropDownChoice<HRPlanningEntryStatus> statusChoice = new DropDownChoice<HRPlanningEntryStatus>(fs.getDropDownChoiceId(), new PropertyModel<HRPlanningEntryStatus>(entry, "status"), statusChoiceRenderer.getValues(), statusChoiceRenderer); statusChoice.setNullValid(true).setRequired(false).setEnabled(!entry.isDeleted()); fs.add(statusChoice); dependentEntryFormComponents.add(statusChoice); final DropDownChoice<Priority> priorityChoice = new DropDownChoice<Priority>(fs.getDropDownChoiceId(), new PropertyModel<Priority>( entry, "priority"), priorityChoiceRenderer.getValues(), priorityChoiceRenderer); priorityChoice.setNullValid(true).setEnabled(!entry.isDeleted()); fs.add(priorityChoice); final DropDownChoice<Integer> probabilityChoice = new DropDownChoice<Integer>(fs.getDropDownChoiceId(), new PropertyModel<Integer>( entry, "probability"), probabilityChoiceRenderer.getValues(), probabilityChoiceRenderer); probabilityChoice.setNullValid(true).setEnabled(!entry.isDeleted()); fs.add(probabilityChoice);
/** * Returns the display value for the null value. The default behavior is to look the value up by * using the key from <code>getNullValidKey()</code>. * * @return The value to display for null */ protected String getNullValidDisplayValue() { String option = getLocalizer().getStringIgnoreSettings(getNullValidKey(), this, null, null); if (Strings.isEmpty(option)) { option = getLocalizer().getString("nullValid", this, ""); } return option; }
/** * Returns the display value if null is not valid but is selected. The default behavior is to * look the value up by using the key from <code>getNullKey()</code>. * * @return The value to display if null is not value but selected, e.g. "Choose One" */ protected String getNullKeyDisplayValue() { String option = getLocalizer().getStringIgnoreSettings(getNullKey(), this, null, null); if (Strings.isEmpty(option)) { option = getLocalizer().getString("null", this, CHOOSE_ONE); } return option; }
new LambdaChoiceRenderer<>(KBHandle::getUiLabel)) .setNullValid(true) .setOutputMarkupPlaceholderTag(true)); new LambdaChoiceRenderer<>(KnowledgeBase::getName)) .setNullValid(true) .add(new LambdaAjaxFormComponentUpdatingBehavior("change", target -> target.add(form.get(MID_SCOPE))))); form.add(
if (isNullValid()) String option = getNullValidDisplayValue(); String option = getNullKeyDisplayValue(); return "\n<option selected=\"selected\" value=\"\">" + option + "</option>";
/** * Gets whether the given value represents the current selection. * * * @param object * The object to check * @param index * The index of the object in the collection * @param selected * The current selected id value * @return Whether the given value represents the current selection */ @Override protected boolean isSelected(final T object, int index, String selected) { return (selected != null) && selected.equals(getChoiceRenderer().getIdValue(object, index)); } }
/** * Create the galleryTypeSelector, only shown in the UI if there actually is something to choose from. Send changes * to the backend using Ajax, in order to remember old choices while navigating through the gallery. * * @return the type selector component */ @SuppressWarnings("unchecked") private Component createTypeSelector() { getGalleryType(); // initialize the galleryType value return new DropDownChoice<String>("gallery-type-selector", new PropertyModel(this, "galleryType"), galleryTypesModel, new TypeChoiceRenderer(this)) { @Override public boolean isVisible() { return getChoices().size() > 1; } } .setNullValid(false) .add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { // required because abstract, but all we need is to have galleryType set, which happens underwater. } }); }
public ContentImportDialog(IModelReference modelReference) { this.modelReference = modelReference; InitMaps(); this.nodeModel = (JcrNodeModel) modelReference.getModel(); DropDownChoice uuid = new DropDownChoice("uuidBehaviors", new PropertyModel(this, "uuidBehavior"), new ArrayList<String>(uuidOpts.values())); DropDownChoice merge = new DropDownChoice("mergeBehaviors", new PropertyModel(this, "mergeBehavior"), new ArrayList<String>(mergeOpts.values())); DropDownChoice reference = new DropDownChoice("derefBehaviors", new PropertyModel(this, "derefBehavior"), new ArrayList<String>(derefOpts.values())); CheckBox save = new CheckBox("saveBehavior", new PropertyModel(this, "saveBehavior")); add(uuid.setNullValid(false).setRequired(true)); add(merge.setNullValid(false).setRequired(true)); add(reference.setNullValid(false).setRequired(true)); add(save); // file upload setMultiPart(true); setNonAjaxSubmit(); add(fileUploadField = new FileUploadField("fileInput")); setOkLabel("import"); setFocus(uuid); try { String path = this.nodeModel.getNode().getPath(); add(new Label("message", new StringResourceModel("dialog.message", this, null, new Object[] {path}))); //info("Import content from a file to node: " + nodeModel.getNode().getPath()); } catch (RepositoryException e) { log.error("Error getting node from model for contant import",e); throw new RuntimeException("Error getting node from model for contant import: " + e.getMessage()); } }
/** * @see org.apache.wicket.markup.html.form.FormComponent#onComponentTag(org.apache.wicket.markup.ComponentTag) */ @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); // since this component cannot be attached to input tag the name // variable is illegal tag.remove("name"); }