alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Struts example source code file (index.jsp)

This example Struts source code file (index.jsp) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Struts tags/keywords

a, a, ajaxtest, alt, content, div, done, examples, loading, text, text, update, use, use

The Struts index.jsp source code

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<html>
<head>
    <title>Ajax Examples
    <jsp:include page="/ajax/commonInclude.jsp"/>
</head>

<script type="text/javascript">
   function before() {alert("before request");}
   function after() {alert("after request");}
   function handler(widget, node) {
     alert('I will handle this myself!');
     dojo.byId(widget.targetsArray[0]).innerHTML = "Done";
   }

    dojo.event.topic.subscribe("/alltopics", function(data, type, e){
      alert('inside a topic event. type='+type);
      //data : text returned
      //type : "before", "load" or "error"
      //e    : request object
   });
</script>

<body>

<div id="t1">Div 1
<s:url var="ajaxTest" value="/AjaxTest.action" /> <br/>
A submit button, that highlights (blue color) its targets <sx:submit type="submit" value="submit" targets="t1" href="%{ajaxTest}" highlightColor="blue"/> <br/>
A submit button, with an indicator <img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/> <sx:submit id="submit2" type="submit" value="submit" targets="t1" href="%{ajaxTest}" indicator="indicator"/> <br/>
A submit button, with "notifyTopics" <sx:submit type="submit" value="submit" targets="t1" href="%{ajaxTest}" notifyTopics="/alltopics"/> <br/>
Use an image as submit <s:url value="/images/struts-power.gif" var="imgUrl" /> <sx:submit type="image" label="Alt Text" targets="t1" src="%{imgUrl}" href="%{ajaxTest}" /> <br/>
<label for="textInput">Text to be echoed <br/>
Use a button as submit (custom text) <s:form id="form" action="AjaxTest"> <input type=textbox name="data"> <sx:submit type="button" label="Update Content" targets="t1" id="ajaxbtn"/> </s:form> <br/>
<s:include value="../footer.jsp"/> </body> </html>

Other Struts examples (source code examples)

Here is a short list of links related to this Struts index.jsp source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.