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 2008/08/26 19:52:28 UTC
svn commit: r689153 - in /wicket/sandbox/knopp/experimental:
wicket-examples/src/main/java/org/apache/wicket/ajax/
wicket/src/main/java/org/apache/wicket/ajaxng/
wicket/src/main/java/org/apache/wicket/ajaxng/markup/
wicket/src/main/java/org/apache/wick...
Author: knopp
Date: Tue Aug 26 10:52:27 2008
New Revision: 689153
URL: http://svn.apache.org/viewvc?rev=689153&view=rev
Log:
focus and more stuff
Added:
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/AjaxLink.java (with props)
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/IAjaxLink.java (with props)
Modified:
wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.html
wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.java
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/AjaxEventBehavior.java
wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java
Modified: wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.html
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.html?rev=689153&r1=689152&r2=689153&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.html (original)
+++ wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.html Tue Aug 26 10:52:27 2008
@@ -1,12 +1,21 @@
<html>
<head>
-
+<!--
+ <script type='text/javascript'
+ src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
+ -->
</head>
<body>
<div wicket:id="c1">
C1 DIV
+ <input id="i1" value="somelongtextinherebaby"/>
+ <input id="i2" value="somelongtextinherebaby"/>
+
</div>
+ <input id="i3" value="somelongtextinherebaby"/>
+ <input id="i4" value="somelongtextinherebaby"/>
+
<div id="div1">
DIV 1
</div>
@@ -20,69 +29,6 @@
</div>
</div>
- <a href="javascript:changestyle();">CS</a>
-
- <script type="text/javascript">
-
- var addStyle = function(style) {
-
- if (W.Y.UA.ie)
- {
- try
- {
- var last = document.styleSheets.length - 1;
- if (last > 0 && document.styleSheets[last].cssText.length < 30000)
- document.styleSheets[last].cssText = document.styleSheets[last].cssText + style;
- else
- document.createStyleSheet().cssText = style;
- }
- catch(e)
- {
- try {
- document.createStyleSheet().cssText = style;
- } catch (e) {
- try {
- var last = document.styleSheets.length - 1;
- document.styleSheets[last].cssText = document.styleSheets[last].cssText + style;
- } catch (error) {
-
- }
- }
- }
- }
- else
- {
- var head = document.getElementsByTagName("head")[0];
-
- var node = document.createElement("style");
- node.setAttribute("type", "text/css");
-
- var content = document.createTextNode(style);
- node.appendChild(content);
- head.appendChild(node);
- }
- }
-
- changestyle = function() {
-
- var s="";
-
- for (var i = 0; i < 30; ++i) {
- s+=(".d1 .d2 { background-color: red; } ");
- }
-
- //alert(s.length);
-
- for (var i = 0; i < 60; ++i) {
- addStyle(s);
- }
-
- addStyle(".d1 .d2 { background-color: red; }");
- addStyle(".d1 .d2 { background-color: blue; }");
- }
-
-
- </script>
</body>
Modified: wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.java?rev=689153&r1=689152&r2=689153&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.java (original)
+++ wicket/sandbox/knopp/experimental/wicket-examples/src/main/java/org/apache/wicket/ajax/TestPage1.java Tue Aug 26 10:52:27 2008
@@ -24,6 +24,7 @@
import org.apache.wicket.ajaxng.AjaxRequestAttributesImpl;
import org.apache.wicket.ajaxng.FunctionList;
import org.apache.wicket.ajaxng.request.AjaxRequestTarget;
+import org.apache.wicket.ajaxng.request.AjaxRequestTarget.ComponentEntry;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
@@ -103,9 +104,12 @@
* @see org.apache.wicket.ajaxng.AjaxBehavior#respond(org.apache.wicket.ajaxng.request.AjaxRequestTarget)
*/
@Override
- public void respond(AjaxRequestTarget target)
+ public void onEvent(AjaxRequestTarget target)
{
- target.addComponent(c1);
+ ComponentEntry e = new ComponentEntry(c1);
+ //e.setAfterReplaceJavascript("console.info(insertedElements); notify()");
+ target.addComponent(e);
+ //target.prependJavascript("console.info(requestQueueItem); alert('x');", false);
}
});
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/AjaxEventBehavior.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/AjaxEventBehavior.java?rev=689153&r1=689152&r2=689153&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/AjaxEventBehavior.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/AjaxEventBehavior.java Tue Aug 26 10:52:27 2008
@@ -17,6 +17,7 @@
package org.apache.wicket.ajaxng;
import org.apache.wicket.Component;
+import org.apache.wicket.ajaxng.request.AjaxRequestTarget;
import org.apache.wicket.markup.html.IHeaderResponse;
/**
@@ -41,6 +42,14 @@
}
@Override
+ public final void respond(AjaxRequestTarget target)
+ {
+ onEvent(target);
+ }
+
+ protected abstract void onEvent(AjaxRequestTarget target);
+
+ @Override
public void renderHead(Component component, IHeaderResponse response)
{
super.renderHead(component, response);
Added: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/AjaxLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/AjaxLink.java?rev=689153&view=auto
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/AjaxLink.java (added)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/AjaxLink.java Tue Aug 26 10:52:27 2008
@@ -0,0 +1,147 @@
+/*
+ * 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.ajaxng.markup.html;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.ajaxng.AjaxEventBehavior;
+import org.apache.wicket.ajaxng.request.AjaxRequestTarget;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.html.link.AbstractLink;
+import org.apache.wicket.model.IModel;
+
+/**
+ * A component that allows a trigger request to be triggered via html anchor tag
+ *
+ * @since 1.2
+ *
+ * @author Igor Vaynberg (ivaynberg)
+ *
+ */
+public abstract class AjaxLink<T> extends AbstractLink implements IAjaxLink
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param id
+ */
+ public AjaxLink(final String id)
+ {
+ this(id, null);
+ }
+
+ /**
+ * Construct.
+ *
+ * @param id
+ * @param model
+ */
+ public AjaxLink(final String id, final IModel<T> model)
+ {
+ super(id, model);
+
+ add(new AjaxEventBehavior("click")
+ {
+ private static final long serialVersionUID = 1L;
+
+
+ @Override
+ protected void onEvent(AjaxRequestTarget target)
+ {
+ onClick(target);
+ }
+
+ @Override
+ public boolean isEnabled(Component component)
+ {
+ return isLinkEnabled();
+ }
+ });
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag)
+ {
+ super.onComponentTag(tag);
+
+ if (isLinkEnabled())
+ {
+ // disable any href attr in markup
+ if (tag.getName().equalsIgnoreCase("a") || tag.getName().equalsIgnoreCase("link") ||
+ tag.getName().equalsIgnoreCase("area"))
+ {
+ tag.put("href", "#");
+ }
+ }
+ else
+ {
+ disableLink(tag);
+ }
+
+ }
+
+ /**
+ * Listener method invoked on the ajax request generated when the user clicks the link
+ *
+ * @param target
+ */
+ public abstract void onClick(final AjaxRequestTarget target);
+
+ /**
+ * Gets model
+ *
+ * @return model
+ */
+ @SuppressWarnings("unchecked")
+ public final IModel<T> getModel()
+ {
+ return (IModel<T>)getDefaultModel();
+ }
+
+ /**
+ * Sets model
+ *
+ * @param model
+ */
+ public final void setModel(IModel<T> model)
+ {
+ setDefaultModel(model);
+ }
+
+ /**
+ * Gets model object
+ *
+ * @return model object
+ */
+ @SuppressWarnings("unchecked")
+ public final T getModelObject()
+ {
+ return (T)getDefaultModelObject();
+ }
+
+ /**
+ * Sets model object
+ *
+ * @param object
+ */
+ public final void setModelObject(T object)
+ {
+ setDefaultModelObject(object);
+ }
+
+}
Propchange: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/AjaxLink.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/IAjaxLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/IAjaxLink.java?rev=689153&view=auto
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/IAjaxLink.java (added)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/IAjaxLink.java Tue Aug 26 10:52:27 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.ajaxng.markup.html;
+
+import org.apache.wicket.ajaxng.request.AjaxRequestTarget;
+
+/**
+ * Interface for Ajax callback links.
+ *
+ * @since 1.2
+ *
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Martijn Dashorst
+ */
+public interface IAjaxLink
+{
+ /**
+ * Listener method invoked on the ajax request generated when the user clicks the link
+ *
+ * @param target
+ * the request target.
+ */
+ void onClick(final AjaxRequestTarget target);
+}
Propchange: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/markup/html/IAjaxLink.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java?rev=689153&r1=689152&r2=689153&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajaxng/request/AjaxRequestTarget.java Tue Aug 26 10:52:27 2008
@@ -258,6 +258,8 @@
* <dd>RequestQueueItem instance for current request</dd>
* <dt>componentId</dt>
* <dd>MarkupId of component that has been replaced
+ * <dt>insertedElements</dt>
+ * <dd>Array of newly inserted elements</dd>
* <dt>notify</dt>
* <dd>Method that javascript needs to execute after it has finished. Note that it is
* mandatory to call this method otherwise the processing pipeline will stop</dd>
@@ -887,7 +889,22 @@
checkComponent(component);
- component.prepareForRender();
+ try
+ {
+ component.prepareForRender();
+ }
+ catch (RuntimeException e)
+ {
+ try
+ {
+ component.afterRender();
+ }
+ catch (RuntimeException e2)
+ {
+ // ignore this one could be a result off.
+ }
+ throw e;
+ }
}
}
@@ -948,15 +965,19 @@
}
else
{
- prepareRender();
-
- response.put("header", respondHeaderContribution());
-
JSONArray components = new JSONArray();
response.put("components", components);
- for (ComponentEntry entry : entries)
+
+ if (!entries.isEmpty())
{
- components.put(renderComponentEntry(entry));
+ prepareRender();
+
+ response.put("header", respondHeaderContribution());
+
+ for (ComponentEntry entry : entries)
+ {
+ components.put(renderComponentEntry(entry));
+ }
}
fireOnAfterRespondListeners(entries);