SAPUI5 error changing value in input with oData model - sap-fiori

I have an oData model in my application, this is one of the elements, which is binded to the view:
{
"SO_Id":1,
"Customer_No":"1",
"System_Status":false,
"User_Status":false,
"SO_Description":"drive seamless niches"
}
This is how I'm binding it to the view:
this.getView().bindElement({
path: "/SO_Info('1')",
model: "SO_List"
});
And I'm binding the properties like this (XML):
<Input value="{SO_List>SO_Description}"/>
It's displayed well but everytime I modify this input I get the following error in the chrome inspector:
ManagedObject-dbg.js:3093 Uncaught TypeError: Cannot read property 'name' of undefined
at constructor.r._resolveGroup (eval at evalModuleStr (jquery.sap.global-dbg.js:3395), :2630:233)
at constructor.r.setProperty (eval at evalModuleStr (jquery.sap.global-dbg.js:3395), :2658:1241)
at constructor.O.setValue (eval at evalModuleStr (jquery.sap.global-dbg.js:3395), :2120:106)
at constructor.P.setExternalValue (PropertyBinding-dbg.js:131)
at f.j.updateModelProperty (ManagedObject-dbg.js:3050)
at f.j.setProperty (ManagedObject-dbg.js:1067)
at f.a.setProperty (eval at evalModuleStr (jquery.sap.global-dbg.js:3395), :2293:115)
at f.a.setValue (eval at evalModuleStr (jquery.sap.global-dbg.js:3395), :2307:308)
at f.h.setValue (eval at evalModuleStr (jquery.sap.global-dbg.js:3395), :2261:73)
at f.a.onChange (eval at evalModuleStr (jquery.sap.global-dbg.js:3395), :2283:178)
However, the value is correctly changed in the model. Why I'm still getting an error?

Related

What is the correct syntax to Verify a mock logger call in F#?

