Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '2.4.x'

Conflicts:
	build.gradle
	grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsApplication.java
	grails-plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/plugins/web/api/ControllersApi.java
	grails-plugin-gsp/src/ast/groovy/org/codehaus/groovy/grails/plugins/web/api/ControllerTagLibraryApi.java
	grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/ApplicationTagLib.groovy
	grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/servlet/RenderMethodTests.groovy
	grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/FormTagLibTests.groovy
	grails-web-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/LinkGenerator.java
  • Loading branch information...
commit 76eed28e7e50dc73139cb7004a9fa40040db2181 2 parents 5364ae1 + 19fc9a7
Lari Hotari lhotari authored
2  grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java
View
@@ -73,7 +73,7 @@
protected Class<?>[] allClasses = new Class[0];
protected static Log log = LogFactory.getLog(DefaultGrailsApplication.class);
- protected Set<Class<?>> loadedClasses = new HashSet<Class<?>>();
+ protected Set<Class<?>> loadedClasses = new LinkedHashSet<Class<?>>();
protected ArtefactHandler[] artefactHandlers;
protected Map<String, ArtefactHandler> artefactHandlersByName = new HashMap<String, ArtefactHandler>();
protected List<Class<?>> allArtefactClasses = new ArrayList<Class<?>>();
8 grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/api/ControllersApi.java
View
@@ -372,6 +372,10 @@ public Object render(Object instance, Object o) {
public Object render(Object instance, String txt) {
return invokeRender(instance, txt);
}
+
+ public Object render(Object instance, CharSequence txt) {
+ return invokeRender(instance, txt);
+ }
public Object render(Object instance, Map args) {
return invokeRender(instance, args);
@@ -385,6 +389,10 @@ public Object render(Object instance, Map args, Closure c) {
return invokeRender(instance, args, c);
}
+ public Object render(Object instance, Map args, CharSequence body) {
+ return invokeRender(instance, args, body);
+ }
+
protected Object invokeRender(Object target, Object... arguments) {
if (arguments.length == 0) {
throw new MissingMethodException(METHOD_SIGNATURE, target.getClass(), arguments);
29 grails-plugin-gsp/src/ast/groovy/org/grails/plugins/web/api/ControllerTagLibraryApi.java
View
@@ -78,24 +78,29 @@ public void setGspTagLibraryLookup(TagLibraryLookup lookup) {
*/
public Object methodMissing(Object instance, String methodName, Object argsObject) {
Object[] args = argsObject instanceof Object[] ? (Object[])argsObject : new Object[]{argsObject};
- TagLibraryLookup lookup = getTagLibraryLookup();
- if (lookup != null) {
- GroovyObject tagLibrary = lookup.lookupTagLibrary(GroovyPage.DEFAULT_NAMESPACE, methodName);
- if (tagLibrary != null) {
- if (!developmentMode) {
- MetaClass controllerMc = GrailsMetaClassUtils.getMetaClass(instance);
- TagLibraryMetaUtils.registerMethodMissingForTags(controllerMc, lookup, GroovyPage.DEFAULT_NAMESPACE, methodName);
- }
- List<MetaMethod> respondsTo = tagLibrary.getMetaClass().respondsTo(tagLibrary, methodName, args);
- if (respondsTo.size()>0) {
- return respondsTo.get(0).invoke(tagLibrary, args);
+ if (shouldHandleMethodMissing(instance, methodName, args)) {
+ TagLibraryLookup lookup = getTagLibraryLookup();
+ if (lookup != null) {
+ GroovyObject tagLibrary = lookup.lookupTagLibrary(GroovyPage.DEFAULT_NAMESPACE, methodName);
+ if (tagLibrary != null) {
+ if (!developmentMode) {
+ MetaClass controllerMc = GrailsMetaClassUtils.getMetaClass(instance);
+ TagLibraryMetaUtils.registerMethodMissingForTags(controllerMc, lookup, GroovyPage.DEFAULT_NAMESPACE, methodName);
+ }
+ List<MetaMethod> respondsTo = tagLibrary.getMetaClass().respondsTo(tagLibrary, methodName, args);
+ if (respondsTo.size()>0) {
+ return respondsTo.get(0).invoke(tagLibrary, args);
+ }
}
}
}
-
throw new MissingMethodException(methodName, instance.getClass(), args);
}
+ protected boolean shouldHandleMethodMissing(Object instance, String methodName, Object[] args) {
+ return !"render".equals(methodName);
+ }
+
/**
* Looks up namespaces on missing property
*
2  grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/ApplicationTagLib.groovy
View
@@ -227,8 +227,6 @@ class ApplicationTagLib implements ApplicationContextAware, InitializingBean, Gr
if (elementId) {
writer << " id=\"${elementId}\""
}
- attrs.remove(UrlMapping.PLUGIN)
- attrs.remove(UrlMapping.NAMESPACE)
def remainingKeys = attrs.keySet() - LinkGenerator.LINK_ATTRIBUTES
for (key in remainingKeys) {
writer << " " << key << "=\"" << attrs[key]?.encodeAsHTML() << "\""
2  grails-plugin-testing/src/main/groovy/grails/test/runtime/GrailsApplicationTestPlugin.groovy
View
@@ -317,7 +317,7 @@ class GrailsApplicationTestPlugin implements TestPlugin {
// trigger grailsApplication initialization by requesting value
runtime.getValue("grailsApplication", event.arguments)
break
- case 'after':
+ case 'resetGrailsApplication':
resetGrailsApplication(runtime)
break
case 'grailsApplicationRequested':
2  grails-resources/src/grails/home/bash/startGrails.bat
View
@@ -74,7 +74,7 @@ set DISABLE_RELOADING=
if "%GRAILS_OPTS%" == "" (
set GRAILS_OPTS=-server -Xmx768M -Xms64M -Dfile.encoding=UTF-8
if not "%GRAILS_NO_PERMGEN%" == "1" (
- set GRAILS_OPTS=%GRAILS_OPTS% -XX:PermSize=32m -XX:MaxPermSize=256m
+ set GRAILS_OPTS=-server -Xmx768M -Xms64M -XX:PermSize=32m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8
)
)
9 grails-test-suite-uber/src/test/groovy/grails/test/mixin/FiltersUnitTestMixinTests.groovy
View
@@ -1,8 +1,10 @@
package grails.test.mixin
-import grails.artefact.Artefact;
+import grails.artefact.Artefact
import grails.test.GrailsMock
import grails.test.mixin.web.FiltersUnitTestMixin
+
+import org.junit.After
import org.junit.Before
import org.junit.Test
import org.springframework.beans.factory.config.MethodInvokingFactoryBean
@@ -19,6 +21,11 @@ class FiltersUnitTestMixinTests {
controller = mockController(AuthorController)
}
+
+ @After
+ void cleanup() {
+ runtime.publishEvent("resetGrailsApplication")
+ }
@Test
void testFilterInvocationExplicitControllerAndAction() {
30 grails-test-suite-uber/src/test/groovy/org/grails/web/servlet/RenderMethodTests.groovy
View
@@ -148,7 +148,7 @@ class RenderMethodTests {
@Test
void testRenderViewWithContentType() {
- controller.renderXmlView.call()
+ controller.renderXmlView()
assert controller.modelAndView
@@ -195,52 +195,52 @@ class RenderMethodTests {
@Artefact('Controller')
class RenderController {
- def renderBug = {
+ def renderBug() {
render(view:'login', [foo:"bar"])
}
- def renderView = { render(view:'testView') }
- def renderXmlView = {
+ def renderView() { render(view:'testView') }
+ def renderXmlView() {
render(view:'xmlView', contentType:'text/xml')
}
- def renderObject = {
+ def renderObject() {
render new RenderTest(foo:"bar")
}
- def renderMessageWithStatus = {
+ def renderMessageWithStatus() {
render text:"test", status:500
}
- def renderList = {
+ def renderList() {
render([1, 2, 3])
}
- def renderMap = {
+ def renderMap() {
render([a:1, b:2])
}
- def renderText = { render "test render" }
- def renderGString = {
+ def renderText() { render "test render" }
+ def renderGString() {
def foo = 'render'
render "test $foo"
}
- def renderXML = {
+ def renderXML() {
render(contentType:"text/xml") { hello("world") }
}
- def renderTemplate = {
+ def renderTemplate() {
render(template:"testTemplate", model:[hello:"world"])
}
- def renderTemplateWithCollection = {
+ def renderTemplateWithCollection() {
def people = [
[firstName: 'Jacob', middleName: 'Ray'],
[firstName: 'Zachary', middleName: 'Scott']
]
render(template:"peopleTemplate", collection: people)
}
- def renderTemplateWithCollectionAndExplicitVarName = {
+ def renderTemplateWithCollectionAndExplicitVarName() {
def people = [
[firstName: 'Jacob', middleName: 'Ray'],
[firstName: 'Zachary', middleName: 'Scott']
]
render(var: 'person', template:"peopleTemplate", collection: people)
}
- def renderXmlTemplate = {
+ def renderXmlTemplate() {
render(template:"xmlTemplate",contentType:"text/xml")
}
}
40 grails-test-suite-web/src/test/groovy/org/grails/web/taglib/FormTagLibTests.groovy
View
@@ -1,6 +1,10 @@
package org.grails.web.taglib
+import grails.core.GrailsUrlMappingsClass
import grails.util.MockRequestDataValueProcessor
+
+import org.grails.core.AbstractGrailsClass
+import org.grails.core.artefact.UrlMappingsArtefactHandler
import org.grails.plugins.web.taglib.FormTagLib
import org.grails.web.pages.FastStringWriter
@@ -17,6 +21,42 @@ class FormTagLibTests extends AbstractGrailsTagTests {
super.setUp()
appCtx.getBean(FormTagLib.name).requestDataValueProcessor = new MockRequestDataValueProcessor()
}
+
+ @Override
+ protected void onInit() {
+ def mappingsClosure = {
+ "/admin/books"(controller:'books', namespace:'admin')
+ "/books"(controller:'books')
+ }
+ grailsApplication.addArtefact(UrlMappingsArtefactHandler.TYPE, new MockGrailsUrlMappingsClass(mappingsClosure));
+ }
+
+ void testFormNamespace() {
+ def template = '<g:form controller="books" namespace="admin"></g:form>'
+ assertOutputEquals('<form action="/admin/books" method="post" ><input type="hidden" name="requestDataValueProcessorHiddenName" value="hiddenValue" />\n</form>', template)
+ }
+
+ void testFormNoNamespace() {
+ def template = '<g:form controller="books"></g:form>'
+ assertOutputEquals('<form action="/books" method="post" ><input type="hidden" name="requestDataValueProcessorHiddenName" value="hiddenValue" />\n</form>', template)
+ }
+
+ private static final class MockGrailsUrlMappingsClass extends AbstractGrailsClass implements GrailsUrlMappingsClass {
+ Closure mappingClosure;
+ public MockGrailsUrlMappingsClass(Closure mappingClosure) {
+ super(this.getClass(), "UrlMappings");
+ this.mappingClosure = mappingClosure;
+ }
+ @Override
+ public Closure getMappingsClosure() {
+ return mappingClosure;
+ }
+
+ @Override
+ public List getExcludePatterns() {
+ return null;
+ }
+ }
void testFormTagWithAlternativeMethod() {
unRegisterRequestDataValueProcessor()
8 grails-web-url-mappings/src/main/groovy/grails/web/mapping/LinkGenerator.java
View
@@ -44,6 +44,9 @@
String ATTRIBUTE_MAPPING = "mapping";
String ATTRIBUTE_EVENT = "event";
String ATTRIBUTE_ELEMENT_ID = "elementId";
+ String ATTRIBUTE_PLUGIN = "plugin";
+ String ATTRIBUTE_NAMESPACE = "namespace";
+
Set<String> LINK_ATTRIBUTES = CollectionUtils.newSet(
ATTRIBUTE_RESOURCE,
@@ -61,7 +64,10 @@
ATTRIBUTE_PARAMS,
ATTRIBUTE_MAPPING,
ATTRIBUTE_EVENT,
- ATTRIBUTE_ELEMENT_ID);
+ ATTRIBUTE_ELEMENT_ID,
+ ATTRIBUTE_PLUGIN,
+ ATTRIBUTE_NAMESPACE
+ );
/**
* Generates a link to a static resource for the given named parameters.
Please sign in to comment.
Something went wrong with that request. Please try again.