Hope you are rocking at your end but i need a small help.
I am working on vaadin portlet and i need to create a vaadin chart(sample).
I downloaded required jars (vaadin-charts-vaadin6-1.1.7.jar and gson-2.2.1.jar) and created
an application as give below:
#SuppressWarnings("serial")
public class UserloginchartApplication extends Application {
public void init() {
Window window = new Window();
setMainWindow(window);
Chart chart = new Chart(ChartType.BAR);
window.setModal(true);
window.addComponent(chart);
}
}
After compiling and deploying on tomcat server i am getting following error on UI
Widgetset does not contain implementation for com.vaadin.addon.charts.Chart. 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:
-Unrendered UIDL
-com.vaadin.addon.charts.Chart(NO CLIENT IMPLEMENTATION FOUND) id=PID3 height=400px width=100.0% confState={ "chart": { "type": "bar" }, "series": [], "exporting": { "enabled": false } }
Can any one tell me steps to achieve/create vaadin chart in liferay.
Thanks in Advance:
-Vikash
The problem is that the vaadin.addon.charts has some client side widget that are not included in default widge-set then you need to recompile your widget-set. If you are using maven like build toll you can do in this way:
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<configuration>
<gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<!-- <runTarget>mobilemail</runTarget> -->
<!-- We are doing "inplace" but into subdir VAADIN/widgetsets. This way
compatible with Vaadin eclipse plugin. -->
<webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets</webappDirectory>
<hostedWebapp>${basedir}/src/main/webapp/VAADIN/widgetsets</hostedWebapp>
<noServer>true</noServer>
<!-- Remove draftCompile when project is ready -->
<draftCompile>false</draftCompile>
<compileReport>true</compileReport>
<style>OBF</style>
<strict>true</strict>
<runTarget>http://localhost:8080/</runTarget>
</configuration>
<executions>
<execution>
<configuration>
<!-- if you don't specify any modules, the plugin will find them -->
<!-- <modules> <module>com.vaadin.demo.mobilemail.gwt.ColorPickerWidgetSet</module>
</modules> <gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath> -->
</configuration>
<goals>
<goal>resources</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
Related
I want to have the developer, which is defined in the pom.xml with the tag to appear in the application.yml after the build process. Somehow it is working with all attributes but developers.
This is in a Spring Boot project, I want the attributes to be filled during the build process.
This is an excerpt of the pom.xml
<description>my description</description>
<developers>
<developer>
<id>12345</id>
<name>John Doe</name>
<email>john#doe.com</email>
</developer>
</developers>
This is in application.yml
info:
description: "#project.description#"
developer: "#project.developers[0].id#"
It works for description, but not for developer. I tried many variations, e.g. ${..}, "#project.developers.0.id". Nothing seems to be working.
If anybody has an idea, I would be very grateful.
You can read the developer id or email address or any values from the pom.xml with this elegant way:
Generate the build-info.properties with the default data plus your additional data
Read values from this file easily with Spring via the BuildProperties.
pom.xml:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<developer>${project.developers[0].email}</developer>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
This will produce a build-info.properties file under the META-INF directory with the following content:
build.artifact=<artifactId-from-pom>
build.group=<groupId-from-pom>
build.name=<name-from-pom>
build.time=<build-time>
build.version=<version-from-pom>
build.developer=<email-of-the-first-developer-from-pom>
Then you can read values with Spring:
#Configuration
public class OpenApiConfiguration {
#Autowired
private BuildProperties buildProperties;
#Bean
public OpenAPI customOpenAPI()) {
return new OpenAPI().info(new Info()
.title(...)
.version(buildProperties.getVersion())
.contact(new Contact().email(buildProperties.get("developer"))));
}
}
To read:
Spring Boot Maven Plugin
BuildProperties
I hope that this will help you.
Add it on the property and use on pom and property file, example:
<properties>
<team.name>John Doe</team.name>
</properties>
Use on developer data:
<developers>
<developer>
<name>${team.name}</name>
...
And in the application use the property:
description: "#team.name#"
I have a Java web project that we deploy on the server of two different customers, 99% of the code is the same, right now I have two ApplicationBuilders, which is the class that contains the customization for each customer.
Anytime I want to deploy the new version I have to manually comment a line, build (with maven), uncomment that line, comment the other one and build again.
public class ApplicationBuilderFactory {
private static final IApplicationBuilder app;
static {
// app = new Customer1ApplicationBuilder()
app = new Customer2ApplicationBuilder();
}
}
public static IApplicationBuilder get() { return app; }
}
I want to avoid all this and the best thing would probably just create two different wars.
What's a good way to do this? I don't use (nor like) dependency injection frameworks and it seems overkill to add one just for a single class, but I may consider it.
One way to approach this is to use the Maven WAR Plugin Overlays feature.
Instead of trying to build multiple artifacts from one project (which can become unwieldy after a while), you create one base WAR project, and then a separate WAR project for each customer that only contains the components that need to be different.
Each customer specific WAR will be overlaid with the base WAR. This will make it easier to customise not only the ApplicationBuilderFactory but also specific web content and assets.
This also has the following benefits
customer specific features are guaranteed to be isolated from each other;
different customers can have their own release cycle and source control repository
it's easy to add subsequent customers
Create 2 different Maven Profiles, one for each customer, that copies a version of class ApplicationBuilderFactory to the right directory before compile stage.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy-files</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="copy files">
<copy file="${project.build.sourceDirectory}/pkg/ApplicationBuilderFactory.java.${extension}" tofile="${project.build.sourceDirectory}/pkg/ApplicationBuilderFactory.java" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>customer1</id>
<properties>
<extension>customer1</extension>
</properties>
</profile>
<profile>
<id>customer2i</id>
<properties>
<extension>customer2</extension>
</properties>
</profile>
Instead of having only one src/main/java/pkg/ApplicationBuilderFactory.java, we have:
src/main/java/pkg/ApplicationBuilderFactory.java.customer1
src/main/java/pkg/ApplicationBuilderFactory.java.customer2.
So before compiling java code, we copy one of these versions to the src/main/java/pkg/ApplicationBuilderFactory.java.
So generate 2 different .wars using 2 different profiles.
I'm using Netbeans & Maven.
I have some problems using CSS with Vaadin Toolkit.
Some basic problems...
It seems to ignore every line of my custom css, I don't know why.
In "/VAADIN/themes/touchkit" I have 4 css and scss files.
addons.scss styles.css styles.scss touchkit.scss
Basically, I wanto to change the background of a VerticalLayout or a VerticalComponentGroup.
So I've put
#import "../valo/valo.scss";
#mixin touchkit {
#include valo;
.backColorGrey {
background-color: #0FD1B1;
}
}
in touchkit.scss
and then
final VerticalLayout content = new VerticalLayout();
final VerticalComponentGroup content2 = new VerticalComponentGroup();
content.addStyleName("backColorGrey");
content2.addStyleName("backColorGrey");
Nothing happen.
I've compiled the Theme
I've tryed to put the code in the other scss files.
I've downloaded ruby to install Sass.
I've recompiled the Theme, the project, clean, clena &Build, recompile so many times ... and a lot of other action but the result is the same.
I've put this in the pom
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>j`enter code here`ava</goal>
</goals>
<configuration>
<classpathScope>compile</classpathScope>
<mainClass>com.vaadin.sass.SassCompiler</mainClass>
<arguments>
<argument>src/main/webapp/VAADIN/themes/touchkit/styles.scss</argument>
<argument>src/main/webapp/VAADIN/themes/touchkit/styles.css</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Nothing happen.
It seems to ignore any css line... but it is a so basic action!!!!
It's frustrating, it is totally a waste of time.
Frankly I hate css.
Is there any way to set this value ignoring css by java code ?
Like .setBackgroundColor ?
I have custom theme for my VAADIN application in src/main/webapp/VAADIN/themes/mytheme/ with files mytheme.scss and styles.scss.
Everything works fine when the vaadin productionMode deployment parameter is set to false in web.xml. When I set the parameter to true, suddenly Vaadin cannot find the resources for my theme and keeps complaining with:
Requested resource [/VAADIN/themes/mytheme/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder
I dont have a /WebContent directory but /webapp instead, since its a maven web-app project.
I tried putting the VAADIN folder to:
src/main/resources
src/main/webapp
src/main/webapp/WEB-INF
but nothing works for the production mode. Any suggenstions?
Thank you in advance for help.
You need to add following goal to your pom.xml, which will compile the .scss files to .css files:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>compile</classpathScope>
<mainClass>com.vaadin.sass.SassCompiler</mainClass>
<arguments>
<argument>src/main/webapp/VAADIN/themes/heijunka/styles.scss</argument>
<argument>src/main/webapp/VAADIN/themes/heijunka/styles.css</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Source: http://dev.vaadin.com/ticket/10291
#Develman already answered how to fix the problem but a bit more explanation.
When a Vaadin application is in development mode, it does the SCSS -> CSS compilation automatically when styles.css is requested and the file does not exist. In the production mode this does not happen. If styles.css exists, regardless of mode, the file is used and there is no SCSS -> CSS compilation.
I got this error even-though I've added maven goal to pom.xml
Finally got to know the reason, Its because of I've enabled production mode of Vaadin on web.xml
So when production mode on, its not generating styles.css file.
So you need to disable production mode in order to enable this SCSS - > CSS compilation.
<context-param>
<description>Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
Is there a tool which takes a Java File what describes a REST service as a parameter and generates a wadl file out of that.
I had the same problem: was using RESTeasy and wanted to find a way to generate the WADL automatically.
Did some research and came to the solution below.
1. Add this to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>maven-wadl-plugin</artifactId>
<version>1.17</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<phase>${javadoc-phase}</phase>
</execution>
</executions>
<configuration>
<wadlFile>${project.build.outputDirectory}/application.wadl
</wadlFile>
<formatWadlFile>true</formatWadlFile>
<baseUri>http://example.com:8080/rest</baseUri>
<packagesResourceConfig>
<param>com.example.rs.resource</param>
</packagesResourceConfig>
<wadlGenerators>
<wadlGeneratorDescription>
<className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc
</className>
<properties>
<property>
<name>applicationDocsFile</name>
<value>${basedir}/src/main/doc/application-doc.xml</value>
</property>
</properties>
</wadlGeneratorDescription>
<wadlGeneratorDescription>
<className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport
</className>
<properties>
<property>
<name>grammarsFile</name>
<value>${basedir}/src/main/doc/application-grammars.xml</value>
</property>
</properties>
</wadlGeneratorDescription>
</wadlGenerators>
</configuration>
</plugin>
</plugins>
</build>
Pay attention to the buildUri and packagesResourceConfig elements. You have to change them to reflect your project's configuration. You may also want to change the plugin's version (I used 1.17).
2. Create a /doc folder and add some files.
Create the src/main/doc/ folder and create the two files below.
File: application-doc.xml
Content:
<?xml version="1.0" encoding="UTF-8"?>
<applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02">
<doc xml:lang="en" title="A message in the WADL">This is added to the start of the generated application.wadl</doc>
</applicationDocs>
File: application-grammars.xml
Content:
<?xml version="1.0" encoding="UTF-8" ?>
<grammars xmlns="http://wadl.dev.java.net/2009/02" />
3. Run the maven command.
Go to the project folder and run the following command:
$ mvn compile com.sun.jersey.contribs:maven-wadl-plugin:generate
The files \target\classes\application.wadl (the WADL itself) and \target\classes\xsd0.xsd (the schema of the resources - it's used by the application.wadl) should be generated.
Edit and use them as you wish.
PS.: Bear in mind that this is a very simple use of the maven-wadl-plugin. It can do a lot more. To know it better, please refer to the zip file mentioned in the other answer (by Pavel Bucek).
Yes, please see gerenate-wadl [1] sample from Jersey samples (look for maven-wadl-plugin).
[1] http://search.maven.org/remotecontent?filepath=com/sun/jersey/samples/generate-wadl/1.12/generate-wadl-1.12-project.zip