Hello, currently learning JS part of Eclipse Scout.
I want to create ColorField. But I have problem that value is always null. Can you help me.
This is ColorField.js, extending BasicField with input type = color
import { BasicField } from '@eclipse-scout/core';
export default class ColorField extends BasicField {
constructor() {
super();
}
_init(model) {
super._init(model);
}
_render() {
this.addContainer(this.$parent, 'colorfield');
this.addLabel();
let $field = this.$parent.makeElement('<input>', 'color-field')
.attr('type', 'color')
.attr('autocomplete', 'NoAutocomplete') /* off and false are currently ignored in Chrome */
.disableSpellcheck();
this.addField($field);
this.addMandatoryIndicator();
this.addStatus();
}
}
This is ColorFieldAdapter:
import { BasicFieldAdapter } from '@eclipse-scout/core';
export default class ColorFieldAdapter extends BasicFieldAdapter {
constructor() {
super();
}
}
This is JsonColorField.js
public class JsonColorField<T extends IColorField> extends JsonBasicField<T> {
public JsonColorField(T model, IUiSession uiSession, String id, IJsonAdapter<?> parent) {
super(model, uiSession, id, parent);
}
@Override
public String getObjectType() {
return "myapp.ColorField";
}
}
I also imported ColorField and ColorFieldAdapter in index.js
This is IColorField
public interface IColorField extends IBasicField<String> {
}
This is AbstractColorField:
public class AbstractColorField extends AbstractBasicField<String> implements IColorField {
private IBasicFieldUIFacade m_uiFacade;
public AbstractColorField() {
this(true);
}
public AbstractColorField(boolean callInitializer) {
super(callInitializer);
}
@Override
protected void initConfig() {
super.initConfig();
m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent());
}
@Override
public IBasicFieldUIFacade getUIFacade() {
return m_uiFacade;
}
}
Now, every time I got null when doing getColorField().getValue();
When I inspect field in JS field has value when color is changed in picker. Inspecting field I see attribute value with right color like '#rit94d'
Do I need to setValue from JS?
I also tried:
this.parseAndSetValue("custom_valueee");
I also tried catch events (change, input) and set value and also set init value but I cannot get value in Java.
Thank you