@Override public void setRequired(Boolean required) { if (component instanceof Field) { checkNotNullArgument(required, "Unable to reset required flag for the bound FieldConfig"); ((Field) component).setRequired(required); } else { this.targetRequired = required; } }
protected void loadRequired(Field component, Element element) { String required = element.attributeValue("required"); if (StringUtils.isNotEmpty(required)) { component.setRequired(Boolean.parseBoolean(required)); } String requiredMessage = element.attributeValue("requiredMessage"); if (requiredMessage != null) { component.setRequiredMessage(loadResourceString(requiredMessage)); } else if (component.isRequired() && component.getDatasource() != null) { MetaPropertyPath propertyPath = component.getMetaPropertyPath(); String defaultRequiredMessage = getMessageTools() .getDefaultRequiredMessage(propertyPath.getMetaClass(), propertyPath.toString()); component.setRequiredMessage(defaultRequiredMessage); } }
protected void initRequired(Field<?> component, MetaPropertyPath metaPropertyPath) { MetaProperty metaProperty = metaPropertyPath.getMetaProperty(); boolean newRequired = metaProperty.isMandatory(); Object notNullUiComponent = metaProperty.getAnnotations() .get(NotNull.class.getName() + "_notnull_ui_component"); if (Boolean.TRUE.equals(notNullUiComponent)) { newRequired = true; } if (newRequired) { component.setRequired(true); if (Strings.isNullOrEmpty(component.getRequiredMessage())) { component.setRequiredMessage(messageTools.getDefaultRequiredMessage( metaPropertyPath.getMetaClass(), metaPropertyPath.toPathString()) ); } } }
@SuppressWarnings("unchecked") @Override public void paramChanged(Param oldParam, Param newParam) { Component oldParamEditComponent = paramEditComponent; for (Component component : paramEditComponentLayout.getComponents()) { paramEditComponentLayout.remove(component); } createParamEditLayout(); if (paramEditComponent instanceof Field) { ((Field) paramEditComponent).setRequired(condition.getRequired()); if (oldParam.getJavaClass().equals(newParam.getJavaClass()) && paramEditComponent.getClass().equals(oldParamEditComponent.getClass())) { ((Field) paramEditComponent).setValue(((Field) oldParamEditComponent).getValue()); } } }
protected void standardFieldInit(Field field, ProcFormParam formParam) { field.setRequired(formParam.isRequired()); field.setEditable(formParam.isEditable()); field.setRequiredMessage(messages.formatMessage(AbstractFormFieldGenerator.class, "fillField", formParam.getLocCaption())); }
/** * Set field's "required" flag to false if the value has been filtered by Row Level Security * This is necessary to allow user to submit form with filtered attribute even if attribute is required */ public static void handleFilteredAttributes(Field component, Datasource datasource, MetaPropertyPath mpp) { if (component.isRequired() && datasource.getState() == Datasource.State.VALID && datasource.getItem() != null && mpp.getMetaProperty().getRange().isClass()) { Entity targetItem = datasource.getItem(); MetaProperty[] propertiesChain = mpp.getMetaProperties(); if (propertiesChain.length > 1) { String basePropertyItem = Arrays.stream(propertiesChain) .limit(propertiesChain.length - 1) .map(MetadataObject::getName) .collect(Collectors.joining(".")); targetItem = datasource.getItem().getValueEx(basePropertyItem); } if (targetItem instanceof BaseGenericIdEntity) { String metaPropertyName = mpp.getMetaProperty().getName(); Object value = targetItem.getValue(metaPropertyName); BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) targetItem; String[] filteredAttributes = getFilteredAttributes(baseGenericIdEntity); if (value == null && filteredAttributes != null && ArrayUtils.contains(filteredAttributes, metaPropertyName)) { component.setRequired(false); } } } }
public Field createField(ReportInputParameter parameter) { Field field = fieldCreationMapping.get(parameter.getType()).createField(parameter); field.setRequiredMessage(messages.formatMessage(this.getClass(), "error.paramIsRequiredButEmpty", parameter.getLocName())); field.setId("param_" + parameter.getAlias()); field.setWidth("100%"); field.setFrame(frame.getWrappedFrame()); field.setEditable(true); field.setRequired(parameter.getRequired()); return field; }
editField.setRequired(false);
cubaField.setRequired(true); cubaField.setRequiredMessage(requiredColumns.get(columnConf));
((Field) component).setRequired(propertyPath.getMetaProperty().isMandatory()); ((Field) component).setRequired(true);
((Field) dynamicAttrComponent).setRequired(attribute.getRequired()); ((Field) dynamicAttrComponent).setRequiredMessage(getMessages() .formatMainMessage("validation.required.defaultMsg", attribute.getLocaleName()));
protected void initDefaultValueField() { defaultValueLabel.setVisible(false); defaultValueBox.removeAll(); ReportInputParameter parameter = getItem(); if (canHaveDefaultValue()) { Field<Object> field = parameterFieldCreator.createField(parameter); field.addValueChangeListener(e -> { if (e.getValue() != null) { parameter.setDefaultValue(reportService.convertToString(e.getValue().getClass(), e.getValue())); } else { parameter.setDefaultValue(null); } }); if (parameter.getParameterClass() != null) { field.setValue(reportService.convertFromString(parameter.getParameterClass(), parameter.getDefaultValue())); } field.setRequired(false); defaultValueBox.add(field); defaultValueLabel.setVisible(true); } defaultValueBox.setEnabled(security.isEntityOpPermitted(metadata.getClassNN(ReportInputParameter.class), EntityOp.UPDATE)); }
cubaField.setRequired(fci.getTargetRequired());
public void createParamEditLayout() { if (paramEditComponentLayout == null){ paramEditComponentLayout = uiComponents.create(HBoxLayout.class); paramEditComponentLayout.setSpacing(true); paramEditComponentLayout.setWidthFull(); } paramEditComponent = condition.getParam().createEditComponent(Param.ValueProperty.VALUE); paramEditComponent.addStyleName("param-field"); if (paramEditComponent instanceof Field) { ((Field) paramEditComponent).setRequired(condition.getRequired()); } paramEditComponentLayout.add(paramEditComponent); removeButton = uiComponents.create(LinkButton.class); removeButton.setStyleName("condition-remove-btn"); removeButton.setIcon("icons/item-remove.png"); removeButton.setAlignment(Alignment.MIDDLE_LEFT); removeButton.setVisible(removeButtonVisible); removeButton.setAction(removeButtonAction); paramEditComponentLayout.add(removeButton); if (paramEditComponentExpandRequired(condition)) { paramEditComponentLayout.expand(paramEditComponent); } else { HBoxLayout spring = uiComponents.create(HBoxLayout.class); paramEditComponentLayout.add(spring); paramEditComponentLayout.expand(spring); } }