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 2010/08/07 11:06:08 UTC
svn commit: r983186 - in /wicket/trunk/wicket/src:
main/java/org/apache/wicket/
test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/
Author: mgrigorov
Date: Sat Aug 7 09:06:08 2010
New Revision: 983186
URL: http://svn.apache.org/viewvc?rev=983186&view=rev
Log:
merge from 1.4.x + test
Author: jrthomerson
Date: Fri Aug 6 19:51:26 2010
New Revision: 983111
URL: http://svn.apache.org/viewvc?rev=983111&view=rev
Log:
fixes WICKET-2974
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html (with props)
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java (with props)
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html (with props)
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java (with props)
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java (with props)
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html (with props)
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java (with props)
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=983186&r1=983185&r2=983186&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Sat Aug 7 09:06:08 2010
@@ -1164,7 +1164,23 @@ public abstract class Component implemen
feedbacks = new ArrayList<Component>();
getRequestCycle().setMetaData(FEEDBACK_LIST, feedbacks);
}
- feedbacks.add(this);
+
+ if (this instanceof MarkupContainer)
+ {
+ ((MarkupContainer)this).visitChildren(IFeedback.class,
+ new IVisitor<Component, Void>()
+ {
+ public void component(Component component, IVisit<Void> visit)
+ {
+ component.beforeRender();
+ }
+ });
+ }
+
+ if (!feedbacks.contains(this))
+ {
+ feedbacks.add(this);
+ }
}
}
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html?rev=983186&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html Sat Aug 7 09:06:08 2010
@@ -0,0 +1,11 @@
+<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" >
+ <head>
+ <title>Wicket Quickstart Archetype Homepage</title>
+ </head>
+ <body>
+ <strong>Wicket Quickstart Archetype Homepage</strong>
+
+ <div wicket:id="pagefbp"></div>
+ <wicket:child />
+ </body>
+</html>
Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java?rev=983186&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java Sat Aug 7 09:06:08 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.validation.innerfeedback;
+
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.feedback.IFeedbackMessageFilter;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+
+public class BasePage extends WebPage
+{
+
+ public BasePage()
+ {
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ super.onBeforeRender();
+ if (get("pagefbp") == null)
+ {
+ add(new FeedbackPanel("pagefbp", new IFeedbackMessageFilter()
+ {
+ public boolean accept(FeedbackMessage message)
+ {
+ return !message.isRendered();
+ }
+ }));
+ }
+ }
+}
Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html?rev=983186&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html Sat Aug 7 09:06:08 2010
@@ -0,0 +1,8 @@
+<wicket:extend>
+ <form wicket:id="form">
+ <div wicket:id="fieldborder">
+ <input type="text" wicket:id="field"></input>
+ </div>
+ <input type="submit" />
+ </form>
+</wicket:extend>
\ No newline at end of file
Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java?rev=983186&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java Sat Aug 7 09:06:08 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.validation.innerfeedback;
+
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+/**
+ * Homepage
+ */
+public class HomePage extends BasePage
+{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor that is invoked when page is invoked without a session.
+ *
+ * @param parameters
+ * Page parameters
+ */
+ @SuppressWarnings("serial")
+ public HomePage(final PageParameters parameters)
+ {
+ Form<Void> form = new Form<Void>("form")
+ {
+ @Override
+ protected void onSubmit()
+ {
+ super.onSubmit();
+ info("form submitted");
+ }
+ };
+ LocalizedFeedbackBorder brdr = new LocalizedFeedbackBorder("fieldborder");
+ TextField<String> field = new TextField<String>("field", new Model<String>(""));
+ field.info("info on field");
+ brdr.add(field.setRequired(true));
+ form.add(brdr);
+ add(form);
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ info("page onbeforerender");
+ super.onBeforeRender();
+ }
+}
Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java?rev=983186&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java Sat Aug 7 09:06:08 2010
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.validation.innerfeedback;
+
+import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test for Wicket-2974
+ */
+public class InnerFeedbackTest
+{
+
+ private WicketTester tester;
+
+ @Before
+ public void before()
+ {
+ tester = new WicketTester(new MockApplication()
+ {
+ @Override
+ protected void init()
+ {
+ super.init();
+
+ // we don't care about FormComponentFeedbackBorder's 'errorindicator'
+ getDebugSettings().setComponentUseCheck(false);
+ }
+
+ /**
+ * @see org.apache.wicket.Application#getHomePage()
+ */
+ @Override
+ public Class<HomePage> getHomePage()
+ {
+ return HomePage.class;
+ }
+ });
+ }
+
+ @Test
+ public void innerFeedback()
+ {
+ tester.startPage(HomePage.class);
+
+ // page's feedback
+ tester.assertInfoMessages(new String[] { "info on field", "page onbeforerender" });
+
+ FormTester formTester = tester.newFormTester("form");
+ formTester.submit();
+
+ // feedback message for LocalizedFeedbackBorder
+ // without the fix the same error message was reported for the page's feedback panel too
+ tester.assertErrorMessages(new String[] { "Field 'field' is required." });
+
+ // page's feedback
+ tester.assertInfoMessages(new String[] { "page onbeforerender" });
+
+ formTester = tester.newFormTester("form");
+ formTester.setValue("fieldborder:border:fieldborder_body:field", "some text");
+ formTester.submit();
+
+ tester.assertErrorMessages(new String[0]);
+
+ // page's feedback
+ tester.assertInfoMessages(new String[] { "form submitted", "page onbeforerender" });
+ }
+}
Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html?rev=983186&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html Sat Aug 7 09:06:08 2010
@@ -0,0 +1,6 @@
+<wicket:border>
+ <div wicket:id="border">
+ <div wicket:id="feedback"></div>
+ <wicket:body />
+ </div>
+</wicket:border>
\ No newline at end of file
Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java?rev=983186&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java Sat Aug 7 09:06:08 2010
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.validation.innerfeedback;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Session;
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.feedback.IFeedbackMessageFilter;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+
+@SuppressWarnings("serial")
+class LocalizedFeedbackBorder extends FormComponentFeedbackBorder
+{
+
+ private final FeedbackPanel feedback;
+
+ public LocalizedFeedbackBorder(String id)
+ {
+ super(id);
+ WebMarkupContainer brdr = new WebMarkupContainer("border");
+ brdr.add(feedback = new FeedbackPanel("feedback", getMessagesFilter()));
+ brdr.add(getBodyContainer());
+ brdr.add(new AttributeModifier("style", true, new AbstractReadOnlyModel<String>()
+ {
+ @Override
+ public String getObject()
+ {
+ boolean error = Session.get()
+ .getFeedbackMessages()
+ .hasMessage(new IFeedbackMessageFilter()
+ {
+ public boolean accept(FeedbackMessage message)
+ {
+ return feedback.getFilter().accept(message) && message.isError();
+ }
+ });
+ return "border: 1px solid " + (error ? "red" : "green");
+ }
+ }));
+ addToBorder(brdr);
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ super.onBeforeRender();
+ }
+
+}
Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java
------------------------------------------------------------------------------
svn:eol-style = native