web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Struts2.3_AjaxTags</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
struts.properties
struts.custom.i18n.resources=messages
messages.properties
title=Struts2 Ajax Tags Example
fd=From Date
td=To Date
fm=Select Favourite Framework
label.button=Submit
tab1=Tab1
tab2=Tab2
tab3=Tab3
tab4=Tab4
fd=From Date
td=To Date
fm=Select Favourite Framework
label.button=Submit
tab1=Tab1
tab2=Tab2
tab3=Tab3
tab4=Tab4
AjaxTags.java
package com.usr.ajax;
import java.util.Date;
public class AjaxTags {
private Date fromDate;
private Date toDate;
private String yourFavFw;
public AjaxTags() {
}
public Date getFromDate() {
return fromDate;
}
public void setFromDate(Date fromDate) {
this.fromDate = fromDate;
}
public Date getToDate() {
return toDate;
}
public void setToDate(Date toDate) {
this.toDate = toDate;
}
public String execute(){
return "success";
}
public String getYourFavFw() {
return yourFavFw;
}
public void setYourFavFw(String yourFavFw) {
this.yourFavFw = yourFavFw;
}
}
index.html
import java.util.Date;
public class AjaxTags {
private Date fromDate;
private Date toDate;
private String yourFavFw;
public AjaxTags() {
}
public Date getFromDate() {
return fromDate;
}
public void setFromDate(Date fromDate) {
this.fromDate = fromDate;
}
public Date getToDate() {
return toDate;
}
public void setToDate(Date toDate) {
this.toDate = toDate;
}
public String execute(){
return "success";
}
public String getYourFavFw() {
return yourFavFw;
}
public void setYourFavFw(String yourFavFw) {
this.yourFavFw = yourFavFw;
}
}
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<!-- <meta http-equiv="Refresh" content="0;URL=ajaxTags.action"> -->
<title>Insert title here</title>
</head>
<body>
<a href="ajaxTags.action">Ajax Tags Demo</a>
</body>
</html>
ajaxTags.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="sf" uri="/struts-dojo-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<sf:head />
</head>
<body>
<h2>
<s:text name="title"></s:text>
</h2>
<s:form action="ajaxTagsAction">
<sf:datetimepicker name="fromDate" key="fd"></sf:datetimepicker>
<sf:datetimepicker name="toDate" key="td"></sf:datetimepicker>
<sf:autocompleter name="yourFavFw" key="fm"
list="{'Apache Wicket','Apache Click','Apache Cocoon','Spring MVC','Struts 1.x','Struts 2.x','JavaServer Faces (JSF)'}"></sf:autocompleter>
<s:submit key="label.button"></s:submit>
</s:form>
</body>
</html>
success.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sf" uri="/struts-dojo-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<sf:head />
</head>
<body>
<hr>
Date picker Tags
<br> From Date:
<s:property value="fromDate" />
<br> To Date:
<s:property value="toDate" />
<br>
<hr>
Auto completer Tags
<br> Your Favourite WebFramework:
<s:property value="yourFavFw" />
<br>
<hr>
<hr>
Tabbed panel Tags
<sf:tabbedpanel id="test">
<sf:div id="one" theme="ajax" key="tab1">
First Tab
</sf:div>
<sf:div id="two" theme="ajax" key="tab2">
Second Tab
</sf:div>
<sf:div id="three" theme="ajax" key="tab3">
Third Tab
</sf:div>
</sf:tabbedpanel>
</body>
</html>
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default"></include>
<package name="default" extends="struts-default">
<action name="ajaxTags">
<result>/WEB-INF/pages/ajaxTags.jsp</result>
</action>
<action name="ajaxTagsAction" class="com.usr.ajax.AjaxTags">
<result name="success">/WEB-INF/pages/success.jsp</result>
<result name="failure">/WEB-INF/pages/ajaxTags.jsp</result>
</action>
</package>
</struts>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.