You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2007/06/30 07:37:32 UTC
[Tapestry Wiki] Update of "PopupLinkSubmit" by ErikVullings
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by ErikVullings:
http://wiki.apache.org/tapestry/PopupLinkSubmit
------------------------------------------------------------------------------
This is a solution for submitting a form and at the same time open a popup with an external link. It is a little lousy since it requires alot of copy paste from Tapestry code. I hope this can look better with future Tapestry versions.
- === Example ===
+ === Example===
{{{
<a href="#" jwcid="@PopupLinkSubmit" parameters="ognl:article" listener="listener:acheterArticle" popuppage="PopupPanier" popupparameters="ognl:article.AR_Design">Acheter</a>
}}}
- === PopupLinkSubmit.jwc ===
- {{{
- <!DOCTYPE component-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN" "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
- <component-specification class="actualis.web.tapestry.components.PopupLinkSubmit" allow-body="yes" allow-informal-parameters="yes" deprecated="no">
-
- <description>
- Creates a hyperlink that submits its enclosing form using JavaScript.
- </description>
-
- <parameter name="disabled"/>
- <parameter name="selected"/>
- <parameter name="tag"/>
- <parameter name="id" property="idParameter" default-value="id"/>
-
- <parameter name="listener">
- <description>
- A listener that is notified if this component is triggered.
- </description>
- </parameter>
- <parameter name="action">
- <description>
- A listener that is notified if this component is triggered
- just before the form's listener, after all components
- enclosed by the Form have had a chance to update their properties.
- </description>
- </parameter>
- <parameter name="parameters">
- <description>
- An object, or list of objects, gathered when the link is triggered and
- made available as listener parameters in the request cycle, making
- the parameters available to a deferred listener.
- </description>
- </parameter>
-
- <parameter name="popuppage" property="popupPage" required="yes"/>
-
- <parameter name="popupparameters" property="popupParameters" required="no"/>
-
- <reserved-parameter name="name"/>
- <reserved-parameter name="href"/>
-
- <inject property="listenerInvoker" object="infrastructure:listenerInvoker"/>
- <inject property="script" type="script" object="PopupLinkSubmit.script"/>
-
- </component-specification>
-
- }}}
-
- === PopupLinkSubmit.script ===
- {{{
- <?xml version="1.0"?>
- <!DOCTYPE script PUBLIC
- "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
- "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd">
- <script>
-
- <input-symbol key="name" class="java.lang.String" required="yes"/>
- <input-symbol key="popupLink" class="java.lang.String" required="yes"/>
- <input-symbol key="form" class="org.apache.tapestry.IForm" required="yes"/>
-
- <let key="href">
- javascript:submitPopupLink('${form.name}', '${name}','${popupLink}');
- </let>
-
- </script>
- }}}
{{{
package actualis.web.tapestry.components;
@@ -103, +37 @@
/**
* Implements a component that submits its enclosing form via a JavaScript link. [<a
* href="../../../../../ComponentReference/LinkSubmit.html">Component Reference</a>]
- *
+ *
* @author Richard Lewis-Shell
* @version $Id$
*/
@@ -168, +102 @@
builder.addln("function {0}(form, elementId, url)", "submitPopupLink");
builder.begin();
- builder.addln("var form = document.getElementById(form);");
+ builder.addln("var form = document.getElementById(form);");
- builder.addln("form.events.submit(elementId);");
+ builder.addln("form.events.submit(elementId);");
builder.addln("aWindow = window.open(url, '" + PopupDirectLink.POPUP_WINDOWNAME
+ "', " + PopupDirectLink.POPUP_FEATURES + ", false);");
builder.addln("aWindow.focus();");
@@ -259, +193 @@
* Copy of AbstractSubmit
*/
public abstract class CustomSubmit extends AbstractFormComponent {
-
+
/**
* Determine if this submit component was clicked.
- *
+ *
* @param cycle
* @param name
* @return true if this submit was clicked
@@ -277, +211 @@
if (isClicked(cycle, getName()))
handleClick(cycle, getForm());
}
-
+
void handleClick(final IRequestCycle cycle, IForm form)
{
if (isParameterBound("selected"))
@@ -308, +242 @@
// Invoke 'listener' now, but defer 'action' for later
if (listener != null)
listenerInvoker.invokeListener(listener, CustomSubmit.this, cycle);
-
+
if (action != null) {
Runnable notify = new Runnable()
{
@@ -317, +251 @@
listenerInvoker.invokeListener(action, CustomSubmit.this, cycle);
}
};
-
+
form.addDeferredRunnable(notify);
}
}
@@ -341, +275 @@
public abstract Object getParameters();
/** Injected */
- public abstract ListenerInvoker getListenerInvoker();
+ public abstract ListenerInvoker getListenerInvoker();
}
}}}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org