<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/jsps/common/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/application.css"></c:url>">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/form.css"></c:url>">
<style>
.error{
border:1px solid yellow;
color:red;
width:180px;
padding:8px;
margin:5px;
}
</style>
</head>
<body>
<s:actionerror cssClass="error" cssStyle="nowrap"/>
<div id="wrapper">
<div id="f_title">酒店房间登记</div>
<s:form namespace="/room" action="createRoom" method="post">
<div class="f_row">
<span>房间房号:</span>
<s:textfield name="room.roomNo"></s:textfield>
</div>
<div class="f_row">
<span>所属分店:</span>
<s:select name="room.hotel.hotelNo"
list="hotelList"
listKey="hotelNo"
listValue="hotelName"
headerKey="0"
headerValue="==请选择=="></s:select>
</div>
<div class="f_row">
<span>房间类型:</span>
<s:radio name="room.roomType" list="#{'a':'普单人间','b':'普双人间','c':'三人间','d':'商务套房','e':'贵宾套房'}"></s:radio>
</div>
<div class="f_row">
<span>屋内设施:</span>
<s:checkboxlist name="room.roomEquip" list="#{\"a\":'平面液晶电视',\"b\":'冰箱',\"c\":'空调',\"d\":'卫星电视',\"e\":'互联网接入',\"f\":'冲浪浴缸',\"g\":'观海景'}"></s:checkboxlist>
</div>
<div class="f_row">
<span>房间状态:</span>
<s:select name="room.roomStatus"
list="#{'a':'未入住','b':'有住客','c':'已预订','d':'保洁中','e':'已退房未保洁','f':'维护中'}"></s:select>
</div>
<div class="f_row">
<span>备注说明:</span>
<s:textarea name="room.roomMemo" rows="8" cols="60"></s:textarea>
</div>
<div class="f_row">
<s:submit value="保存信息"></s:submit>
</div>
</s:form>
</div>
</body>
</html>
<pre name="code" class="java">package edu.fjnu.hotelsys.action;
import java.util.List;
import edu.fjnu.hotelsys.domain.Hotel;
import edu.fjnu.hotelsys.domain.Room;
import edu.fjnu.hotelsys.exception.ApplicationException;
import edu.fjnu.hotelsys.service.HotelService;
import edu.fjnu.hotelsys.service.HotelServiceImpl;
import edu.fjnu.hotelsys.service.RoomQueryHelper;
import edu.fjnu.hotelsys.service.RoomService;
import edu.fjnu.hotelsys.service.RoomServiceImpl;
import edu.fjnu.hotelsys.utils.Page;
/**
* @author Administrator
*
*/
public class RoomAction extends BaseAction {
private Room room;
private RoomQueryHelper helper=null;
private Page page=null;
private List<Hotel> hotelList = null;
private HotelService hotelService=null;
private RoomService roomService=null;
public void setHotelService(HotelService hotelService) {
this.hotelService = hotelService;
}
public void setRoomService(RoomService roomService) {
this.roomService = roomService;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public RoomQueryHelper getHelper() {
return helper;
}
public void setHelper(RoomQueryHelper helper) {
this.helper = helper;
}
public List<Hotel> getHotelList() {
return hotelList;
}
public void setHotelList(List<Hotel> hotelList) {
this.hotelList = hotelList;
}
public Room getRoom() {
return room;
}
public void setRoom(Room room) {
this.room = room;
}
public String toInput() throws Exception {
hotelList=hotelService.loadall();
room=new Room();
room.setRoomType("c");
room.setRoomNo("1112");
room.setRoomEquip(new String[]{"a","b","c"});
return INPUT;
}
public String createRoom() throws Exception {
try{
roomService.createRoom(room);
}catch(ApplicationException e){
this.addActionError(e.getMessage());
hotelList=hotelService.loadall();
return "input";
}
return "loadRoomsAction";
}
public String loadRooms() throws Exception{
hotelList=hotelService.loadall();
if(page==null) page=new Page();
if(helper==null) helper=new RoomQueryHelper();
page=roomService.loadPagedRooms(page, helper);
return "list";
}
public String removeRoom() throws Exception{
roomService.removeRoom(room.getRoomId());
return "loadRoomsAction";
}
public String preUpdate() throws Exception{
room=roomService.getRoomById(room.getRoomId());
hotelList=hotelService.loadall();
return "update";
}
public String updateRoom() throws Exception{
try{
roomService.updateRoom(room);
}catch(ApplicationException e){
this.addActionError(e.getMessage());
hotelList=hotelService.loadall();
return "update";
}
return "loadRoomsAction";
}
}
ssh界面传对象到controller-页面和controller代码
最新推荐文章于 2021-12-30 19:53:39 发布