Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » ColorField.js(Creating new field)
ColorField.js [message #1849878] Mon, 07 February 2022 08:22
Mr Robot is currently offline Mr RobotFriend
Messages: 72
Registered: March 2020
Member
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
Previous Topic:Eclipse Scout new project forcing to 22-beta
Next Topic:22.0-beta1: Classic App not loading after successful login
Goto Forum:
  


Current Time: Thu Oct 03 11:03:07 GMT 2024

Powered by FUDForum. Page generated in 0.28195 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top