You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2007/11/08 09:59:21 UTC

svn commit: r593079 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java

Author: skitching
Date: Thu Nov  8 00:59:20 2007
New Revision: 593079

URL: http://svn.apache.org/viewvc?rev=593079&view=rev
Log:
Add docs/comments.

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java?rev=593079&r1=593078&r2=593079&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java Thu Nov  8 00:59:20 2007
@@ -66,13 +66,34 @@
 		}, fromAction, outcome);
 	}
 
-	// TODO: this only supports one EL expression at the moment; it would be nice
-	// to support multiple.
+	/**
+	 * Expand any EL expressions in the URL string.
+	 * <p>
+	 * If the url string contains one or more EL expressions (ie contains "#{" anywhere)
+	 * then expand all embedded EL expressions in the url.
+	 * <p>
+	 * The result of evaluating an EL expression is inserted directly into the url without
+	 * any further encoding. Therefore an EL expression must ONLY return data that is valid
+	 * within a url (and in particular, no space characters).
+	 * <p>
+	 * TODO: Consider evaluating each EL expression separately, and encoding each
+	 * result, so the EL expression can safely return any data without worrying about
+	 * generating invalid urls. However encoding things like questionmarks, slashes,
+	 * spaces, etc. would limit the usefulness of the EL expressions.
+	 * <p>
+	 * TODO: Consider supporting the "${" EL expression marker too, just for consistency.
+	 * <p>
+	 * Returns the original string if it contains no EL expressions, otherwise a new
+	 * string with the EL expressions expanded.
+	 */
 	protected String interceptRedirect(FacesContext context, String url)
 	{
 		int pos = url.indexOf("#{");
 		if (pos > -1 && url.indexOf("}", pos) > -1)
 		{
+			// There is at least one EL expression, so evaluate the whole url string.
+			// Note that something like "aaa#{foo}bbb#{bar}ccc" is fine; both the
+			// el expressions will get replaced.
 			ValueBinding vb = context.getApplication().createValueBinding(url);
 			return (String) vb.getValue(context);
 		}