I'm unit testing an F# function that calls ILogger.LogInformation. I'm attempting to verify that the function made the call as expected. Here is the verify statement I have so far:
let mockLogger = Mock<ILogger<MyFunction>>()
// call function that uses ILogger.LogInformation.
mockLogger.Verify(fun x -> x.Log(
LogLevel.Information,
It.IsAny<EventId>(),
It.IsAny(),
It.IsAny<Exception>(),
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once)
When I try this I get the following error:
System.ArgumentException: Expression of type 'System.Void' cannot be used for constructor parameter of type 'Microsoft.FSharp.Core.Unit' (Parameter 'a...
System.ArgumentException
Expression of type 'System.Void' cannot be used for constructor parameter of type 'Microsoft.FSharp.Core.Unit' (Parameter 'arguments[0]')
at System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
at System.Dynamic.Utils.ExpressionUtils.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection`1& arguments, String methodParamName)
at System.Linq.Expressions.Expression.New(ConstructorInfo constructor, IEnumerable`1 arguments)
at Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.ConvExprToLinqInContext(ConvEnv env, FSharpExpr inp) in D:\a\_work\1\s\src\fsharp\FSharp.Core\Linq.fs:line 616
at Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.ConvExprToLinqInContext(ConvEnv env, FSharpExpr inp) in D:\a\_work\1\s\src\fsharp\FSharp.Core\Linq.fs:line 599
at Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.QuotationToLambdaExpression[T](FSharpExpr`1 e) in D:\a\_work\1\s\src\fsharp\FSharp.Core\Linq.fs:line 698
The exception is thrown when it calls the Verify method. How can I change this to get past this error?
I don't know much about Moq, but I think part of the problem here is that you need another pair of parentheses around your lambda to separate it from the Times.Once argument. Try something like this instead:
mockLogger.Verify(
(fun x -> x.Log(
LogLevel.Information,
It.IsAny<EventId>(),
It.IsAny(),
It.IsAny<Exception>(),
It.IsAny<Func<It.IsAnyType, Exception, string>>())),
Times.Once)
Without the extra parens, your lambda returns a tuple, so your code is currently calling this method:
Verify: expression: Expression<Action<'T>> -> unit
But I think you want to call this method instead:
Verify: expression: Expression<Action<'T>> * times: Times -> unit
Here's a simpler example that should make the difference clear:
Verify(fun x -> x, 1) // call Verify with a single argument (a lambda that returns a tuple)
Verify((fun x -> x), 1) // call Verify with two arguments (a lambda and the literal value 1)

Use imported Algebraic Data Type in eval

I'm using the eval function to evaluate an abstract list pattern against a list and it keeps coming up with an Undeclared Variable error. Below is included a small reproducible example.
module PuzzleScript::Test::Engine::EvalExample
import util::Eval;
import IO;
data Animal = dog() | cat();
void main(){
bool boolean = [*_, cat(), *_] := [dog(), cat()];
if (boolean) println("True 1");
println("[*_, cat(), *_] := [dog(), cat()];");
Result[bool] re = eval(#bool, "[*_, cat(), *_] := [dog(), cat()];");
if (re.val) println("True 2");
}
Which generates the following error
Rascal Version: 0.18.2, see |release-notes://0.18.2|
rascal>import PuzzleScript::Test::Engine::EvalExample;
ok
rascal>main()
True 1
[*_, cat(), *_] := [dog(), cat()];
|std:///util/Eval.rsc|(622,1030,<23,0>,<60,95>): StaticError(
"Undeclared variable: dog\nAdvice: |http://tutor.rascal-mpl.org/Errors/Static/UndeclaredVariable/UndeclaredVariable.html|",
|eval:///?command=[*_,%2520cat(),%2520*_]%20:=%20[dog(),%2520cat()];|(20,3,<1,20>,<1,23>))
at $evalinstance$0(|main://$evalinstance$0|)
at *** somewhere ***(|std:///util/Eval.rsc|(622,1030,<23,0>,<60,95>))
at eval(|project://AutomatedPuzzleScript/src/PuzzleScript/Test/Engine/EvalExample.rsc|(288,36,<13,31>,<13,67>))
at $root$(|prompt:///|(0,47,<1,0>,<1,47>)ok
rascal>
As far as I understand, the error happens when it tries to evaluate the dog constructor on the right side of the pattern. I'm looking for a solution that would allow me to make the environment available to the eval function without having to re-import everything in the eval. The reason I'm doing it this way is that I haven't found a way to dynamically generate abstract patterns, if there's a way I'd be glad to hear about it since it is the root of my current issue.
eval is not an often used function in Rascal; do you really need to dynamically create patterns?
there is the node pattern: (str name)() which in this case would match any constructor with no arguments
the real answer is that if you do import the right modules in the call to eval those modules will be cached by the interpreter which is used by the eval function
so that would not be slow
however, module reloading is not well-supported and you might have to restart the shell to get a fresh version into the eval evaluator.

illegal use of variable in erlang map

How can we create a map inside a function, then pass it as an argument to another function in erlang?
I was trying it in the following code:
-module(maps_all).
-export([test_my_map/2]).
test_my_map(K, V) ->
io:fwrite('~w ~w ~n done.',[K, V]),
nested_func(#{K => V}).
nested_func(MyMap) ->
io:fwrite('In nested function as map ~n ~w',[MyMap]).
This throws the error:
31> c(maps_all).
maps_all.erl:6: illegal use of variable 'K' in map
error
Also, this was added in Erlang 18 RC
For now (Erlang R17) there is no way to use variable directly in map expression.
You can achieve this with maps: new and put:
nested_func(maps:put(K, V, maps:new()))

grails shell and closures

Trying to run the following command in grails console:
Family.where() {password =~ "%qw%"}
A very simple query on a stored object. I'm getting back:
ERROR groovy.lang.MissingMethodException:
No signature of method: com.babyboom.Family.where() is applicable for argument types: (groovysh_evaluate$_run_closure1) values: [groovysh_evaluate$_run_closure1#34356294]
Possible solutions: where(groovy.lang.Closure), merge(), every(), grep(), merge(com.babyboom.Family), merge(java.util.Map)
I understand that the closure I created is a different than the expected one.
Couple of questions:
Why there are 2 types of closures ?
Found Why am I getting a "No signature of method"" error when running the closure recursion example in the Groovy shell? tried it and it didn't help, still getting the same error
It works well when using grails console
This is likely a classloader bug with the grails shell. To reproduce, add dependency to BuildConfig.gradle:
runtime "org.grails:grails-datastore-simple:3.1.2.RELEASE"
then run
import org.grails.datastore.mapping.simple.SimpleMapDatastore
import org.grails.datastore.gorm.GormStaticApi
class Bar {}
class Foo extends GormStaticApi<Bar> {
Foo() {
super(Bar, new SimpleMapDatastore(), [], null)
}
}
def f = new Foo()
In grails console yields:
Result: Foo#699c0395
In grails shell yields:
groovy:000> def f = new Foo()
ERROR java.lang.LinkageError:
loader constraint violation: when resolving overridden method "Foo.$getStaticMetaClass()Lgroovy/lang/MetaClass;" the class loader (instance of groovy/lang/GroovyClassLoader$InnerLoader) of the current class, Foo, and its superclass loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader), have different Class objects for the type ()Lgroovy/lang/MetaClass; used in the signature

Konacha - stubing and ember

konocha 3.2.3, rails 4.0.2. I want to stub didInsetElement method in my Ember View
I use
sinon.stub(App.ToyBoxView, "didInsertElement")
but I get
TypeError: Attempted to wrap undefined property didInsertElement as function
at Object.wrapMethod (http://localhost:3500/assets/sinon.js?body=1:522:23)
at Object.stub (http://localhost:3500/assets/sinon.js?body=1:1662:22)
at Context.<anonymous> (http://localhost:3500/assets/aptp/routes/application_route_spec.js?body=1:12:22)
at invoke (http://localhost:3500/assets/ember-mocha-adapter.js?body=1:60:8)
at Context.<anonymous> (http://localhost:3500/assets/ember-mocha-adapter.js?body=1:52:11)
at Hook.Runnable.run (http://localhost:3500/assets/mocha.js:4319:15)
at next (http://localhost:3500/assets/mocha.js:4609:10)
at http://localhost:3500/assets/mocha.js:4626:5
at timeslice (http://localhost:3500/assets/mocha.js:5733:27)
my View:
App.ToyBoxView = Ember.View.extend Ember.ViewTargetActionSupport,
properties..
didInsertElement: ->
console.log "Something"
You need to define didInsertElement on App.ToyBoxView and it only exists on instances, not on the type definition itself.

Resources