model.create(), can not show reference type property

15 views
Skip to first unread message

min...@nanopay.net

unread,
Oct 23, 2018, 2:04:03 PM10/23/18
to foam-framework-discuss
When I call this ‘model.create()’ ,  but if the model has a Reference type property, it’s shown as an empty list.
Message has been deleted

min...@nanopay.net

unread,
Oct 23, 2018, 2:09:45 PM10/23/18
to foam-framework-discuss
What I did is..



I have these models - named A, B

Whenever I pass an object as a choice view event on A, then B.create() is called in the one of the A’s ‘FObjectProperty’ below




{
      class: 'FObjectProperty',
      of: this.javaType,
      name: 'objectType',
      label: 'Object Value',
      documentation: 'Parameters input value (Object Type Parameters)',
      factory: function() {
        var model = this.lookup(this.javaType.toString(), true);

        
          return model.create();
      }
    }

min...@nanopay.net

unread,
Oct 23, 2018, 2:10:25 PM10/23/18
to foam-framework-discuss
by mcarcaso  : 
So you're creating the model without a context so it'll use the global context which won't have any of the nspec services so any references in the model won't be able to get looked up
you could try `return model.create(null, this.__context__);` and see if that helps.
It’s a subtle thing that’s easy to forget. When creating something from a model you require the context of the model is automatically passed in but since you’re looking up the model you have to be a bit more mindful of the context.



On Tuesday, October 23, 2018 at 2:04:03 PM UTC-4, min...@nanopay.net wrote:

Adam Van Ymeren

unread,
Oct 23, 2018, 6:59:23 PM10/23/18
to min...@nanopay.net, foam-framework-discuss

As a follow up its to pass "this" as the second parameter instead of
"this.__context__"

So "model.create(null, this);" as it lets FOAM optimize a few things
under the hood in certain situations.

min...@nanopay.net writes:

> by mcarcaso :
> So you're creating the model without a context so it'll use the global
> context which won't have any of the nspec services so any references in the
> model won't be able to get looked up
> you could try `return model.create(null, this.__context__);` and see if
> that helps.
> It’s a subtle thing that’s easy to forget. When creating something from a
> model you require the context of the model is automatically passed in but
> since you’re looking up the model you have to be a bit more mindful of the
> context.
>
>
>
> On Tuesday, October 23, 2018 at 2:04:03 PM UTC-4, min...@nanopay.net wrote:
>>
Reply all
Reply to author
Forward
0 new messages