I want to change the JSTL code in the script to Thymeleaf - thymeleaf

I want to change the JSTL code in the script to Thymeleaf
Because it is an HTML file, JSTL is not recognized.
request
I don't know how to change the path to the script.

Related

Tree is not working

I tried to set up an Orbeon form with a tree (xf:select1 appearance="tree"). Using Orbeon Demo form builder I created a page with tree and it is working in Demo environment. The same XForms code in my local Tomcat environment (latest Orbeon CE) is not working - the tree is not rendered at all.
If I check working demo HTML, then there are some additinal JS after extension functions (after sections /*! Extension 'jquery.fancytree.wide.min.js' */, etc.) and there is minimized code line a.declareCompanion("fr|tree-select1",b); which I believe registers the component. The same form code my in local Tomcat instance does not generate this block in JS files.
In Orbeon source code is file TreeSelect1.scale which I believe is converted to JS and then included in rendered HTML JS files.
Also in tree-select1.xbl strange I comment:
NOTE: When using this component outside of Form Runner, the supporting JavaScript must be explicitly included.
after:
<xbl:script src="/xbl/orbeon/tree-select1/fancytree/jquery-ui.min.js"/>
<xbl:script src="/xbl/orbeon/tree-select1/fancytree/jquery.fancytree-all.min.js"/>
What must be done to be able to render the tree?
The JavaScript for the component is not included by default. You can work around this with this:
<xh:script
type="text/javascript"
src="/apps/fr/resources/scalajs/orbeon-form-runner.js"/>
And then, on your main XForms model, put the xxf:assets.baseline.excludes attribute like this:
<xf:model
xxf:assets.baseline.excludes="/ops/javascript/scalajs/orbeon-xforms.js">
Regarding your other question about which JavaScript files are under xbl vs. not: some JavaScript files are written by hand, and are available as separate assets.
But code for other components like the tree is written in Scala and compiled with Scala.js. The resulting JavaScript for all such code is optimized and available in orbeon-xforms.js, orbeon-form-runner.js, and orbeon-form-builder.js depending on the environment. Only one of those 3 files must be included, hence the use of the xxf:assets.baseline.excludes property.

Grails r:require on modal

So i read the requirements for using r:require tag in Grails Load r:require are that,
Requires 1st g:layoutResources before head closure
Requires 2nd g:layoutResources before body closure
But i'm doing a modal on my GSP page and i need to use jqgrid resource defined on the applicationResources.groovy on it. And the modal has neither head nor body tag on it, only some g:set and div tags.
The jqgrid is defined inside the tag inside the modal's gsp file. I tried to put the following
<r:require module='jqgrid' />
<r:layoutResources />
before and after the script tag, or outside of the div tags, but still not working.
So where should i define the r:require so that i can use jqgrid resource for my modal?

Is it necessary to declare tags in facelet taglib 2.0?

I've read the tutorial: http://jsflive.wordpress.com/2011/03/24/custom-component-library/ in which the authors are making empty .taglib.xml file, and according to tutorial the tags should be automatically loaded from the resource subfolder.
However, by me I have exception:
javax.faces.FacesException: Could not get component metadata for
myComponent.xhtml
I have to manually specify each tag:
<tag>
<tag-name>myComponent</tag-name>
<source>tags/mylib/myComponent.xhtml</source>
</tag>
Am I missing something? Where the tag definition locations would be automatically resolved? I'm running on WebSphere 7.0 and MyFaces 2.0.7.
I think you mix things up here. In my above mentioned blog post I added composite components to the tag lib like this:
<facelet-taglib>
<namespace>http://jsflive.at/taglib</namespace>
<composite-library-name>jsflive</composite-library-name>
</facelet-taglib>
This adds all composite components of the resource library with the name specified in composite-library-name. The tag names are derived from the file names by convention.
You on the contrary specify a tag for a Facelets fragment:
<tag>
<tag-name>myComponent</tag-name>
<source>tags/mylib/myComponent.xhtml</source>
</tag>
This has nothing to do with composite components! This approach is the pre JSF 2.0 way of defining custom tags for Facelets fragments. Your code creates a tag for the referenced xhtml file, which could be an arbitrary Facelets file. The path is relative to the location of the taglib.xml file in this case.
JSF 2.2 however will provide a way to specify tags for specific composite components. My post http://jsflive.wordpress.com/2013/04/06/jsf22-cc-taglib/ shows how this works.

