Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » @ModelVariant - cannot find custom field
@ModelVariant - cannot find custom field [message #1834072] Sun, 01 November 2020 11:25 Go to next message
Eclipse UserFriend
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 11:28 Go to previous messageGo to next message
Eclipse UserFriend
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 11:49 Go to previous message
Eclipse UserFriend
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: Sun Jun 22 18:11:23 EDT 2025

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

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

Back to the top