Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » @ModelVariant - cannot find custom field
@ModelVariant - cannot find custom field [message #1834072] Sun, 01 November 2020 16:25 Go to next message
Mr Robot is currently offline Mr RobotFriend
Messages: 70
Registered: March 2020
Member
Hello,

I am trying to extend StringField.js with my custom StringField called MyCustomStringField.js

I created FormField in form and added annotation @ModelVariant("MyCustom")

I created MyCustomStringField.js class that extends StringField from Scout like this:
import { StringField } from '@eclipse-scout/core';

export default class MyCustomStringField extends StringField {

	constructor() {
		super();
	}

	_render() {
		super._render();
		console.log("Component testing");
	}


}


I included MyCustomStringField like this in index.js:

export {default as MyCustomStringField} from './MyCustomStringField';

// Define namespace and put it onto window (necessary for model variants, e.g. @ModelVariant(${classPrefixLowerCase}.Example)
import * as self from './index.js';
export default self;


window.testing= Object.assign(window.testing|| {}, self);



I have this error when opening form...
[ERROR] App initialization failed Error: Failed to create object for objectType "StringField:MyCustom": Could not find "MyCustomStringField" in namespace ""

Please can you help? Why is namespace empty "" in error description?

Did I forgot to add something?

Thanks
Re: @ModelVariant - cannot find custom field [message #1834073 is a reply to message #1834072] Sun, 01 November 2020 16:28 Go to previous messageGo to next message
Mr Robot is currently offline Mr RobotFriend
Messages: 70
Registered: March 2020
Member
ok, solved. @ModelVariant has to include app namespace like @ModelVariant("appnamespace.MyCustom")
Re: @ModelVariant - cannot find custom field [message #1843822 is a reply to message #1834073] Thu, 19 August 2021 15:49 Go to previous message
Daniel Sanchez is currently offline Daniel SanchezFriend
Messages: 5
Registered: April 2019
Junior Member
Thank you very much!!!

I was getting crazy being unable to make it work during my migration from scout 9 to 11, until I saw your last post here ;)

Previous Topic:Launch a Form from Smart Field Selection
Next Topic:[Solved]Error 404 for a resource
Goto Forum:
  


Current Time: Tue Apr 23 15:53:38 GMT 2024

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

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

Back to the top