Postprocess *.js files with grails

I am wondering of there is any possibility of postprocessing *.js files so that every gsp expression can be evaluated.
for example i can write the following code directly in the gsp page:
<script type="text/javascript">
$.post("${createLink(controller:'mycontroller',action:'myaction')} " , {"id":id},function(){});
</script>
And the expression ${createLink} is evaluated by grails.
But i would like to also use ${createLink()} in *.js files which are not processed by grails.
Maybe it is possible to use the resource plugin to postprocess every *.js file and evaluate gsp expressions?
Of course i could wrap all my js code in a separate gsp page but it does not seem like an elegant solution.
Any help would be appreciated.
Either of this should work for you
http://grails.org/plugin/gsp-arse (standalone)
http://grails.org/plugin/gsp-resources (It works with resources plugin)
Another option is to do something similar to store the url in a variable
<script type="text/javascript">
var url = "${createLink(controller:'mycontroller',action:'myaction')}";
</script>
Then you can use all the ajax calls you want and still only have the url set once.
Use a JS Hash in your GSP file to save what matters
<r:script>
var linkobject={
mylink:'${createLink(controller:"mycontroller",action:"myaction")}',
 linkA : '${params.id}',
    linkB: '${g.createLink(action: "getThreats")}',
    linkC: '${g.createLink(action: "addThreat")}',
    linkD: '${g.resource(dir: 'images/icons', file: 'folder.png')}'
 
}
</r:script>
Then, Consume that JS hash in your JavaScript file to get what you need:
$.post(linkobject.mylink , {"id":linkobject.linkA},function(){});

grails app root context

I have a test grails app setup with a context of "/testapp". When I add a link in my gsp that references / it does not go to the root of my grails.app.context, but to the root of my grails.serverURL property.
For example given a link with href "/css/main.css"
I would expect that this link would actually look in localhost:8080/testapp/css/main.css instead of localhost:8080/css/main.css
Is there a way that I can get references to / to start at my grails.app.context vs the grails.serverURL?
use the request contextPath value on the page
${request.contextPath}
and then prepend the additional host information if necessary to construct the complete url
the question is how do you add your links into your gsps?
We do things like
<link rel="stylesheet" href="${resource(dir: 'css', file: 'stylesheet1.css')}"/>
and
<g:javascript library="prototype"/>
by using the g:javascript and resource tags and methods, you tell grails to set the path for you...
I suspect you are just putting standard tags in...
goto
http://grails.org/doc/latest/
and, under tags in the left hand nav, look for resource and/or javascript to get an idea (its difficult to link directly in to the docs...:()
I had a similar issue to OP - how to have grails form links that start at the context root and NOT server root?
You can do so using the "uri" attribute for g:link and g:createLink tags. For example:
<g:link uri="/login">login</g:link>
will prefix any context if applicable, and produce the following
login if your app is at the http://server/
login if your app is at http://server/testapp/
Not sure why it's an undocumented attribute in the reference docs, but I found it in the Javadocs - ApplicationTagLib
You should probably be using the resource tag into your grails CSS directory, like mentioned above. However, you can also use the resource method to find the root context of you web application using the same tag:
${resource(uri:'/')}
then just use that string wherever.
And when it comes to elements like stylesheets I'd recommend creating a simple tag that'll do the trick, something along those lines:
class StylesTagLib {
static namespace = "g"
def stylesheet = { args, body ->
out << """<link rel="stylesheet" href="${resource(dir: 'css', file: args.href)}"/>"""
}
}
and later on in your code use it like this:
<g:stylesheet href="main.css"/>
Obviously you can fiddle with the conventions (should I use a predefined folder? should I add the .css extension automatically? stuff like that) but the general idea is to hide the ugliness behind a nicely defined tag.

Resources