This is the operator usually used in comparator. It will returns –1, 0, 1
println (1<=>2) // –1
println (1<=>1) // 0
println (2<=>1) // 1
This is the operator usually used in comparator. It will returns –1, 0, 1
println (1<=>2) // –1
println (1<=>1) // 0
println (2<=>1) // 1
def inX = [0,0]
def inXExpanded = []
(1..2).each {
inXExpanded += inX
}
println inXExpanded // the result is [0,0,0,0]
replace the code above to
(1..2).each {
inXExpanded.add(inX)
}
println inXExpanded // the result is [[0,0],[0,0]]
There is a good article online about Gorm Performance tuning.
Run this command
grails-debug run-app
The application is now up and running in debug mode, which means you may setup your eclipse remote debugging on port 5005.
Have this in BootStrap.groovy
import grails.util.Environment;class BootStrap {
def messageSource
def init = { servletContext ->
if( Environment.getCurrent() == Environment.PRODUCTION ){
messageSource.basenames = [ 'WEB-INF/grails-app/i18n/messages' ]
messageSource.clearCache()
}
}
def destroy = {
}
}
Run these two commands to package and deploy
<g:javascript library="prototype" />
…
<g:remoteLink action="showDetail" id="${messageInstance?.id}"
update="details" >
${messageInstance.author.fullName} - ${messageInstance.subject}
</g:remoteLink>
The final attribute that we
set on the <g:remoteLink> tag is update. This attribute contains the ID of the HTML element on this page that will be updated with the result of the action—in this case, details.
In the method in action
def showDetail = {
def messageInstance = Message.get(params.id)
if (messageInstance) {
render(template:"details" , model:[messageInstance:messageInstance])
}
else {
render "No message found with id: ${params.id}"
}
}
You can include a GSP template in a GSP page with the <g:render> tag, like this:
<g:render template="someTemplate" />
I cannot find a good convertor online. So I did it in groovy web console
http://groovyconsole.appspot.com/
static String toCamelCase( String text, boolean capitalized = false ) {
text = text.replaceAll( "(_)([A-Za-z0-9])", { Object[] it -> it[2].toUpperCase() } )
return capitalized ? capitalize(text) : text
}
static String toSnakeCase( String text ) {
text.replaceAll( /([A-Z])/, /_$1/ ).toLowerCase().replaceAll( /^_/, '' )
}
println toCamelCase("type_requisition")
The result is
typeRequisition