Skip to content

Commit

Permalink
Merge pull request #13905 from jdaugherty/feature/7.0.0/deprecateDisp…
Browse files Browse the repository at this point in the history
…atchAction

Mark dispatch action as deprecated due to grails-gsp#551
  • Loading branch information
codeconsole authored Dec 3, 2024
2 parents 5fed630 + a1d2263 commit cc5d4ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion UPGRADE7.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ Experienced while upgrading modules for Grails 7
- Jar artifacts produced by Grails Plugins will no longer have the suffix `-plain`
- https://github.com/grails/grails-gradle-plugin/pull/347
- [GROOVY-5169](https://issues.apache.org/jira/browse/GROOVY-5169) [GROOVY-10449](https://issues.apache.org/jira/browse/GROOVY-10449)
- Fields with a public modifier were not returned with MetaClassImpl#getProperties() in groovy 3, but are now.
- Fields with a public modifier were not returned with MetaClassImpl#getProperties() in groovy 3, but are now.

## NOTE: This document is a draft and the explanations are only highlights and will be expanded further prior to release of 7.0.

## New Features
- [grails-gsp #551](https://github.com/grails/grails-gsp/issues/551) adopts a `formActionSubmit` tag to replace `actionSubmit`. Dispatching actions via a parameter name on a form submit will be removed in a future version of grails.

### Cool New Features
- You can now @Scaffold Controllers and Services and virtually eliminate any boiler plate code.
- Hello Exterminator, Good by bugs! Lot's of things started working... and working well! For instance, use of controller namespaces now work seemlessly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import grails.core.GrailsApplication;
import grails.web.mapping.UrlMappingInfo;
import grails.web.mapping.exceptions.UrlMappingException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.grails.web.servlet.mvc.GrailsWebRequest;
import org.grails.web.util.WebUtils;
import org.springframework.context.ApplicationContext;
Expand All @@ -49,6 +51,7 @@
*/
public class DefaultUrlMappingInfo extends AbstractUrlMappingInfo {

private static final Log LOG = LogFactory.getLog(DefaultUrlMappingInfo.class);
private static final String SETTING_GRAILS_WEB_DISABLE_MULTIPART = "grails.web.disable.multipart";
private static final String CONTROLLER_PREFIX = "controller:";
private static final String ACTION_PREFIX = "action:";
Expand Down Expand Up @@ -212,6 +215,13 @@ public String getId() {
return evaluateNameForValue(id);
}

/**
* @deprecated
* This method will be removed in a future grails version since the associated g:submitAction is being removed.
* Grails will no longer support redirecting to a different action name by adding a parameter with the prefix
* '_action'
*/
@Deprecated(since = "7.0.0", forRemoval = true)
private String checkDispatchAction(HttpServletRequest request) {
if (request.getAttribute(WebUtils.EXCEPTION_ATTRIBUTE) != null || WebUtils.isForwardOrInclude(request)) {
return null;
Expand All @@ -231,6 +241,11 @@ private String checkDispatchAction(HttpServletRequest request) {
break;
}
}

if (LOG.isWarnEnabled() && dispatchActionName != null) {
LOG.warn(String.format("Dispatch Action [%s] detected; Dispatch Actions will be removed in a future version of Grails. Use g: formActionSubmit instead.", dispatchActionName));
}

return dispatchActionName;
}

Expand Down

0 comments on commit cc5d4ca

Please sign in to comment.