Wednesday, September 8, 2010

Struts with netbeans - part 1


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
person

struts2

org.apache.struts2.dispatcher.FilterDispatcher




struts2
/*




index.jsp





"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">





/pages/insertSuccessful.jsp






/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package action;

import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import model.Person;
import service.PersonService;
import service.PersonServiceImpl;

/**
*
* @author DELL
*/
public class PersonAction extends ActionSupport{

private PersonService service;
private List persons;
private Person person;
private int id;
private String firstName;
private String lastName;
private int age;

public String save(){
service = new PersonServiceImpl();
person = new Person();
person.setAge(age);
person.setFirstName(firstName);
person.setLastName(lastName);
service.save(person);
return SUCCESS;
}

/**
* @return the service
*/
public PersonService getService() {
return service;
}

/**
* @param service the service to set
*/
public void setService(PersonService service) {
this.service = service;
}

/**
* @return the persons
*/
public List getPersons() {
return persons;
}

/**
* @param persons the persons to set
*/
public void setPersons(List persons) {
this.persons = persons;
}

/**
* @return the person
*/
public Person getPerson() {
return person;
}

/**
* @param person the person to set
*/
public void setPerson(Person person) {
this.person = person;
}

/**
* @return the id
*/
public int getId() {
return id;
}

/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}

/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}

/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}

/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}

/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}

/**
* @return the age
*/
public int getAge() {
return age;
}

/**
* @param age the age to set
*/
public void setAge(int age) {
this.age = age;
}
}



<%--
Document : input
Created on : Sep 7, 2010, 6:41:26 PM
Author : DELL
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
"http://www.w3.org/TR/html4/loose.dtd">




JSP Page













<%--
Document : response
Created on : Sep 7, 2010, 6:41:41 PM
Author : DELL
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
"http://www.w3.org/TR/html4/loose.dtd">




JSP Page


Insert Successful






Average Age





List of Customers





<%--
Document : input
Created on : Sep 7, 2010, 6:41:26 PM
Author : DELL
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
"http://www.w3.org/TR/html4/loose.dtd">




JSP Page






">







Home
















commons-fileupload-1.2.1
commons-logging-1.0.4
freemarker-2.3.13
mysql-connector-java-5.0.7-bin
ognl-2.6.11
struts2-core-2.1.6
xwork-2.1.2

web-inf/classes ------- struts.xml
web-inf/lib libraries



download

http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html

0 comments: