Trying to use the Jquery-UI plugin from http://grails.org/plugin/jquery-ui
but apparently the documentations is not correct when discuss using the plugin with resources framework as following the instructions leads to an error:
Error processing GroovyPageView: Error executing tag <r:layoutResources>: No module found with name [jquery-ui]
Apparently the same problem is known around, but was not able to find a solution on the net (example: some discussion here and some other discussions with no solution or hints to a solution).
Did anyone managed to successfully configure jquery-ui in grails with the resource framework?
First you need to install the plugin, so in your BuildConfig.groovy
plugins {
...
compile ":jquery-ui:1.8.24"
...
}
Use grails compile --refresh-dependencies and see if the console output the download of the plugin. If you are using STS, you can go in right click > grails tools > refresh dependencies
After that, you can add <r:require module="jquery-ui"/> before the <r:layoutResources/>
A usefull tip is the change of the jquery ui theme, you can configure this in your ApplicationResources.groovy
modules = {
overrides {
'jquery-theme' {
resource id:'theme', url:'/css/ui/jquery-ui-1.8.21.custom.css'
}
}
}
In this example i have one css located in web-app/css/ui/.
Another tip is that you can force your modules to depend on jquery-ui:
modules = {
mymodule {
dependsOn 'jquery-ui'
resource url: '/js/my.js'
}
}
So if you add the resource mymodule to your GSP, the jquery-ui will be loaded too.
Related
After upgrading from Vaadin 14.5 to 14.6 I'm facing problems with CSS that contains URL's that point to content.
For example, the following CSS no longer works:
:host([part="my-part"]) [part="reveal-button"]::before {
content: url("../images/my-image.svg");
}
It fails to "compile" when running the build-frontend goal of the Vaadin Maven plugin with the following error:
ERROR in ../node_modules/#vaadin/flow-frontend/styles/components/my-component.css
Module build failed (from ../node_modules/css-loader/dist/cjs.js):
Error: Can't resolve '../images/my-image.svg' in '<Project Path>\node_modules\#vaadin\flow-frontend\styles\components'
The same error appears in the browser if I try to run the project. This CSS has worked fine in all previous versions of Vaadin 14.
Has anyone encountered anything similar, or have any ideas as to what has changed that might cause this?
With the new custom theme feature the .css loader has changed from raw-loader to css-loader but it shouldn't touch urls outside of frontend/themes/[theme-name] or node_modules
Is the styles/components/my-component.css located in src/main/resources/META-INF/frontend, src/main/resources/META-INF/resources/frontend or src/main/resources/META-INF/resources to be packaged as an add-on jar or compatibility mode?
As in that case the css would end up inside node_modules which might make a difference to the resolving.
As a workaround if you are not building an add-on you should be able to move the css and image to {project_root}/frontend and it should build fine.
Until release of 14.6.2 you can add the raw-loader dependency to a java class with
#NpmPackage(value = "raw-loader", version = "3.1.0")
and then add to webpack.config.js the lines
if(flowDefaults.module.rules[2].test.toString().includes('.css')) {
flowDefaults.module.rules[2].use = [ {loader: 'raw-loader' }];
} else if(flowDefaults.module.rules[1].test.toString().includes('.css')) {
flowDefaults.module.rules[1].use = [ {loader: 'raw-loader' }];
}
Did you change the css structure to follow the new theme structure introduced in 14.6? It is not needed, but it is important context. I think it is at least related to your issue.
The path seems a little weird in your error messages, ending up in a node_modules folder. Could you share where this file is in, and what loads the file to your project?
With the new theme structure, I've used the following css to import images in css:
background: url('./images/fire.png');
And that was placed in a file: frontend/themes/mythemename/mythemefile.css
I've recently upgraded a grails app to 2.4.3 and in the process upgraded the resources plugin to 1.2.14. I realize the assets plugin is preferred at this point, but I cannot make the switch just yet. I have the following defined in my ApplicationResources.groovy
modules = {
core {
resource url: '/js/main.js', disposition: 'head'
resource url: '/lib/bootstrap/css/bootstrap.css', disposition: 'head'
... more here
}
}
When I run the app, I get the following:
| Error 2015-02-01 23:13:40,005 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /lib/bootstrap/css/bootstrap.css
If you look at the image I've attached, you can see that this file is indeed in the correct place, and this worked with an older version of the resources plugin.
The Grails Resources plugin uses the grails.resources.adhoc.patterns and grails.resources.adhoc.includes values in Config.groovy to determine which resources to process. Perhaps this behavior changed across versions and you need to add the lib directory like so:
grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*', '/lib/bootstrap/css/*']
grails.resources.adhoc.includes = ['/images/**', '/css/**', '/js/**', '/plugins/**', '/lib/bootstrap/css/**']
I know it is a very old question, but thought my finding would helpful to someone. If we place grails.resources.resourceLocatorEnabled = false in Config.groovy file then it should work. No need to add grails.resources.adhoc property.
I want to use fontawesome plugin in grails.
I have added in build config compile :font-awesome-resources:4.0.3.1 to add plugin.I have added
customBootstrap
{
dependsOn 'font-awesome'
resource url: 'css/bootstrap.css'
resource url: 'js/bootstrap.js' resource url: 'css/bootstrap-fixtaglib.css'
}
in applicationresource.groovy but when i run the application get error
ERROR resource.ResourceProcessor - Unable to load resources Message: No such property: pluginManager for class: org.springframework.web.context.support.XmlWebApplicationContext.Please provide solution.
I am not sure whether this is a configuration issue with migration from earlier grails versions or if font-awesome has not been migrated completely to grails 2.4.x. But I encountered this as well.
As a short (dirty) workaround, you can replace the code that causes the problem directly on the plugin.
File (replace X with your project name):
~/.grails/2.4.2/projects/X/plugins/font-awesome-resources-4.0.3.1/grails-app/conf/FontAwesomePluginResources.groovy
Replace lines 3 and 4 with:
def pluginManager = grails.util.Holders.pluginManager
def lesscssPlugin = pluginManager.getGrailsPlugin('lesscss-resources') || pluginManager.getGrailsPlugin('less-resources')
And give it a go.
I have gradle project (backend) and I want to add Vaadin-based frontend. But I haven't find any gradle-plugins for Vaadin.
While, as was already mentioned above, Vaadin app is a simple web application and does not require any additional plugins but "java" and "war" (and maybe "jetty" to run the app), currently there seems to be the first vaadin-specific gradle plugin available:
https://github.com/johndevs/gradle-vaadin-plugin
It will help you with Vaadin-specific task like building widgetsets, creating components skeletons, etc.
I think there is no a Vaadin plugin for Gradle but I have used Gradle in one of my Vaadin add-on projects: SplitButton. It's a project with sub-projects, widgetset compilation and it writes necessary jar manifest entries neebed by Vaadin Directory.
EDIT
Actually there is Gradle Vaadin plugin now - it allows you to easily build Vaadin projects with Gradle. It helps with the most tedious tasks when building a Vaadin project like building the widgetset and running development mode. It also helps you to quickly get started by providing tasks for project, component and theme creation:
https://github.com/johndevs/gradle-vaadin-plugin
You don't need a Vaadin plugin. A Vaadin application is simply a web application.The war plugin will suffice. If you want support for automatically creating the folder layout that Vaadin wants however, you might look into using the vaadin eclipse plugin found here:
http://vaadin.com/eclipse
If you are looking for deployment support, you can simply use the jetty plugin that comes with gradle or the tomcat plugin found here
https://github.com/bmuschko/gradle-tomcat-plugin
If you need to create custom widgets and compile them into a widgetset that's a GWT compile
https://vaadin.com/book/vaadin6/-/page/gwt.development.html#gwt.development.compiler
Note: The Vaadin7 Book no longer has the section on developing Gwt widgets.
There is a gradle plugin for GWT that could help with that. However, I've not needed a custom widget yet, so I haven't actually tried it.
https://github.com/markuskobler/gwt-gradle-plugin
This post:
Using Gradle with Vaadin
looks very comprehensive as far as Gradle+Vaadin setup goes. I'm also including a link to another Vaadin-based 'build.gradle' file I found on my travels, using Google's very useful 'filetype' search (see also the associated gradle.properties file).
JFYI that Google file search is:
filetype:<extension> <your search phrases>
Gradle can also be used to configure Eclipse and IntelliJ's project files by using a fragment such as the following (Eclipse natures can be 'found' by using the above Google file search for "project" extension and "natures" search, etc.):
//Template plugin - Great for project-layout setup - See http://tellurianring.com/wiki/gradle/templates
apply from: 'http://launchpad.net/gradle-templates/trunk/latest/+download/apply.groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
// if you want to distribute the gradle with your code
task('wrapper', type: Wrapper).configure {
gradleVersion = '1.0-milestone-8a'
}
def versionCompatibility = 1.6
//configurations.providedDependencies.extendsFrom configurations.gwt
eclipse {
project {
comment = ""
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "org.eclipse.wst.jsdt.core.javascriptValidator"
buildCommand "org.eclipse.wst.common.project.facet.core.builder"
buildCommand "org.eclipse.wst.validation.validationbuilder"
buildCommand "com.vaadin.integration.eclipse.widgetsetBuilder"
//buildCommand "org.eclipse.m2e.core.maven2Builder"
//buildCommand "org.maven.ide.eclipse.maven2Builder"
//buildCommand "com.google.gdt.eclipse.core.webAppProjectValidator"
//buildCommand "com.google.gwt.eclipse.core.gwtProjectValidator"
//buildCommand "com.google.gdt.eclipse.designer.GWTBuilder"
//Don't forget commas - no trailing
natures "org.eclipse.jdt.core.javanature",
"com.vaadin.integration.eclipse.widgetsetNature",
"org.eclipse.wst.jsdt.core.jsNature",
"org.eclipse.wst.common.project.facet.core.nature",
"org.eclipse.wst.common.modulecore.ModuleCoreNature",
"org.eclipse.jem.workbench.JavaEMFNature"
//"org.eclipse.m2e.core.maven2Nature",
//"org.maven.ide.eclipse.maven2Nature",
//"com.google.gwt.eclipse.core.gwtNature"
//"com.google.gdt.eclipse.designer.GWTNature",
//"ch.epfl.lamp.sdt.core.scalanature",
//"com.springsource.sts.grails.core.nature",
//"org.eclipse.jdt.groovy.core.groovyNature"
}
classpath {
containers "com.google.gwt.eclipse.core.GWT_CONTAINER"
//"com.springsource.sts.gradle.classpathcontainer"
//minusConfigurations=[configurations.gwt]
}
}
idea {
project {
jdkName = versionCompatibility
ipr {
withXml { provider ->
def node = provider.asNode()
// Set Gradle home
def gradleSettings = node.appendNode('component', [name: 'GradleSettings'])
gradleSettings.appendNode('option', [name: 'SDK_HOME', value: gradle.gradleHomeDir])
}
}
}
}
Cheers
Rich
I'm using Grails 1.3.7 and I want to use both resources plugin as well as jquery ui, the problem comes when I want to switch to a different jquery ui theme. I cannot give the theme argument.
I use this tag:
<r:use module="jquery" />
<r:use module="jquery-ui" theme="smoothness" />
but doesn't work, also tried with themeCSS attribute and no effect.
Thanks.
You can override the default jquery-theme resource in your own local resources definition (like /conf/AppResources.groovy). To do that add overrides section like:
modules = {
...
overrides {
// this overrides the default ui-lightness theme from jquery-ui plugin
'jquery-theme' {
resource id:'theme', url:'/css/themes/my-theme/jquery-ui.custom.css', attrs: [media: 'screen, projection']
}
}
...
}
Adjust the url accordingly to point to your theme css downloaded from a ThemeRoller. Then simply use
<r:require module="jquery-ui" />
jquery-ui module depends on jquery-theme and will pull it according to your overridden definition.
I don't know why this plugin makes it so hard but anyway, if you want to change the theme you need to specify (inside of head tag):
<jqui:resources themeCss="${g.resource(dir:'/css/jquery-ui/theme/smoothness', file:'jquery-ui-1.4.4.custom.css')}" />
Than you need to place your template files (css file and also images folder) into your application css folder (web-app/css). This should work