THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
<s:div id="div" /> <!-- With a submitbind tag --> <s:submit value="Make Request" id="submit" /> <sx:bind highlightColor="blue" highlightDuration="2000" targets="div" sources="submit" events="onclick" href="%{#url}" /> <!-- With a submit tag --> <sx:submit highlightColor="blue" highlightDuration="2000" targets="div" href="%{#url}" /> <!-- With an anchor tag --> <sx:a highlightColor="blue" highlightDuration="2000" targets="div" href="%{#url}" /> |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<script type="text/javascript"> dojo.event.topic.subscribe("/before", function(event, widget){ alert('inside a topic event. before request'); //event: event object //widget: widget that published the topic }); </script> <!-- With a bind tag --> <s:submit value="Make Request" id="submit" /> <sx:bind beforeNotifyTopics="/before" sources="submit" events="onclick" href="%{#url}" /> <!-- With a submit tag --> <sx:submit beforeNotifyTopics="/before" href="%{#url}" /> <!-- With an anchor tag --> <sx:a beforeNotifyTopics="/before" href="%{#url}" /> |
Publish a topic
...
after the request
Code Block | ||||
---|---|---|---|---|
| ||||
<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 //request: XMLHttpRequest object //widget: widget that published the topic }); </script> <!-- With a bind tag --> <s:submit value="Make Request" id="submit" /> <sx:bind afterNotifyTopics="/after" sources="submit" events="onclick" href="%{#url}" /> <!-- With a submit tag --> <sx:submit afterNotifyTopics="/after" href="%{#url}" /> <!-- With an anchor tag --> <sx:a afterNotifyTopics="/after" href="%{#url}" /> |
Publish a topic on error
Code Block | ||||
---|---|---|---|---|
| ||||
<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> <!-- With a bind tag --> <s:submit value="Make Request" id="submit" /> <sx:bind errorNotifyTopics="/error" sources="submit" events="onclick" href="%{#url}" /> <!-- With a submit tag --> <sx:submit errorNotifyTopics="/error" href="%{#url}" /> <!-- With an anchor tag --> <sx:a errorNotifyTopics="/error" href="%{#url}" /> |
Show a fixed error message on error
Code Block | ||||
---|---|---|---|---|
| ||||
<div id="div" />
<!-- With a bind tag -->
<s:submit value="Make Request" id="submit" />
<sx:bind errorText="Error Loading" targets="div" sources="submit" events="onclick" href="%{#url}" />
<!-- With a submit tag -->
<sx:submit errorText="Error Loading" targets="div" href="%{#url}" />
<!-- With an anchor tag -->
<sx:a errorText="Error Loading" targets="div" href="%{#url}" />
|
Prevent a request
Code Block | ||||
---|---|---|---|---|
| ||||
<script type="text/javascript"> dojo.event.topic.subscribe("/before", function(event, widget){ alert('I will stop this request'); event.cancel = true; }); </script> <!-- With a bind tag --> <s:submit value="Make Request" id="submit" /> <sx:bind beforeNotifyTopics="/before" sources="submit" events="onclick" href="%{#url}" /> <!-- With a submit tag --> <sx:submit beforeNotifyTopics="/before" href="%{#url}" /> <!-- With an anchor tag --> <sx:a beforeNotifyTopics="/before" href="%{#url}" /> |
Submit a form (plain form)
Code Block | ||||
---|---|---|---|---|
| ||||
<form id="form"> <input type=textbox name="data"> </form> <!-- With a bind tag --> <s:submit value="Make Request" id="submit" /> <sx:bind formId="form" sources="submit" events="onclick" href="%{#url}" /> <!-- With a submit tag --> <sx:submit formId="form" href="%{#url}" /> <!-- With an anchor tag --> <sx:a formId="form" href="%{#url}" /> |
Submit a form (using s:form tag)
Code Block | ||||
---|---|---|---|---|
| ||||
<!-- With a submit tag --> <s:form namespace="/mynamespace" action="MyAction"> <input type=textbox name="data"> <sx:submit /> </s:form> <!-- With an anchor tag --> <s:form namespace="/mynamespace" action="MyAction"> <input type=textbox name="data"> <sx:a /> </s:form> |