You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by kn...@apache.org on 2009/11/22 18:50:15 UTC
svn commit: r883110 - in /wicket/trunk:
wicket-examples/src/main/java/org/apache/wicket/examples/ng/
wicket-examples/src/main/webapp/ wicket-examples/src/main/webapp/WEB-INF/
wicket/src/main/java/org/apache/wicket/ajax/
Author: knopp
Date: Sun Nov 22 17:50:14 2009
New Revision: 883110
URL: http://svn.apache.org/viewvc?rev=883110&view=rev
Log: (empty)
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/NGApplication.java
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage1.java
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage2.java
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage3.java
Modified:
wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml
wicket/trunk/wicket-examples/src/main/webapp/index.html
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/NGApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/NGApplication.java?rev=883110&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/NGApplication.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/NGApplication.java Sun Nov 22 17:50:14 2009
@@ -0,0 +1,33 @@
+package org.apache.wicket.examples.ng;
+
+import org.apache.wicket.ng.markup.html.link.ILinkListener;
+import org.apache.wicket.ng.protocol.http.WebApplication;
+import org.apache.wicket.ng.request.component.RequestablePage;
+import org.apache.wicket.ng.request.listener.RequestListenerInterface;
+import org.apache.wicket.ng.request.mapper.MountedMapper;
+
+public class NGApplication extends WebApplication
+{
+
+ public NGApplication()
+ {
+ super();
+ }
+
+ @Override
+ public void init()
+ {
+ mount(new MountedMapper("first-test-page", TestPage1.class));
+ mount(new MountedMapper("third-test-page", TestPage3.class));
+
+ // load the interface
+ RequestListenerInterface i = ILinkListener.INTERFACE;
+ }
+
+ @Override
+ public Class<? extends RequestablePage> getHomePage()
+ {
+ return TestPage1.class;
+ }
+
+}
Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage1.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage1.java?rev=883110&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage1.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage1.java Sun Nov 22 17:50:14 2009
@@ -0,0 +1,116 @@
+package org.apache.wicket.examples.ng;
+
+import org.apache.wicket.ng.Page;
+import org.apache.wicket.ng.markup.html.link.Link;
+import org.apache.wicket.ng.request.cycle.RequestCycle;
+
+public class TestPage1 extends Page
+{
+ private static final long serialVersionUID = 1L;
+
+ public TestPage1()
+ {
+ Link l1 = new Link("l1")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onLinkClicked()
+ {
+ System.out.println("link 1 clicked");
+ getPageParameters().setNamedParameter("p1", "v1");
+ getPageParameters().setIndexedParameter(0, "indexed1");
+ getPageParameters().setIndexedParameter(1, "indexed2");
+ getPageParameters().setIndexedParameter(2, "indexed3");
+
+ // necessary on stateless page
+ if (getPage().isPageStateless())
+ RequestCycle.get().setResponsePage(getPage());
+ }
+ };
+ l1.setBookmarkable(isPageStateless());
+ l1.setLabel("Link 1 - Add Some Parameters");
+ add(l1);
+
+ Link l2 = new Link("l2")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onLinkClicked()
+ {
+ System.out.println("link 2 clicked");
+ getPageParameters().removeNamedParameter("p1");
+ getPageParameters().clearIndexedParameters();
+
+ if (getPage().isPageStateless())
+ // necessary on stateless page
+ RequestCycle.get().setResponsePage(getPage());
+ }
+ };
+ l2.setLabel("Link 2 - Remove The Parameters (this link is bookmarkable listener interface!)");
+ l2.setBookmarkable(true);
+ add(l2);
+
+
+ Link l3 = new Link("l3")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onLinkClicked()
+ {
+ System.out.println("link 3 clicked");
+ RequestCycle.get().setResponsePage(new TestPage2());
+ }
+ };
+ // l3.setBookmarkable(true);
+ l3.setLabel("Link 3 - Go to Test Page 2 - Not mounted, Not bookmarkable");
+ add(l3);
+
+
+ Link l4 = new Link("l4")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onLinkClicked()
+ {
+ System.out.println("link 4 clicked");
+ RequestCycle.get().setResponsePage(TestPage2.class, null);
+ }
+ };
+ l4.setLabel("Link 4 - Go to Test Page 2 - Not mounted, Bookmarkable");
+ add(l4);
+
+
+ Link l5 = new Link("l5")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onLinkClicked()
+ {
+ System.out.println("link 5 clicked");
+ TestPage3 page = new TestPage3(TestPage1.this);
+ page.getPageParameters().setIndexedParameter(0, "i1");
+ page.getPageParameters().setIndexedParameter(1, "i2");
+ page.getPageParameters().setIndexedParameter(2, "i3");
+ RequestCycle.get().setResponsePage(page);
+ }
+ };
+ l5.setLabel("Link 5 - Go to Test Page 3 - Mounted");
+ add(l5);
+ }
+
+ private boolean rendered = false;
+
+ @Override
+ public void renderPage()
+ {
+ super.renderPage();
+ rendered = true;
+ }
+
+ @Override
+ public boolean isPageStateless()
+ {
+ return false;
+// return !rendered;
+ }
+}
Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage2.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage2.java?rev=883110&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage2.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage2.java Sun Nov 22 17:50:14 2009
@@ -0,0 +1,15 @@
+package org.apache.wicket.examples.ng;
+
+import org.apache.wicket.ng.Page;
+
+public class TestPage2 extends Page
+{
+
+ private static final long serialVersionUID = 1L;
+
+ public TestPage2()
+ {
+
+ }
+
+}
Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage3.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage3.java?rev=883110&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage3.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ng/TestPage3.java Sun Nov 22 17:50:14 2009
@@ -0,0 +1,30 @@
+package org.apache.wicket.examples.ng;
+
+import org.apache.wicket.ng.Page;
+import org.apache.wicket.ng.markup.html.form.Form;
+import org.apache.wicket.ng.markup.html.link.Link;
+import org.apache.wicket.ng.request.cycle.RequestCycle;
+
+public class TestPage3 extends Page
+{
+ private static final long serialVersionUID = 1L;
+
+ public TestPage3(final Page back)
+ {
+ Link b = new Link("back")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onLinkClicked()
+ {
+ RequestCycle.get().setResponsePage(back);
+ }
+ };
+ b.setLabel("Go Back");
+ add(b);
+
+ Form form = new Form("form");
+ add(form);
+ }
+
+}
Modified: wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml?rev=883110&r1=883109&r2=883110&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml (original)
+++ wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml Sun Nov 22 17:50:14 2009
@@ -435,6 +435,22 @@
</init-param>
</filter>
+ <filter>
+ <filter-name>WicketNGApplication</filter-name>
+ <filter-class>org.apache.wicket.ng.protocol.http.WicketFilter</filter-class>
+ <init-param>
+ <param-name>applicationClassName</param-name>
+ <param-value>org.apache.wicket.examples.ng.NGApplication</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>WicketNGApplication</filter-name>
+ <url-pattern>/ng/*</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
<filter-mapping>
<filter-name>WicketExamplesMenuApplication</filter-name>
<url-pattern>/examples/*</url-pattern>
Modified: wicket/trunk/wicket-examples/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/webapp/index.html?rev=883110&r1=883109&r2=883110&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/webapp/index.html (original)
+++ wicket/trunk/wicket-examples/src/main/webapp/index.html Sun Nov 22 17:50:14 2009
@@ -59,6 +59,7 @@
<tr class="section"><td align="right"><a href="spring">spring</a></td><td> - Demonstrates integration options with the Spring framework.</td></tr>
<tr><td align="right"><a href="guice">guice</a></td><td> - Integration with the Google Guice IoC container.</td></tr>
<tr><td align="right"><a href="velocity">velocity</a></td><td> - Shows a Velocity panel in action.</td></tr>
+ <tr><td align="right"><a href="ng">new generation</a></td><td> - Shows simple example of new request cycle in action.</td></tr>
</tbody>
</table>
</div>
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java?rev=883110&r1=883109&r2=883110&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java Sun Nov 22 17:50:14 2009
@@ -226,9 +226,9 @@
private static final Logger LOG = LoggerFactory.getLogger(AjaxRequestTarget.class);
- private final List<String> appendJavascripts = new ArrayList<String>();
+ private final List<CharSequence> appendJavascripts = new ArrayList<CharSequence>();
- private final List<String> domReadyJavascripts = new ArrayList<String>();
+ private final List<CharSequence> domReadyJavascripts = new ArrayList<CharSequence>();
/**
* Create a response for component body and javascript that will escape output to make it safe
@@ -246,7 +246,7 @@
private final Map<String, Component> markupIdToComponent = new LinkedHashMap<String, Component>();
/** */
- private final List<String> prependJavascripts = new ArrayList<String>();
+ private final List<CharSequence> prependJavascripts = new ArrayList<CharSequence>();
/** a list of listeners */
private List<IListener> listeners = null;
@@ -343,18 +343,18 @@
{
for (final Component component : components)
{
- if (component == null)
- {
- throw new IllegalArgumentException("component cannot be null");
- }
- if (component.getOutputMarkupId() == false)
- {
- throw new IllegalArgumentException(
- "cannot update component that does not have setOutputMarkupId property set to true. Component: " +
- component.toString());
+ if (component == null)
+ {
+ throw new IllegalArgumentException("component cannot be null");
+ }
+ if (component.getOutputMarkupId() == false)
+ {
+ throw new IllegalArgumentException(
+ "cannot update component that does not have setOutputMarkupId property set to true. Component: " +
+ component.toString());
+ }
+ addComponent(component, component.getMarkupId());
}
- addComponent(component, component.getMarkupId());
- }
}
/**
@@ -428,7 +428,7 @@
*
* @param javascript
*/
- public final void appendJavascript(String javascript)
+ public final void appendJavascript(CharSequence javascript)
{
if (javascript == null)
{
@@ -489,7 +489,7 @@
*
* @param javascript
*/
- public final void prependJavascript(String javascript)
+ public final void prependJavascript(CharSequence javascript)
{
if (javascript == null)
{
@@ -572,10 +572,10 @@
fireOnBeforeRespondListeners();
// normal behavior
- Iterator<String> it = prependJavascripts.iterator();
+ Iterator<CharSequence> it = prependJavascripts.iterator();
while (it.hasNext())
{
- String js = it.next();
+ CharSequence js = it.next();
respondInvocation(response, js);
}
@@ -589,13 +589,13 @@
it = domReadyJavascripts.iterator();
while (it.hasNext())
{
- String js = it.next();
+ CharSequence js = it.next();
respondInvocation(response, js);
}
it = appendJavascripts.iterator();
while (it.hasNext())
{
- String js = it.next();
+ CharSequence js = it.next();
respondInvocation(response, js);
}
@@ -710,7 +710,7 @@
* @param str
* @return encoded string
*/
- protected String encode(String str)
+ protected String encode(CharSequence str)
{
if (str == null)
{
@@ -733,7 +733,7 @@
* @param str
* @return true if string needs to be encoded, false otherwise
*/
- protected boolean needsEncoding(String str)
+ protected boolean needsEncoding(CharSequence str)
{
/*
* TODO Post 1.2: Ajax: we can improve this by keeping a buffer of at least 3 characters and
@@ -743,8 +743,8 @@
* but this improvement will only work if we write first and encode later instead of working
* on fragments sent to write
*/
-
- return str.indexOf(']') >= 0;
+ // TODO: Would be nice not to have to call tostring here
+ return str.toString().indexOf(']') >= 0;
}
/**
@@ -1122,10 +1122,10 @@
* @param response
* @param js
*/
- private void respondInvocation(final Response response, final String js)
+ private void respondInvocation(final Response response, final CharSequence js)
{
boolean encoded = false;
- String javascript = js;
+ CharSequence javascript = js;
// encode the response if needed
if (needsEncoding(js))