WW-1658 Create a general purpose "Bind" tag

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@526300 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Musachy Barroso
2007-04-06 22:29:44 +00:00
parent 81525eef2d
commit 57d82a8a70
23 changed files with 1723 additions and 1132 deletions
@@ -0,0 +1,213 @@
/*
* $Id$
*
* 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.struts2.dojo.components;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
import com.opensymphony.xwork2.util.ValueStack;
/**
* <!-- START SNIPPET: javadoc -->
* <p>
* This tag will generated event listeners for multiple events on multiple sources,
* making an asynchronous request to the specified href, and updating multiple targets.
* </p>
* <!-- END SNIPPET: javadoc -->
* <p>Examples</p>
* <!-- START SNIPPET: example1 -->
* <pre>
* &lt;img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/&gt;
* &lt;sx:bind id="ex1" href="%{#ajaxTest}" sources="button" targets="div1" events="onclick" indicator="indicator" /&gt;
* &lt;s:submit theme="simple" type="submit" value="submit" id="button"/&gt;
* </pre>
* <!-- END SNIPPET: example1 -->
* <!-- START SNIPPET: example2 -->
* <pre>
* &lt;sx:bind id="ex3" href="%{#ajaxTest}" sources="chk1" targets="div1" events="onchange" formId="form1" /&gt;
* &lt;form id="form1"&gt;
* &lt;s:checkbox name="data" label="Hit me" id="chk1"/&gt;
* &lt;/form>
* </pre>
* <!-- START SNIPPET: example2 -->
*/
@StrutsTag(name="bind", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.BindTag", description="Attach event listeners to elements to make AJAX calls")
@StrutsTagSkipInheritance
public class Bind extends AbstractRemoteCallUIBean {
public static final String TEMPLATE = "bind-close";
public static final String OPEN_TEMPLATE = "bind";
protected String targets;
protected String sources;
protected String events;
public Bind(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
super(stack, request, response);
}
public String getDefaultOpenTemplate() {
return OPEN_TEMPLATE;
}
protected String getDefaultTemplate() {
return TEMPLATE;
}
public void evaluateExtraParams() {
super.evaluateExtraParams();
if(targets != null)
addParameter("targets", findString(targets));
if(sources != null)
addParameter("sources", findString(sources));
if(events != null)
addParameter("events", findString(events));
}
@StrutsTagAttribute(description="Comma delimited list of event names to attach to", required=true)
public void setEvents(String events) {
this.events = events;
}
@StrutsTagAttribute(description="Comma delimited list of ids of the elements to attach to", required=true)
public void setSources(String sources) {
this.sources = sources;
}
@StrutsTagAttribute(description="Comma delimited list of ids of the elements whose content will be updated")
public void setTargets(String targets) {
this.targets = targets;
}
@Override
@StrutsTagSkipInheritance
public void setTheme(String theme) {
super.setTheme(theme);
}
@Override
public String getTheme() {
return "ajax";
}
@StrutsTagAttribute(description="Topic that will trigger the remote call")
public void setListenTopics(String listenTopics) {
this.listenTopics = listenTopics;
}
@StrutsTagAttribute(description="The URL to call to obtain the content. Note: If used with ajax context, the value must be set as an url tag value.")
public void setHref(String href) {
this.href = href;
}
@StrutsTagAttribute(description="The text to display to the user if the is an error fetching the content")
public void setErrorText(String errorText) {
this.errorText = errorText;
}
@StrutsTagAttribute(description="Javascript code in the fetched content will be executed", type="Boolean", defaultValue="false")
public void setExecuteScripts(String executeScripts) {
this.executeScripts = executeScripts;
}
@StrutsTagAttribute(description="Text to be shown while content is being fetched", defaultValue="Loading...")
public void setLoadingText(String loadingText) {
this.loadingText = loadingText;
}
@StrutsTagAttribute(description="Javascript function name that will make the request")
public void setHandler(String handler) {
this.handler = handler;
}
@StrutsTagAttribute(description="Function name used to filter the fields of the form.")
public void setFormFilter(String formFilter) {
this.formFilter = formFilter;
}
@StrutsTagAttribute(description="Form id whose fields will be serialized and passed as parameters")
public void setFormId(String formId) {
this.formId = formId;
}
@StrutsTagAttribute(description="Comma delimmited list of topics that will published before and after the request, and on errors")
public void setNotifyTopics(String notifyTopics) {
this.notifyTopics = notifyTopics;
}
@StrutsTagAttribute(description="Set whether errors will be shown or not", type="Boolean", defaultValue="true")
public void setShowErrorTransportText(String showError) {
this.showErrorTransportText = showError;
}
@StrutsTagAttribute(description="Id of element that will be shown while making request")
public void setIndicator(String indicator) {
this.indicator = indicator;
}
@StrutsTagAttribute(description="Show loading text on targets", type="Boolean", defaultValue="true")
public void setShowLoadingText(String showLoadingText) {
this.showLoadingText = showLoadingText;
}
@StrutsTagSkipInheritance
public void setCssClass(String cssClass) {
super.setCssClass(cssClass);
}
@StrutsTagSkipInheritance
public void setCssStyle(String cssStyle) {
super.setCssStyle(cssStyle);
}
@StrutsTagSkipInheritance
public void setName(String name) {
super.setName(name);
}
@StrutsTagAttribute(description="Comma delimmited list of topics that will published after the request(if the request succeeds)")
public void setAfterNotifyTopics(String afterNotifyTopics) {
this.afterNotifyTopics = afterNotifyTopics;
}
@StrutsTagAttribute(description="Comma delimmited list of topics that will published before the request")
public void setBeforeNotifyTopics(String beforeNotifyTopics) {
this.beforeNotifyTopics = beforeNotifyTopics;
}
@StrutsTagAttribute(description="Comma delimmited list of topics that will published after the request(if the request fails)")
public void setErrorNotifyTopics(String errorNotifyTopics) {
this.errorNotifyTopics = errorNotifyTopics;
}
@StrutsTagAttribute(description="The id to use for the element")
public void setId(String id) {
super.setId(id);
}
}
@@ -6,13 +6,14 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Head;
import org.apache.struts2.dojo.views.freemarker.tags.DojoModels;
import org.apache.struts2.dojo.views.velocity.components.AnchorDirective;
import org.apache.struts2.dojo.views.velocity.components.AutocompleterDirective;
import org.apache.struts2.dojo.views.velocity.components.BindDirective;
import org.apache.struts2.dojo.views.velocity.components.DateTimePickerDirective;
import org.apache.struts2.dojo.views.velocity.components.DivDirective;
import org.apache.struts2.dojo.views.velocity.components.FormDirective;
import org.apache.struts2.dojo.views.velocity.components.HeadDirective;
import org.apache.struts2.dojo.views.velocity.components.SubmitDirective;
import org.apache.struts2.dojo.views.velocity.components.TabbedPanelDirective;
import org.apache.struts2.dojo.views.velocity.components.TreeDirective;
@@ -40,7 +41,8 @@ public class DojoTagLibrary implements TagLibrary {
TreeDirective.class,
TreeNodeDirective.class,
FormDirective.class,
Head.class
HeadDirective.class,
BindDirective.class
};
return Arrays.asList(directives);
}
@@ -0,0 +1,43 @@
/*
* $Id: DivModel.java 471756 2006-11-06 15:01:43Z husted $
*
* 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.struts2.dojo.views.freemarker.tags;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Component;
import org.apache.struts2.dojo.components.Bind;
import org.apache.struts2.views.freemarker.tags.TagModel;
import com.opensymphony.xwork2.util.ValueStack;
/**
* @see Bind
*/
public class BindModel extends TagModel {
public BindModel(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
super(stack, req, res);
}
protected Component getBean() {
return new Bind(stack, req, res);
}
}
@@ -19,6 +19,7 @@ public class DojoModels {
protected AnchorModel a;
protected SubmitModel submit;
protected FormModel form;
protected BindModel bind;
private ValueStack stack;
private HttpServletRequest req;
@@ -30,6 +31,14 @@ public class DojoModels {
this.res = res;
}
public BindModel getBind() {
if (bind == null) {
bind = new BindModel(stack, req, res);
}
return bind;
}
public DateTimePickerModel getDatetimepicker() {
if (dateTimePicker == null) {
dateTimePicker = new DateTimePickerModel(stack, req, res);
@@ -0,0 +1,60 @@
/*
* $Id$
*
* 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.struts2.dojo.views.jsp.ui;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Component;
import org.apache.struts2.dojo.components.Bind;
import com.opensymphony.xwork2.util.ValueStack;
public class BindTag extends AbstractRemoteCallUITag {
protected String targets;
protected String sources;
protected String events;
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new Bind(stack, req, res);
}
protected void populateParams() {
super.populateParams();
Bind bind = (Bind) component;
bind.setTargets(targets);
bind.setSources(sources);
bind.setEvents(events);
}
public void setEvents(String events) {
this.events = events;
}
public void setSources(String sources) {
this.sources = sources;
}
public void setTargets(String targets) {
this.targets = targets;
}
}
@@ -0,0 +1,43 @@
/*
* $Id$
*
* 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.struts2.dojo.views.velocity.components;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Component;
import org.apache.struts2.dojo.components.Bind;
import org.apache.struts2.views.velocity.components.AbstractDirective;
import com.opensymphony.xwork2.util.ValueStack;
/**
* @see Bind
*/
public class BindDirective extends AbstractDirective {
public String getBeanName() {
return "bind";
}
protected Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new Bind(stack, req, res);
}
}
@@ -1,7 +1,7 @@
dojo.provide("struts.widget.Bind");
dojo.require("dojo.widget.HtmlWidget");
dojo.require("dojo.io");
dojo.require("dojo.io.*");
dojo.widget.defineWidget(
"struts.widget.Bind",
@@ -34,7 +34,7 @@ dojo.widget.defineWidget(
formFilter : "",
formNode : null,
event : "",
events : "",
indicator : "",
parseContent : true,
@@ -77,14 +77,20 @@ dojo.widget.defineWidget(
this.targetsArray = this.targets.split(",");
}
if(!dojo.string.isBlank(this.event)) {
dojo.event.connect(this.domNode, this.event, function(evt) {
evt.preventDefault();
evt.stopPropagation();
self.reloadContents();
});
if(!dojo.string.isBlank(this.events)) {
var eventsArray = this.events.split(",");
if(eventsArray && this.domNode) {
dojo.lang.forEach(eventsArray, function(event){
dojo.event.connect(self.domNode, event, function(evt) {
evt.preventDefault();
evt.stopPropagation();
self.reloadContents();
});
});
}
}
if(dojo.string.isBlank(this.href) && dojo.string.isBlank(this.formId)) {
//no href and no formId, we must be inside a form
this.formNode = dojo.dom.getFirstAncestorByTag(this.domNode, "form");
@@ -111,12 +117,16 @@ dojo.widget.defineWidget(
var xmlParser = new dojo.xml.Parse();
dojo.lang.forEach(this.targetsArray, function(target) {
var node = dojo.byId(target);
node.innerHTML = text;
if(self.parseContent && text != self.loadingText){
var frag = xmlParser.parseElement(node, null, true);
dojo.widget.getParser().createSubComponents(frag, dojo.widget.byId(target));
}
if(node) {
node.innerHTML = text;
if(self.parseContent && text != self.loadingText){
var frag = xmlParser.parseElement(node, null, true);
dojo.widget.getParser().createSubComponents(frag, dojo.widget.byId(target));
}
} else {
self.log("Unable to find target: " + node);
}
});
}
},
@@ -187,11 +197,11 @@ dojo.widget.defineWidget(
var self = this;
if(topicsArray) {
dojo.lang.forEach(topicsArray, function(topic) {
try {
dojo.event.topic.publish(topic, data, type, e);
} catch(ex){
self.log(ex);
}
try {
dojo.event.topic.publish(topic, data, type, e);
} catch(ex){
self.log(ex);
}
});
}
},
@@ -1,7 +1,7 @@
dojo.provide("struts.widget.BindAnchor");
dojo.require("dojo.widget.HtmlWidget");
dojo.require("dojo.io");
dojo.require("dojo.io.*");
dojo.require("struts.widget.Bind");
dojo.widget.defineWidget(
@@ -9,7 +9,7 @@ dojo.widget.defineWidget(
struts.widget.Bind, {
widgetType : "BindAnchor",
event: "onclick",
events: "onclick",
postCreate : function() {
struts.widget.BindAnchor.superclass.postCreate.apply(this);
@@ -1,6 +1,6 @@
dojo.provide("struts.widget.BindDiv");
dojo.require("dojo.io");
dojo.require("dojo.io.*");
dojo.require("dojo.widget.ContentPane");
dojo.require("dojo.lang.timing.Timer");
@@ -0,0 +1,38 @@
dojo.provide("struts.widget.BindEvent");
dojo.require("struts.widget.Bind");
dojo.widget.defineWidget(
"struts.widget.BindEvent",
struts.widget.Bind, {
widgetType : "BindEvent",
sources: "",
postCreate : function() {
struts.widget.BindEvent.superclass.postCreate.apply(this);
var self = this;
if(!dojo.string.isBlank(this.events) && !dojo.string.isBlank(this.sources)) {
var eventsArray = this.events.split(",");
var sourcesArray = this.sources.split(",");
if(eventsArray && this.domNode) {
//events
dojo.lang.forEach(eventsArray, function(event) {
//sources
dojo.lang.forEach(sourcesArray, function(source) {
var sourceObject = dojo.byId(source);
if(sourceObject) {
dojo.event.connect(sourceObject, event, function(evt) {
evt.preventDefault();
evt.stopPropagation();
self.reloadContents();
});
}
});
});
}
}
}
});
@@ -1,7 +1,6 @@
dojo.provide("struts.widget.StrutsDatePicker");
dojo.require("dojo.widget.DropdownDatePicker");
dojo.requireLocalization("dojo.widget", "StrutsDatePicker");
dojo.widget.defineWidget(
"struts.widget.StrutsDatePicker",
dojo.widget.DropdownDatePicker, {
@@ -4,6 +4,7 @@ dojo.kwCompoundRequire({
"struts.widget.BindAnchor",
"struts.widget.ComboBox",
"struts.widget.StrutsTimePicker",
"struts.widget.StrutsDatePicker"]
"struts.widget.StrutsDatePicker",
"struts.widget.BindEvent"]
});
dojo.provide("struts.widget.*");
File diff suppressed because it is too large Load Diff
@@ -22086,7 +22086,7 @@ dojo.widget.defineWidget(
formFilter : "",
formNode : null,
event : "",
events : "",
indicator : "",
parseContent : true,
@@ -22129,14 +22129,20 @@ dojo.widget.defineWidget(
this.targetsArray = this.targets.split(",");
}
if(!dojo.string.isBlank(this.event)) {
dojo.event.connect(this.domNode, this.event, function(evt) {
evt.preventDefault();
evt.stopPropagation();
self.reloadContents();
});
if(!dojo.string.isBlank(this.events)) {
var eventsArray = this.events.split(",");
if(eventsArray && this.domNode) {
dojo.lang.forEach(eventsArray, function(event){
dojo.event.connect(self.domNode, event, function(evt) {
evt.preventDefault();
evt.stopPropagation();
self.reloadContents();
});
});
}
}
if(dojo.string.isBlank(this.href) && dojo.string.isBlank(this.formId)) {
//no href and no formId, we must be inside a form
this.formNode = dojo.dom.getFirstAncestorByTag(this.domNode, "form");
@@ -22163,12 +22169,16 @@ dojo.widget.defineWidget(
var xmlParser = new dojo.xml.Parse();
dojo.lang.forEach(this.targetsArray, function(target) {
var node = dojo.byId(target);
node.innerHTML = text;
if(self.parseContent && text != self.loadingText){
var frag = xmlParser.parseElement(node, null, true);
dojo.widget.getParser().createSubComponents(frag, dojo.widget.byId(target));
}
if(node) {
node.innerHTML = text;
if(self.parseContent && text != self.loadingText){
var frag = xmlParser.parseElement(node, null, true);
dojo.widget.getParser().createSubComponents(frag, dojo.widget.byId(target));
}
} else {
self.log("Unable to find target: " + node);
}
});
}
},
@@ -22239,11 +22249,11 @@ dojo.widget.defineWidget(
var self = this;
if(topicsArray) {
dojo.lang.forEach(topicsArray, function(topic) {
try {
dojo.event.topic.publish(topic, data, type, e);
} catch(ex){
self.log(ex);
}
try {
dojo.event.topic.publish(topic, data, type, e);
} catch(ex){
self.log(ex);
}
});
}
},
@@ -22827,7 +22837,7 @@ dojo.widget.defineWidget(
struts.widget.Bind, {
widgetType : "BindAnchor",
event: "onclick",
events: "onclick",
postCreate : function() {
struts.widget.BindAnchor.superclass.postCreate.apply(this);
@@ -27632,7 +27642,6 @@ dojo.widget.defineWidget(
dojo.provide("struts.widget.StrutsDatePicker");
dojo.widget.defineWidget(
"struts.widget.StrutsDatePicker",
dojo.widget.DropdownDatePicker, {
@@ -27653,13 +27662,53 @@ dojo.widget.defineWidget(
},
});
dojo.provide("struts.widget.BindEvent");
dojo.widget.defineWidget(
"struts.widget.BindEvent",
struts.widget.Bind, {
widgetType : "BindEvent",
sources: "",
postCreate : function() {
struts.widget.BindEvent.superclass.postCreate.apply(this);
var self = this;
if(!dojo.string.isBlank(this.events) && !dojo.string.isBlank(this.sources)) {
var eventsArray = this.events.split(",");
var sourcesArray = this.sources.split(",");
if(eventsArray && this.domNode) {
//events
dojo.lang.forEach(eventsArray, function(event) {
//sources
dojo.lang.forEach(sourcesArray, function(source) {
var sourceObject = dojo.byId(source);
if(sourceObject) {
dojo.event.connect(sourceObject, event, function(evt) {
evt.preventDefault();
evt.stopPropagation();
self.reloadContents();
});
}
});
});
}
}
}
});
dojo.kwCompoundRequire({
common: ["struts.widget.Bind",
"struts.widget.BindDiv",
"struts.widget.BindAnchor",
"struts.widget.ComboBox",
"struts.widget.StrutsTimePicker",
"struts.widget.StrutsDatePicker"]
"struts.widget.StrutsDatePicker",
"struts.widget.BindEvent"]
});
dojo.provide("struts.widget.*");
@@ -0,0 +1,47 @@
<script language="JavaScript" type="text/javascript">
dojo.addOnLoad(function() {
dojo.widget.createWidget("struts:BindEvent", {
"sources": "${parameters.sources?html}",
"events": "${parameters.events?html}",
<#if parameters.id?if_exists != "">
"id": "${parameters.id?html}",
</#if>
<#if parameters.formId?if_exists != "">
"formId": "${parameters.formId?html}",
</#if>
<#if parameters.formFilter?if_exists != "">
"formFilter": "${parameters.formFilter?html}",
</#if>
<#if parameters.href?if_exists != "">
"href": "${parameters.href}",
</#if>
<#if parameters.loadingText?if_exists != "">
"loadingText" : "${parameters.loadingText?html}",
</#if>
<#if parameters.errorText?if_exists != "">
"errorText" : "${parameters.errorText?html}",
</#if>
<#if parameters.executeScripts?exists>
"executeScripts": "${parameters.executeScripts?string?html}",
</#if>
<#if parameters.listenTopics?if_exists != "">
"listenTopics": "${parameters.listenTopics?html}",
</#if>
<#if parameters.notifyTopics?if_exists != "">
"notifyTopics": "${parameters.notifyTopics?html}",
</#if>
<#if parameters.targets?if_exists != "">
"targets": "${parameters.targets?html}",
</#if>
<#if parameters.indicator?if_exists != "">
"indicator": "${parameters.indicator?html}",
</#if>
<#if parameters.showErrorTransportText?exists>
"showError": "${parameters.showErrorTransportText?string?html}",
</#if>
<#if parameters.handler?if_exists != "">
"handler": "${parameters.handler?html}"
</#if>
});
});
</script>
@@ -5,11 +5,6 @@ dojo.hostenv.setModulePrefix('struts', 'struts');
dojo.require('dojo.widget.*');
dojo.widget.manager.registerWidgetPackage('struts.widget');
dojo.require("struts.widget.Bind");
dojo.require("struts.widget.BindDiv");
dojo.require("struts.widget.BindAnchor");
dojo.require("struts.widget.ComboBox");
dojo.require("struts.widget.StrutsTimePicker")
dojo.require("struts.widget.StrutsDatePicker")
dojo.require("struts.widget.*");
dojo.require("dojo.widget.Editor2");
dojo.hostenv.writeIncludes(); // not needed, but allows the Venkman debugger to work with the includes
@@ -1,5 +1,5 @@
<#if parameters.type?exists && parameters.type=="button">
<input type="button" dojoType="struts:Bind" event="onclick"<#rt/>
<input type="button" dojoType="struts:Bind" events="onclick"<#rt/>
<#include "/${parameters.templateDir}/ajax/ajax-common.ftl"/>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl"/>
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
@@ -9,7 +9,7 @@
/>
<#else>
<#if parameters.type?exists && parameters.type=="image">
<input type="image" dojoType="struts:Bind" event="onclick"<#rt/>
<input type="image" dojoType="struts:Bind" events="onclick"<#rt/>
<#if parameters.label?if_exists != "">
alt="${parameters.label?html}"<#rt/>
</#if>
@@ -17,7 +17,7 @@
src="${parameters.src?html}"<#rt/>
</#if>
<#else>
<input type="submit" dojoType="struts:Bind" event="onclick"<#rt/>
<input type="submit" dojoType="struts:Bind" events="onclick"<#rt/>
</#if>
<#if parameters.nameValue?if_exists != "">
value="${parameters.nameValue?html}"<#rt/>
@@ -0,0 +1,33 @@
package org.apache.struts2.dojo.views.jsp.ui;
import org.apache.struts2.dojo.TestAction;
public class BindTest extends AbstractUITagTest {
public void testSubmit() throws Exception {
TestAction testAction = (TestAction) action;
testAction.setFoo("bar");
BindTag tag = new BindTag();
tag.setPageContext(pageContext);
tag.setId("a");
tag.setHref("b");
tag.setLoadingText("c");
tag.setErrorText("d");
tag.setListenTopics("e");
tag.setBeforeNotifyTopics("f");
tag.setAfterNotifyTopics("g");
tag.setHandler("h");
tag.setLabel("i");
tag.setNotifyTopics("k");
tag.setIndicator("l");
tag.setShowLoadingText("true");
tag.setErrorNotifyTopics("m");
tag.setSources("n");
tag.setEvents("o");
tag.doStartTag();
tag.doEndTag();
verify(BindTest.class.getResource("Bind-1.txt"));
}
}
@@ -0,0 +1,17 @@
<script language="JavaScript" type="text/javascript">
dojo.addOnLoad(function() {
dojo.widget.createWidget("struts:BindEvent", {
"sources":"n",
"events":"o",
"id":"a",
"href":"b",
"loadingText":"c",
"errorText":"d",
"listenTopics":"e",
"notifyTopics":"k",
"indicator":"l",
"showError":"true",
"handler":"h"
});
});
</script>
@@ -1,7 +1,7 @@
<input
type="submit"
dojoType="struts:Bind"
event="onclick"
events="onclick"
value="Submit"
id="a"
label="i"
@@ -1,7 +1,7 @@
<input
type="button"
dojoType="struts:Bind"
event="onclick"
events="onclick"
id="a"
label="i"
href="b"
@@ -1,7 +1,7 @@
<input
type="image"
dojoType="struts:Bind"
event="onclick"
events="onclick"
alt="i"
src="j"
value="Submit"