You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/06/25 16:42:03 UTC

git commit: WICKET-5179 Move Form hidden field rendering to dedicated method

Updated Branches:
  refs/heads/master 0c412482d -> 8c21ccf8c


WICKET-5179 Move Form hidden field rendering to dedicated method


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/8c21ccf8
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/8c21ccf8
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/8c21ccf8

Branch: refs/heads/master
Commit: 8c21ccf8c292152d13d02fd8523ea152d0cdd787
Parents: 0c41248
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Jun 25 17:41:31 2013 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Jun 25 17:41:31 2013 +0300

----------------------------------------------------------------------
 .../apache/wicket/markup/html/form/Form.java    | 76 ++++++++++----------
 1 file changed, 40 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/8c21ccf8/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
index 2162b44..5fac05b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
@@ -1164,16 +1164,9 @@ public class Form<T> extends WebMarkupContainer
 	 * will do a form submit using this component. This method is overridable as what we do is best
 	 * effort only, and may not what you want in specific situations. So if you have specific
 	 * usability concerns, or want to follow another strategy, you may override this method.
-	 * 
-	 * @param markupStream
-	 *            The markup stream
-	 * @param openTag
-	 *            The open tag for the body
 	 */
-	protected void appendDefaultButtonField(final MarkupStream markupStream,
-		final ComponentTag openTag)
+	protected void appendDefaultButtonField()
 	{
-
 		AppendingStringBuffer buffer = new AppendingStringBuffer();
 
 		// div that is not visible (but not display:none either)
@@ -1633,41 +1626,52 @@ public class Form<T> extends WebMarkupContainer
 		if (isRootForm())
 		{
 			// get the hidden field id
-			String nameAndId = getHiddenFieldId();
+			writeHiddenFields();
+		}
 
-			// render the hidden field
-			AppendingStringBuffer buffer = new AppendingStringBuffer(HIDDEN_DIV_START)
-				.append("<input type=\"hidden\" name=\"").append(nameAndId).append("\" id=\"")
-				.append(nameAndId).append("\" />");
+		// do the rest of the processing
+		super.onComponentTagBody(markupStream, openTag);
+	}
 
-			// if it's a get, did put the parameters in the action attribute,
-			// and have to write the url parameters as hidden fields
-			if (encodeUrlInHiddenFields())
-			{
-				String url = getActionUrl().toString();
-				int i = url.indexOf('?');
-				String queryString = (i > -1) ? url.substring(i + 1) : url;
-				String[] params = Strings.split(queryString, '&');
+	/*
+	 * Writes the markup for the hidden input field and default button field if applicable to the current response.
+	 */
+	public final void writeHiddenFields()
+	{
+		// get the hidden field id
+		String nameAndId = getHiddenFieldId();
 
-				writeParamsAsHiddenFields(params, buffer);
-			}
-			buffer.append("</div>");
-			getResponse().write(buffer);
+		AppendingStringBuffer buffer = new AppendingStringBuffer(HIDDEN_DIV_START).append(
+			"<input type=\"hidden\" name=\"")
+			.append(nameAndId)
+			.append("\" id=\"")
+			.append(nameAndId)
+			.append("\" />");
 
-			// if a default submitting component was set, handle the rendering of that
-			if (defaultSubmittingComponent instanceof Component)
-			{
-				final Component submittingComponent = (Component)defaultSubmittingComponent;
-				if (submittingComponent.isVisibleInHierarchy()
+		// if it's a get, did put the parameters in the action attribute,
+		// and have to write the url parameters as hidden fields
+		if (encodeUrlInHiddenFields())
+		{
+			String url = getActionUrl().toString();
+			int i = url.indexOf('?');
+			String queryString = (i > -1) ? url.substring(i + 1) : url;
+			String[] params = Strings.split(queryString, '&');
+
+			writeParamsAsHiddenFields(params, buffer);
+		}
+		buffer.append("</div>");
+		getResponse().write(buffer);
+
+		// if a default submitting component was set, handle the rendering of that
+		if (defaultSubmittingComponent instanceof Component)
+		{
+			final Component submittingComponent = (Component)defaultSubmittingComponent;
+			if (submittingComponent.isVisibleInHierarchy()
 					&& submittingComponent.isEnabledInHierarchy())
-				{
-					appendDefaultButtonField(markupStream, openTag);
-				}
+			{
+				appendDefaultButtonField();
 			}
 		}
-
-		// do the rest of the processing
-		super.onComponentTagBody(markupStream, openTag);
 	}
 
 	/**