We’re trying to implement the MVP pattern using a custom Vaadin widget. In order to avoid duplicating interfaces, our first approach was making the Vaadin server-side component to implement the view interface.
But when I compile the widgetset, I got the following error:
Widgetset does not contain implementation for com.enterprise.designer.vaadin.widget.workflow.Workflow. Check its #ClientWidget mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions. Unrendered UIDL:
com.enterprise.designer.vaadin.widget.workflow.Workflow(NO CLIENT IMPLEMENTATION FOUND) id=PID2 caption=Editorongo actionCount=1 workflowAction_0_id=1 workflowAction_0_name=addStartNode workflowAction_0_y=75.0 workflowAction_0_x=50.0
If I comment the interface (and the imports) it works ok, even if I uncomment them after building the widgetset. The code (with import/implements commented) looks like the following:
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
//import com.enterprise.designer.workflow.presenter.WorkflowDrawArea;
//import com.enterprise.platform.i18n.api.Language;
//import com.enterprise.platform.mvp.api.ViewEventNotifier;
//import com.enterprise.platform.r13n.api.Region;
//import com.enterprise.vaadin.mvp.VaadinView;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
#com.vaadin.ui.ClientWidget(com.enterprise.designer.vaadin.widget.workflow.client.ui.VWorkflow.class)
public class Workflow extends AbstractComponent
//implements WorkflowDrawArea.Display, VaadinView
{
. . .
The log doesn’t show any error (except for sources for validation api, but the same errors are shown when I comment the interface and it works ok). I tried both compiling form Eclipse plugin and from command line.
Any idea? Thanks in advance.
Crosspost: https://vaadin.com/forum/-/message_boards/view_message/817539
I found a workaround. If I create an intermediate class for the widget, it compiles OK. And creating a sub class of that widget and using it form Vaadin application works ok, so I can make such subclass implementing the interface from an external project:
________________________________
|com.vaadin.ui.AbstractComponent |
|________________________________|
^
/|\
|
|
____________________________________________
|com.enterprise.designer.vaadin.widget.Dummy |
|--------------------------------------------|
| <#com.vaadin.ui.ClientWidget > |
|____________________________________________|
^
/|\ ______________________________________
| | com.enterprise.vaadin.mvp.VaadinView |
| |______________________________________|
| ^
| /|\
| | implements
| |
_________________________________________________________
| com.enterprise.designer.vaadin.widget.workflow.Workflow |
|_________________________________________________________|
|
| ________________________
| | com.vaadin.Application |
|uses |________________________|
| ^
| /|\
| |
| |
_____________________________________________________
| com.enterprise.designer.vaadin.widget.MyApplication |
|_____________________________________________________|
In this diagram, Dummy is the Vaadin widget (which implements the paintContent method) and Workflow is the subclass implementing the interface form other project (VaadinView). The Vaadin application (MyApplication) uses Worflow class directly.
However, it would be nice solving the problem without this workaround :)
If you get some think like "NO CLIENT IMPLEMENTATION FOUND", it mean during widgetset compilations were some errors. I have same problem, complication was OK, but no effect for application. After debugging I found problem, in my app was used drools library and inside this lib was compiler with same name as in gwt-dev libraries and during widgetset compilation compiler takes wrong class to compile widgetset and as result widgetset compile with errors. Drools library in app should be included all time and only way to solve this problem was compile widgetset manually. If you use Eclipse you should add in module new "Java application" with:
Project: {your project}
Main class: com.google.gwt.dev.Compiler
Program arguments: -gen {your project location (like C:\workspace**)}\target.generated -logLevel INFO -style OBF -war {your project location}\src\main\webapp\VAADIN\widgetsets -localWorkers 4 {your project custom widgetset location in java packages(like com.***.widgetset.CustomWidgetset)}
After this in project class path in "Libraries" add external jar gwt-dev-2.3.0.jar(or other version) on top of all libraries, this needed only to be sure that compiler take right java class and in "Source" change for all available folder field "Included:*/.java" to "Included:(All)"
It should help solve your problem.
Related
Hi I am using scala with Junit.
Every time I want to generate a test class CTRL + SHIFT + T it always generates a java class and I always need to reformat the class and the code inside it.
How can I implement this feature in Intellij?
I'd like to generate a test class like this:
package combiner.impl
import org.junit.Test;
import org.junit.Assert._
class NextploraWeboDataFrameCombinerImplTest {
#Test
def combineDataFrames() {
}
}
While generating the test you should select ScalaTest testing library. The default template of generated file can be changed in Preferences | Editor | File and Code Templates | Code | ScalaTest Class.
Here is my file structure
component.ts
/services
first.service.ts
second.service.ts
index.ts
index.ts
export * from './first.service';
export * from './second.service';
From component.ts, I wish to use a service. This is how my IDE (PhpStorm/WebStorm) automatically generates the import code
import { FirstService } from './services/first.service'
Of course this works. But I would prefer:
import { FirstService } from './services/index'
Can this be tweaked through a setting?
Update
I've changed my mind about using barrel files all over my Angular project after reading this thread about the subject. I would recommend reading it to anyone considering doing the same thing.
In Settings | Editor | Code Style | TypeScript | Imports, enable Use directory import (Node-style module resolution) . When this checkbox is selected, import statements are generated in compliance with the Node.js module resolution strategy
I am trying to build the java projects with gradle and my project structure something like below:
Root
|
|----Child
| |
| Child1 (build.gradle)
|
|
|----Child12
| |
| Child111
| |
| Child222(build.gradle)
|
settings.gradle
As you can see, the project structure, here I am doing the gradle eclipse build for all the projects (Child1, Child222) in a single attempt by modifying settings.gradle and including the child projects something like below:
include 'Child/Child1'
include 'Child12/Child111/Child222'
Build is fine with that.
Whereas, while importing the projects(Child1, Child222) into eclipse, I am getting the following error:
Creation Problems
Path for project must have only one segment.
Because, in the Child1 .project file
<projectDescription>
<name>Root/Child1</name>
<projectDescription>
project name appearing as Root/Child1, instead of Child1.
Is there anyway, with that I can import the projects into the eclipse?
I got it, I changed settings.gradle file like below:
include 'Child:Child1'
include 'Child12:Child111:Child222'
It's working fine for me.
Inside a GWT application we have a "shared" package which contains, as its name implies, objects shared between client-side and server-side code.
We have a multi-module maven project:
+ server
| |
| + businessLogicPackage
|
+ gwt
|
+ client
|
+ server
| |
| + converter
| |
| + rpc
|
+ shared
Each time I need to reuse a shared object in the server module, I need to convert the shared object using some converter located in gwt/server/converter.
I tried to use inheritance and have the shared objects inherit classes from the server/businessLogicPackage, thinking I could get away with a simple casting operation. This produces an error. Obviously GWT can't compile the sources from an external module.
> No source code is available for type server.businessLogicPackage.x; did you forget to inherit a required module ?
Knowing that:
We are manipulating a huge quantity of "shared" objects
I want my business logic to remain in a separate module so I can reuse it elsewhere
I don't want to write all those converters
Could anyone share some best practice / alternative with me ? What's trendy now in 2014 ?
Your problem is to use classes from gwt module and shared package in server module without manual conversion ?
You could simply create a third module named shared for example that contains the classes used by gwt client side and server module.
gwt and server modules depend on this new shared module.
For GWT to have access to the source, you add a MySharedModuleName.gwt.xml to the new module and add its package as source. In your GWT module, add an inherit tag for MySharedModuleName.
And then, GWT needs access to the sources. You can add in your gwt module pom a dependency to the sources jar if you create it : <classifier>sources</classifier>. Or add the goal gwt:resources in your shared module to include the sources inside the jar.
Finally I added the sources to the compiled jar, so adding only one dependency (without classifier) to the POM is enough. My GWT-module inherits from the GWT-module of the "shared" maven-module as proposed by Nicolas Morel.
<build>
<resources>
<resource>
<directory>${project.build.sourceDirectory}</directory>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
It's been about 5 hrs since I decided to use JSR 303 Bean Validation in my GWT project and I gotta say I can't even express (politely) how deeply unsatisfied I am with lame documentation on the subject on Google's website.
I really hope you guys can help me.
I followed this blog post to add client-side bean validation to my project. Unfortunately it worked only once and threw an exception in runtime saying that I need to add Hibernate Validation sources to class path. I fixed that and decided to remassage my dependencies a little too (biggest mistake of my life) but I couldn't make it work ever again.
I can't play with Validation sample from GWT SDK either because it's uncompilable because it has two implementations of class ServerValidator. Weird.
So to simplify my question I created dummy GWT application using project wizard of IntelliJ IDEA.
I added following elements to module xml:
<inherits name="org.hibernate.validator.HibernateValidator"/>
<replace-with class="com.mySampleApplication.client.ClientValidatorFactory">
<when-type-is class="javax.validation.ValidatorFactory"/>
</replace-with>
Created ClientValidatorFactory:
package com.mySampleApplication.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.validation.client.AbstractGwtValidatorFactory;
import com.google.gwt.validation.client.GwtValidation;
import com.google.gwt.validation.client.impl.AbstractGwtValidator;
import javax.validation.Validator;
import javax.validation.groups.Default;
public class ClientValidatorFactory extends AbstractGwtValidatorFactory
{
#GwtValidation(value = {Organization.class}, groups = {Default.class, ClientGroup.class})
public interface GwtValidator extends Validator
{
}
#Override
public AbstractGwtValidator createValidator()
{
return GWT.create(GwtValidator.class);
}
}
And in onModuleLoad() method I added this single line which causes compiler to blow up
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
And finally I used following jars which I copied from Validation sample of GWT SDK.
hibernate-validator-4.1.0.Final-sources.jar
hibernate-validator-4.1.0.Final.jar
log4j-1.2.16.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
validation-api-1.0.0.GA-sources.jar
validation-api-1.0.0.GA.jar
But when I compile my project it gives following meaningless error:
In detailed GWT compiler log I see this:
Loaded 2315 units from persistent store.
Found 2282 cached units. Used 2282 / 2282 units from cache.
Added 0 units to persistent cache.
Validating newly compiled units
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/engine/ConstraintViolationImpl_CustomFieldSerializer.java'
Line 33: No source code is available for type org.hibernate.validator.engine.ConstraintViolationImpl<T>; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/engine/ValidationSupport.java'
Line 43: No source code is available for type org.hibernate.validator.engine.ConstraintViolationImpl<T>; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/EmailValidator.java'
Line 25: No source code is available for type org.hibernate.validator.constraints.Email; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/ScriptAssertValidator.java'
Line 26: No source code is available for type org.hibernate.validator.constraints.Email; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/URLValidator.java'
Line 26: No source code is available for type org.hibernate.validator.constraints.URL; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/engine/PathImpl.java'
Line 72: No source code is available for type org.hibernate.validator.engine.NodeImpl; did you forget to inherit a required module?
Why can't it find classses? I have hibernate-validator-4.1.0.Final-sources.jar in my classpath.
Any thoughts ?
I uploaded my project here if you guys want to play with it.
Case closed, guys. Error was caused by lack of hibernate validation sources in classpath because of bug in IntelliJ IDEA. Details are here.