Grails 3.x - Customizing scaffolding-generated views - grails

I'm a Grails 2.x developer and I'm trying to jump to Grails 3.x and Java 8. But I feel disappointed with the scaffolding process results. It generates these views (GSP files): create.gsp, edit.gsp, show.gsp and index.gsp.
So, some things have changed:
The form.gsp file is missing. I think it's been replaced (to
generate the form) in the create.gsp and edit.gsp files with this code: <f:all bean="myDomainClass"/>.
IMHO this is really sad. Customizing our forms is the most natural
thing.
The same has happened with the show.gsp and index.gsp files, replacing the customizable generated code with <f:display bean="myDomainClass" /> and <f:table collection="${myDomainClassList}" /> respectively.
So, how can I customize the form or generate a form.gsp like file? How can I customize the show.gsp and index.gsp files? Is there a way to generate views as Grails 2.x does? Can we avoid the usage of <f:all />, <f:display /> and <f:table/> tags?

Related

sitemesh + struts2 How to include external files in standard.jsp

My company has 20+ web applications. They all use Struts2 and Sitemesh to decorate the pages.
Every application has its own version of header.html and footer.html which are included in standard.jsp (using <%# include file=filename%>).
For look and feel consistency across applications I want to have the header and footer files outside of the web application.
However I can't figure out how to do that!
My decorator.xml looks like this
<decorators defaultdir="/layout">
<decorator name="standard-layout" page="standard.jsp">
<pattern>/*</pattern>
</decorator>
</decorators>
My include directive <%# include file="/common/header.html%>, gets prefix with the defaultdir value, like this /layout/common/header.html, and I get a file not found error.
The same thing happens if I use an absolute path.
Also, the same thing happens if I change decorators.xml like this.
<decorators>
<decorator name="standard-layout" page="/layout/standard.jsp">
<pattern>/*</pattern>
</decorator>
</decorators>
Help will be appreciated!
Update: I was able to solve this using JSTL
<c:import var="commomHeader" url="/resources/html/common_header.html"/>
${commomHeader}

Layout page and simple mvc razor view in Orchard Module and css, js reference issue

According to the answer provided by REMESQ on this question: Is it possible to use razor layouts with Orchard CMS and bypass the theming
I was able to have separate layout and pages for a module bypassing Orchard's themes and layouts. But having problem referencing the cs,js script files (located in different folders of the module). Getting 404 NotFound error.
I tried referancing in the following way:
#Script.Include("~/Scripts/jquery-1.9.1.js")
But cant get the correct reference path rendered attached picture
Your URL is wrong - it should be either:
jquery-1.9.1.js. Without leading tilde and Scripts/. Orchard will make sure the final URL will lead to /Scripts folder in your current module, or
~/Modules/Your.Module/Scripts/jquery-1.9.1.js
it works if written in this way:
<link href="~/Modules/ModuleName/Styles/site.css" rel="stylesheet" type="text/css" />
For the image tags in html we can write like this:
<img alt="" src="~/Modules/ModuleName/Styles/images/for-rent.jpg" />

Grails Resource Plugin - Require module with JS file when AJAX

in my grails app, I'm using the awesome resource plugin which wires all the dependencies. When I'm doing the ajax calls I always use <r:layoutResources disposition="defer"/> in order to render all scripts <r:script>... and other dependencies property.
The problem is if I use <r:require module="myModule"/> and the module specify a JS file which was not loaded before (when the page was not loaded). After the AJAX call the JS file is not loaded, what is more or less expected because all JS file should be loaded when the page is rendered.
My question is how to solve it properly? Should I put my r:require to the gsp which is rendered during the first request? Or are there any plans to make the r:require deal with "external" JS files when AJAX?
Thanks,
Mateo
Create a layout ajaxInternal.gsp and put in something like:
<r:require module="gaScript" />
<r:layoutResources />
<g:layoutBody />
<r:layoutResources disposition="defer" />
And in your ajax action of controller render this:
render(template:"aTemplateIfRequired", model:[yourModel],layout:'ajaxInternalContentBox')
So all your js will work properly and all your modules also.

Cannot import the CSS in JSF pages

I'm learning to use ADF on Oracle jDeveloper 11g.
I created an ADF Fusion Web Application (with the WebLogic webserver) and I created a JSF page under \ViewController\public_html. Then I created a CSS skin file (for JSF) and I put it under \ViewController\WebContent\resources\css\
I want to apply such style rules to the JSF page. To do this I put it into such page the line
<h:outputStylesheet library="css" name="prova.css" id="CASD"/>
where prova.css is the name of the CSS file I've created.
It doesn't work, neither using /css instead of css or /resources/css, etc.
Try using <af:resource type="css" source="your source path here" /> instead.
You shoud make a skin and add your page. When you make a skin
the name of skin is set in trinidad-config.xml in your project:
<skin-family>skin2(name of skin)</skin-family>

In Grails template namespace how do you use a template that is in another directory

Say I have a template called /sample/_mytemplate.gsp.
If I want to call this template from the same directory I can use
However, what if I am in another directory. Then what do I do?
Say I'm in the view /sample2/mypage.gsp how do I call it?
In Grails 1.3.7 the following syntax
<tmpl:/sample/mytemplate />
works.
<g:render template="/sample/mytemplate" />
should do it.

Resources