Vaadin 23 cannot handle #Viewport annotation - vaadin

I have upgraded a Vaadin 14 app to Vaadin 23.1.3 and now it refuses to start with this error message:
Found app shell configuration annotations in non `AppShellConfigurator` classes.
Please create a custom class implementing `AppShellConfigurator` and move the following annotations to it:
- #Viewport from my.custom.class
However, my class does not have this annotation, it only extends an abstract class with this annoation. But I cannot change the abstract class, because it is a third party lib. So is there a way to tell Vaadin to just ignore this annotation and use the one I provided in the AppShellConfigurator class? Or any other way to get this app to start short of ditching the 3rd party library?

If the problematic class is just an abstract one, You can try creating a custom class with exactly the same structure and name but without the Viewport annotation. Then just import your custom class instead of the one from external package.
For example while using the AppLayoutRouterLayout class from com.github.appreciated:app-layout-addon package You could replace its usage with following class:
import com.github.appreciated.app.layout.component.applayout.AppLayout;
import com.github.appreciated.app.layout.component.router.AppLayoutRouterLayoutBase;
public abstract class AppLayoutRouterLayout<T extends AppLayout> extends AppLayoutRouterLayoutBase<T> {
}

Related

Is there an interface in Vaadin14 to create custom Component instead of extending Component class?

I want to create a custom component in Vaadin. But instead of extending it from a Component class I tried as below
public class MyMapComponent extends LMap implements Component {
}
I get error as
getId()' in 'com.vaadin.ui.AbstractComponent' clashes with 'getId()' in 'com.vaadin.flow.component.Component'; attempting to use incompatible return type.
How to resolve this error? What is the best way to achieve it?
Am I going in correct direction? I want add the LMap as component in Vaadin 14. Since v-leaflet does not support above Vaadin 8, I am trying MPR for which I am trying to add LMap as component in vaadin flow.
In Vaadin 8 and older, Component is an interface and AbstractComponent is an abstract class implementing that interface. Creating your own completely custom implement of the Component interface without using AbstractComponent as the base class is rarely feasible because of all the internal bookkeeping that is needed.
In Vaadin 10 and newer, this is taken one step further. There is no separate interface with only one viable implementation but instead, Component itself is an abstract class.
Furthermore, it seems like you're trying to mix the Vaadin 8 AbstractComponent and the Vaadin 14 Component base types in the same class hierarchy. This cannot work since they are explicitly incompatible with each other.
The v-leaflet add-on is not compatible with newer version of Vaadin, but the author of that add-on recommends using https://vaadin.com/directory/component/leafletmap-for-vaadin instead.

Dart - Hide method from parent class / call private method from parent class

