private void init(final String id, final Integer maxLength) { if (maxLength != null && maxLength != -1) { add(StringValidator.maximumLength(maxLength)); // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Field maxlength is produced by StringValidator. } }
private void init(final Integer maxLength) { if (maxLength != null) { add(StringValidator.maximumLength(maxLength)); //add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Done by StringValidator } } }
private void init(final String id, final Integer maxLength) { if (maxLength != null) { add(StringValidator.maximumLength(maxLength)); // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Not supported by html textarea! this.maxLength = maxLength; } }
private void init(final String id, final Integer maxLength) { if (maxLength != null) { add(StringValidator.maximumLength(maxLength)); // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Done by StringValidator } }
@Override public Component appendInput(WicketBuildContext ctx, BSControls formGroup, IModel<String> labelModel) { final IModel<? extends SInstance> model = ctx.getModel(); FormComponent<?> comp = new TextField<>(model.getObject().getName(), new SInstanceValueModel<>(model), String.class).setLabel(labelModel); formGroup.appendInputText(comp); Optional<Integer> maxSize = Optional.ofNullable( model.getObject().getAttributeValue(SPackageBasic.ATR_MAX_LENGTH)); if (maxSize.isPresent()) { comp.add(StringValidator.maximumLength(maxSize.get())); comp.add(new CountDownBehaviour()); } Optional<String> basicMask = Optional.ofNullable( model.getObject().getAttributeValue(SPackageBasic.ATR_BASIC_MASK)); if (basicMask.isPresent()) { comp.add(new InputMaskBehavior(Masks.valueOf(basicMask.get()))); comp.setOutputMarkupId(true); } Optional.ofNullable(model.getObject() .getAttributeValue(SPackageBasic.ATR_UPPER_CASE_TEXT) ).filter(x -> x) .ifPresent(value -> { comp.add($b.attrAppender("style", "text-transform: uppercase", ";")); }); return comp; }
@Override public Component appendInput(WicketBuildContext ctx, BSControls formGroup, IModel<String> labelModel) { final IModel<? extends SInstance> model = ctx.getModel(); final SView view = ctx.getView(); if (view instanceof SViewTextArea) { SViewTextArea mTextAreaView = (SViewTextArea) view; final SInstance mi = model.getObject(); FormComponent<?> textArea = new TextArea<>(mi.getName(), new SInstanceValueModel<>(model)); textArea.setLabel(labelModel); formGroup.appendTextarea(textArea, mTextAreaView.getLines()); Optional<Integer> maxSize = Optional.ofNullable(mi.getAttributeValue(SPackageBasic.ATR_MAX_LENGTH)); if (maxSize.isPresent()) { textArea.add(StringValidator.maximumLength(maxSize.get())); textArea.add(new CountDownBehaviour()); } return textArea; } throw new WicketRuntimeException("TextAreaMapper deve ser utilizado com MTextAreaView"); } }
addButton(BSModalBorder.ButtonStyle.PRIMARY, $m.ofValue("Confirmar"), new OkButton("btn-ok", annotationComponent)); comment.add(StringValidator.maximumLength(4000)); comment.add(new CountDownBehaviour());