stationaction.java

来自「工厂版本管理系统,STRUTS2框架,用于管理商品的版本,便于有效的控制版本」· Java 代码 · 共 96 行

JAVA
96
字号
package com.utstar.fcs.web.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Preparable;
import com.utstar.fcs.domain.workinstruction.Station;
import com.utstar.fcs.domain.workinstruction.WorkInstruction;

public class StationAction extends BaseAction implements Preparable {

	// form1
	private Long id;
	private Long workInstructionId;
	private Station station = new Station();

	// data
	private List stationTypeList;

	public void prepare() throws Exception {
		stationTypeList = getWorkInstructionService().getAllStationTypes();

	}

	public String input() {

		return INPUT;
	}

	public String edit() {

		station = getWorkInstructionService().loadStationWithVersions(id);
		
		return INPUT;
	}

	public String save() {
		HttpServletRequest request = ServletActionContext.getRequest();
		String name = request.getParameter("station.name");
		
		if (station.getId() == null) {

			WorkInstruction wi = (WorkInstruction) getReposity().get(
					WorkInstruction.class, workInstructionId);
			wi.addStation(station);

			getReposity().save(station);
		} else{
			Station entity = (Station)getReposity().get(Station.class, station.getId());
			
			entity.setName(station.getName());
			entity.setStationType(station.getStationType());
			
			getReposity().update(entity);
		}
		
		return "autoclose";
	}

	public Station getStation() {
		return station;
	}

	public void setStation(Station station) {
		this.station = station;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List getStationTypeList() {
		return stationTypeList;
	}

	public void setStationTypeList(List stationTypeList) {
		this.stationTypeList = stationTypeList;
	}

	public Long getWorkInstructionId() {
		return workInstructionId;
	}

	public void setWorkInstructionId(Long workInstructionId) {
		this.workInstructionId = workInstructionId;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?