I have a class that extends another. The parent class is not intended to be used directly by the API rather it implements basic methods that are helpers for child classes.
When I use the child class in a program I can see all method from said class but also the one from the parent class that are not intended to be called directly, they exist to be called by the methods of the child class.
I tried to make parents method private. This would work I believe as long as parent and child are declared in the same library. But I have an issue with the "library" notion. I understand part/part of are somewhat depreciated, and I want the parent class to be in a specific file. I can't figure a way to do it with import/export.
Is there a way to either hide a public method from the parent class from all child classes usage or to make a private method from the parent class callable from all child classes ?
Best regards ;
Exemple:
myLib.dart
export mainClass.dart;
mainClass.dar
import baseClass.dart;
class MainClass extends BaseClass {
publicFunc() => ... //Can't call _hiddenFunc, can call wantToHideFunc()
}
In a second file (for code reusability purposes)
class MainClass extends BaseClass {
_hiddenFunc() => ...
wantToHideFunc() => ...
}
Using myLib public API
import myLib.dart
main() {
class = Class();
class.publicFunc(); //Intended
class.wantToHideFunc() //Wants to avoid...
}
Dart does not have protected access like Java or C#.
You can't hide a public member, you can't access a private member from a different library, and there is no third option.
It sounds like you want members of the superclass which can be invoked only from subclasses, not from outside of the object. That's what's called protected in, e.g., Java, and Dart does not have anything similar to that.
The only level of privacy in Dart is library-private, which is chosen by starting the name with a _.
The reason that Dart has this design is that it was originally a very dynamic language. You can preform "dynamic invocations" on a value with static type dynamic, say dynVal.foo(42) and it will call the method of that name.
To make a name unreachable, it needed to be safe from dynamic invocation as well. Because of that, Dart privacy does not care where the code doing the invocation is, it only cares whether you know the name - and library private names are considered different names depending on which library they're from.
Using part is not discouraged for situations where it actually serves a purpose. If you can put the part into a library of its own, that's better because it allows it to have its own privacy and imports, but if you need the classes to share privacy, using part files to split up a large file is perfectly reasonable. It's a tool, there is nothing wrong with using it when it's the right tool for the job. A library is often a better tool for modularity, but not always.
Now, there is a hack you can use:
// Declare the base and provide extensions for "protected" members:
abstract class Base {
int get _someHiddenStuff => 42;
int get somePublicStuff => 37;
}
extension ProtectedBase on Base {
int get someHiddenStuff => _someHiddenStuff;
}
Then import that in another library and do:
import "base.dart";
export "base.dart" hide ProtectedBase;
class SubClass extends Base {
int doSomething => someHiddenStuff + somePublicStuff;
}
Then anyone importing "subclass.dart" will also get a version of Base, but they won't get the ProtectedBase extensions. Hiding the extensions from your package's public API will allow yourself to use it, but prevent your package's users from seeing the helper extensions.
(This is likely highly over-engineered, but it's an option. It's the evolution of the hack of having static/top-level helper functions that you don't export.)

Import class from an inplacePlugin to another inplacePlugin Grails

I need use a domain class define in one inplacePlugin to a controller class in another inplacePlugin inside my app, but when I try to define the class IDE "cannot resolve the symbol". AutorDef domain class I define public in my app. What i need to do for reselve this issue?
def autor = AutorDef.findAll()
I already know how can do it that, it is very simple, (of course after a few day of deep thinking and search). Here is the solution.
In BuildConfig.groovy inside the inplace plugin where we need import the domain class from other inplace plugin we add next code,
grails.plugin.location.'common'="../sdl-common"
We add this code directly below
grails.project.test.reports.dir = "target/test-reports"
The import code before equals
grails.plugin.location.'common'
is the name use for import the plugin data(domain class, etc) and
"../sdl-common"
is the route to inplace plugin, and when we need to import the data in our classes, or controllers, we only need add
import common.*
in the part where we import hte packages.

Can I use JAXRS annotations(for example #Produces) in an interface class in Grails

I am trying to create an interface class in Grails and implement that in a resource. I wanted to use the #Produces annotation in the interface class and use(implement) that in my resources class. I created my interface in src/groovy. But, it doesn't like the #Produces annotation, gives syntax error. My interface is something like this:
import javax.ws.rs.Produces
public interface annotationInterface {
#Produces(['application/xml','application/json'])
}
Could anyone please tell me what I am doing wrong?
thanks
Your annotation does not annotate anything, that is why the compiler complains. javax.ws.rs.Produces can annotate methods or classes, so in your case I would think that
import javax.ws.rs.Produces
#Produces(['application/xml','application/json'])
public interface annotationInterface {
}
I cannot say if it makes sense though, because annotations are not inherited, so any class implementing the interface won't have that annotation. So unless there is a lookup for this annotation on implementing interfaces and/or super classes it won't work.
Did you used the Jax-rs plug-in ? If not, there will be a class path problem.

ActionScript - Class Extends Object?

i've been poking around RIM's PlayBook SDK and noticed they extend Object on a lot of their classes.
are there benefits to extending Object on a custom class that would normally be unextended?
package qnx.notificationManager
{
public class Notification extends Object
{
...
If you do not specify that your class extends another class, the compiler automatically makes your class extend Object. So the answer is that you don't gain any benefit; they must have just been trying to be explicit, or maybe the code was generated through decompilation.

Resources