Author: musachy Date: Tue May 1 14:02:01 2007 New Revision: 534243 URL: http://svn.apache.org/viewvc?view=rev&rev=534243 Log: Improve javadoc examples for Bind, and Anchor tags
Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java?view=diff&rev=534243&r1=534242&r2=534243 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java (original) +++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java Tue May 1 14:02:01 2007 @@ -73,21 +73,52 @@ * <!-- END SNIPPET: example3 --> * * <!-- START SNIPPET: example4 --> - * <p>Using topics:</p> + * <p>Using beforeNotifyTopics:</p> * <pre> - * <script type="text/javascript"> - * dojo.event.topic.subscribe("/before", function(data, type, e){ - * alert('inside a topic event. before request'); - * //data : source element id - * //type : "before" - * //e : request object - * //set e.cancel = true to cancel request + * <script type="text/javascript"> + * dojo.event.topic.subscribe("/before", function(event, widget){ + * alert('inside a topic event. before request'); + * //event: set event.cancel = true, to cancel request + * //widget: widget that published the topic * }); - * </script> + * </script> * * <sx:a beforeNotifyTopics="/before">Publish topics</sx:a> * </pre> * <!-- END SNIPPET: example4 --> + * + * <!-- START SNIPPET: example5 --> + * <p>Using afterNotifyTopics and highlight:</p> + * <pre> + * <script type="text/javascript"> + * dojo.event.topic.subscribe("/after", function(data, request, widget){ + * alert('inside a topic event. after request'); + * //data : text returned from request(the html) + * //request: XMLHttpRequest object + * //widget: widget that published the topic + * }); + * </script> + * + * <sx:a afterNotifyTopics="/after" highlightColor="red" href="%{#ajaxTest}">Publish topics</sx:a> + * </pre> + * <!-- END SNIPPET: example5 --> + * + * <!-- START SNIPPET: example6 --> + * <p>Using errorNotifyTopics and indicator:</p> + * <pre> + * <script type="text/javascript"> + * dojo.event.topic.subscribe("/error", function(error, request, widget){ + * alert('inside a topic event. on error'); + * //error : error object (error.message has the error message) + * //request: XMLHttpRequest object + * //widget: widget that published the topic + * }); + * </script> + * + * <img id="ind1" src="${pageContext.request.contextPath}/images/indicator.gif" style="display:none"/> + * <sx:a errorNotifyTopics="/error" indicator="ind1" href="%{#ajaxTest}">Publish topics</sx:a> + * </pre> + * <!-- END SNIPPET: example6 --> */ @StrutsTag(name="a", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.AnchorTag", description="Renders an HTML anchor element that when clicked calls a URL via remote XMLHttpRequest and updates " + "its targets content") Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java?view=diff&rev=534243&r1=534242&r2=534243 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java (original) +++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java Tue May 1 14:02:01 2007 @@ -52,6 +52,57 @@ * </form> * </pre> * <!-- START SNIPPET: example2 --> + * + * <!-- START SNIPPET: example4 --> + * <p>Using beforeNotifyTopics:</p> + * <pre> + * <script type="text/javascript"> + * dojo.event.topic.subscribe("/before", function(event, widget){ + * alert('inside a topic event. before request'); + * //event: set event.cancel = true, to cancel request + * //widget: widget that published the topic + * }); + * </script> + * + * <input type="button" id="button"> + * <sx:bind id="ex1" href="%{#ajaxTest}" beforeNotifyTopics="/before" sources="button" events="onclick"/> + * </pre> + * <!-- END SNIPPET: example4 --> + * + * <!-- START SNIPPET: example5 --> + * <p>Using afterNotifyTopics and highlight:</p> + * <pre> + * <script type="text/javascript"> + * dojo.event.topic.subscribe("/after", function(data, request, widget){ + * alert('inside a topic event. after request'); + * //data : text returned from request(the html) + * //request: XMLHttpRequest object + * //widget: widget that published the topic + * }); + * </script> + * + * <input type="button" id="button"> + * <sx:bind id="ex1" href="%{#ajaxTest}" highlightColor="red" afterNotifyTopics="/after" sources="button" events="onclick"/> + * </pre> + * <!-- END SNIPPET: example5 --> + * + * <!-- START SNIPPET: example6 --> + * <p>Using errorNotifyTopics and insicator:</p> + * <pre> + * <script type="text/javascript"> + * dojo.event.topic.subscribe("/error", function(error, request, widget){ + * alert('inside a topic event. on error'); + * //error : error object (error.message has the error message) + * //request: XMLHttpRequest object + * //widget: widget that published the topic + * }); + * </script> + * + * <input type="button" id="button"> + * <img id="ind1" src="${pageContext.request.contextPath}/images/indicator.gif" style="display:none"/> + * <sx:bind href="%{#ajaxTest}" indicator="ind1" errorNotifyTopics="/error" sources="button" events="onclick"/> + * </pre> + * <!-- END SNIPPET: example6 --> */ @StrutsTag(name="bind", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.BindTag", description="Attach event listeners to elements to make AJAX calls") @StrutsTagSkipInheritance