Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use context.directActionURLForActionNamed() for URL generation of dir…

…ect actions and add a flag to include sessionID
  • Loading branch information...
commit 4e2898aa2e907bd45183c63127b95cc3d51aa75d 1 parent ecf4306
@darkv darkv authored pascalrobert committed
View
29 Frameworks/Core/ERExtensions/Sources/er/extensions/appserver/ERXRedirect.java
@@ -6,6 +6,7 @@
import com.webobjects.appserver.WOResponse;
import com.webobjects.appserver.WOSession;
import com.webobjects.foundation.NSDictionary;
+import com.webobjects.foundation.NSMutableDictionary;
import er.extensions.appserver.ajax.ERXAjaxApplication;
import er.extensions.foundation.ERXMutableURL;
@@ -26,6 +27,7 @@
private String _requestHandlerKey;
private String _requestHandlerPath;
private Boolean _secure;
+ private boolean _includeSessionID;
private String _directActionClass;
private String _directActionName;
@@ -36,6 +38,7 @@
public ERXRedirect(WOContext context) {
super(context);
_originalComponent = context.page();
+ _includeSessionID = false;
}
/**
@@ -48,6 +51,17 @@ public ERXRedirect(WOContext context) {
public void setSecure(boolean secure) {
_secure = Boolean.valueOf(secure);
}
+
+ /**
+ * Sets whether or not a direct action URL should contain the session ID.
+ * This defaults to <code>false</code> to maintain backward compatibility.
+ *
+ * @param includeSessionID
+ * whether or not a sessionID should be included
+ */
+ public void setIncludeSessionID(boolean includeSessionID) {
+ _includeSessionID = includeSessionID;
+ }
/**
* Sets the request handler key to redirect to. You typically want to also
@@ -150,6 +164,19 @@ protected String queryParametersString() {
}
return queryParametersString;
}
+
+ protected NSDictionary<String, Object> directActionQueryParameters() {
+ NSMutableDictionary<String, Object> params = null;
+ if (_queryParameters != null) {
+ params = (NSMutableDictionary<String, Object>) _queryParameters.mutableClone();
+ } else {
+ params = new NSMutableDictionary<String, Object>();
+ }
+ if (!_includeSessionID) {
+ params.takeValueForKey(Boolean.FALSE.toString(), WOApplication.application().sessionIdKey());
+ }
+ return params;
+ }
@Override
public void appendToResponse(WOResponse response, WOContext context) {
@@ -221,7 +248,7 @@ else if (_directActionName != null) {
else {
requestHandlerPath = _directActionName;
}
- url = context._urlWithRequestHandlerKey(WOApplication.application().directActionRequestHandlerKey(), requestHandlerPath, queryParametersString(), secure);
+ url = context.directActionURLForActionNamed(requestHandlerPath, directActionQueryParameters(), secure, 0, false);
}
else {
throw new IllegalStateException("You must provide a component, url, requestHandlerKey, or directActionName to this ERXRedirect.");
Please sign in to comment.
Something went wrong with that request. Please try again.