I am getting the following error in my Apploader. I don't know from where ConfigurationComponents is getting included in my code.
Error:(63, 7) class AppComponents inherits conflicting members:
method configuration in class BuiltInComponentsFromContext of type => play.api.Configuration and
method configuration in trait ConfigurationComponents of type ()play.api.Configuration
(Note: this can be resolved by declaring an override in class AppComponents.);
other members with override errors are: environment, applicationLifecycle, httpErrorHandler, fileMimeTypes
class AppComponents (context: Context) extends BuiltInComponentsFromContext(context)
Also, I dont understand the statement in the above error other members with override errors are: environment, applicationLifecycle, httpErrorHandler, fileMimeTypes
Snippet of my Apploader.scala code is
class AppComponents (context: Context) extends BuiltInComponentsFromContext(context)
with CassandraRepositoryComponents
with HttpFiltersComponents
with AssetsComponents
with CSRFComponents { ... }
I also notice that the different use of () and => in the statement => play.api.Configuration and method configuration in trait ConfigurationComponents of type ()play.api.Configuration
The issue got resolved when I removed import play.controllers.AssetsComponents. It seems I included this file by mistake which caused conflicts.
Related
I am getting the following error when I deploy a Vaadin 14 web application on Tomcat 9.0.46
Caused by: com.vaadin.flow.server.AmbiguousRouteConfigurationException: Navigation targets must have unique routes, found navigation targets 'xx.SForceFindPaymentView' and 'xx.SForceFindPaymentView' with parameter have the same route.
The class is defined as follows:
#Route(value = "sf-find-payment", layout = MainLayout.class)
#PageTitle("Find Payment")
public class SForceFindPaymentView extends FindPaymentView implements HasUrlParameter<String>, IAAPConnection {
And the parent class is defined as follows:
#PageTitle("Find Payment")
#Route(value = "find-payment", layout = MainLayout.class)
public class FindPaymentView extends VerticalLayout implements HasUrlParameter<String>, IAAPConnection {
The only difference between the parent class and the derived class is the way the parameters are handled in the setParameter() method.
The setParameter method has the following signature
#Override
public void setParameter(final BeforeEvent event, #OptionalParameter final String parameter) {
The odd thing is if I delete the war and redeploy the exact same war file the problem goes away and the application installs successfully.
I tried removing the #OptionalParameter annotation but that made no difference. The error message seems to see two routes for the same class, one with a parameter and one without so I thought if I removed the #OptionalParameter in both the parent and derived class, that might help but it made no difference.
Grateful for any suggestions.
I am injecting service from a super abstract class into our sub classes.
This works fine, except for the Store service.
What I'm doing is the following:
Super Class:
export abstract class GenericClass {
translate: TranslateService;
cdr: ChangeDetectorRef;
someService: SomeService;
otherService: OtherService;
anotherService: AnotherService;
constructor(injector: Injector){
this.translate = injector.get(TranslateService);
this.cdr = injector.get(ChangeDetectorRef);
this.someService= injector.get(SomeService);
this.otherService = injector.get(OtherService);
this.anotherService= injector.get(AnotherService);
}
}
Sub-Class (Component):
export class SubClassComponent {
constructor(injector: Injector){
super(injector);
}
}
This works fine, but with store it doesn't.
When I add Store the same way to the super class, e.g:
Super Class:
export abstract class GenericClass {
...
store: Store<AppState>;
constructor(injector: Injector){
...
this.store = injector.get(Store<AppState>);
}
}
In this case I get the following Error:
ERROR in fox-generic-form.ts(45,30): error TS2348: Value of type 'typeof Store' is not callable. Did you mean to include 'new'?
I tried this with as it suggests in the error:
this.store = injector.get(new Store<AppState>);
How ever in this case I get an error on required arguments in the constructor of Store, and after checking it does require 3 different arguments:
store.d.ts:
constructor(state$: StateObservable, actionsObserver: ActionsSubject, reducerManager: ReducerManager);
I've been searching for this for a while on the net and I can't find a solution, I did find testing scenarios, but those are not what I need for this case of components super-class & Injector.
Any one has an idea of how to use Store with Injector from a super class?
Or how I use these 3 arguments (state$: StateObservable, actionsObserver: ActionsSubject, reducerManager: ReducerManager) with Store?
Should work if you would do injector.get(Store), without the generic type.
I have Android development background and I'm learning Flutter.
In Android it's a common practice to use Kotlin sealed classes to return a state from ViewModel e.g.
sealed class MyState {
data class Success(val data: List<MyObject>) : MyState()
data class Error(val error: String) : MyState()
}
I want to use similar pattern in Flutter and return a State object from the BLOC class. What is the best way to achieve the same in Flutter?
Such use case would be done using named factory constructors.
It requires a lot more code, but the behavior is the same.
class MyState {
MyState._();
factory MyState.success(String foo) = MySuccessState;
factory MyState.error(String foo) = MyErrorState;
}
class MyErrorState extends MyState {
MyErrorState(this.msg): super._();
final String msg;
}
class MySuccessState extends MyState {
MySuccessState(this.value): super._();
final String value;
}
RĂ©mi Rousselet's answer is somehow correct but as sindrenm mentioned:
Unfortunately, this isn't the same thing. Kotlin sealed classes guarantee that there are no other implementations of the given class outside of the file they're defined in. That means you can exhaust when statements (switch in Dart) by just providing all possible alternatives as cases, not having to think about potential sub-classes elsewhere
While there is an active discussion about this feature on dart language: Algebraic Data Types, but there is some libraries that can help you implement this behavior. You can use this libraries:
Sealed Unions
Super Enum
Sealed Class
And if you are using BLoC library you can use this lib:
Sealed Flutter Bloc
I hope that dart language add this feature ASAP
Soon Dart is going to support sealed classes.
GitHub Code: source
sealed class Either {}
class Left extends Either {}
class Right extends Either {}
You can now test the sealed class
test(Either either) {
switch (either) {
case Left(): print('Left');
case Right(): print('Right');
}
}
Here is the package for the Sealed Classes/Unions in Flutter
Freezed
This Package provided the features to deal with Data Classes, Sealed Class in Dart/Flutter
Here is the link which explains the beast use of freezed package in Flutter
Use of Freezed Package in Flutter/Dart
Mixin Problem
Without the use of a mixin, the following code in the default_project works:
abstract class ProjectGen extends ConceptEntity<Project> {
With the use of the ConceptEntity mixin, there is a problem, without an error message, with the exit code=139 on Ubuntu 14.04 LTS, and the exit code=-1073741819 on Windows 7.
abstract class ProjectGen extends Object with ConceptEntity<Project> {
The restrictions on the ConceptEntity mixin in dartling are fulfilled:
ConceptEntity does not declare a constructor.
Its superclass is Object.
It does not ontain calls to super.
default_project
https://github.com/dzenanr/default_project
ProjectGen in lib/gen/default/project/projects.dart
dartling
https://github.com/dzenanr/dartling
ConceptEntity in lib/domain/model/entity.dart
class ConceptEntity<E extends ConceptEntity<E>> implements EntityApi {
I am seeing this error in my console:
Exception: InvalidStateError: Internal Dartium Exception
PolymerDeclaration.registerType (package:polymer/src/declaration.dart:241:22)
PolymerDeclaration.register (package:polymer/src/declaration.dart:175:17)
PolymerDeclaration._register (package:polymer/src/declaration.dart:114:13)
PolymerDeclaration.registerWhenReady (package:polymer/src/declaration.dart:109:14)
_notifyType (package:polymer/src/declaration.dart:514:49)
Polymer.register (package:polymer/src/instance.dart:64:16)
_loadLibrary (package:polymer/src/loader.dart:177:25)
I have code like this:
#CustomTag('person-tag')
class PersonTag extends PolymerElement {
And my HTML is like this:
<polymer-element name="person-tag" extends="li">
Why am I getting this Internal Dartium Exception error from registerType ?
You are seeing this error because your HTML says extends="li" but the Dart code only extends PolymerElement.
If you use an extends attribute in your polymer-element, then your Dart class must also extend the same kind of element.
To fix the problem in the question, change the Dart class:
#CustomTag('person-tag')
class PersonTag extends LIElement with Polymer, Observable {
Now PersonTag really does extend <li>.