package cn.itcast.oa.view.action;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import cn.itcast.oa.domain.Role;
import cn.itcast.oa.service.RoleService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@Controller
@Scope("prototype")
public class RoleAction extends ActionSupport{
private Long id;
private String name;
private String description;
@Resource
private RoleService roleService;
/**
* 列表
* @return
* @throws Exception
*/
public String list() throws Exception{
List<Role> roleList = roleService.findAll();
ActionContext.getContext().put("roleList", roleList);
return "list";
}
/**
* 删除
* @return
* @throws Exception
*/
public String delete() throws Exception{
return "toList";
}
/**
* 添加
* @return
* @throws Exception
*/
public String add() throws Exception{
Role role = new Role();
role.setName(name);
role.setDescription(description);
roleService.save(role);
return "toList";
}
/**
* 修改
* @return
* @throws Exception
*/
public String edit() throws Exception{
//要更新到数据库
Role role = roleService.getById(id);
role.setName(name);
role.setDescription(description);
roleService.update(role);
return "toList";
}
/**
* 添加页面
* @return
* @throws Exception
*/
public String addUI() throws Exception{
return "addUI";
}
/**
* 修改页面
* @return
* @throws Exception
*/
public String editUI() throws Exception{
//准备回显的数据
Role role=roleService.getById(id);
//ActionContext.getContext().getValueStack().push(role);
this.name=role.getName();
this.description=role.getDescription();
return "editUI";
}
}
最后
以上就是大方秋天最近收集整理的关于SSH框架之Action的全部内容,更多相关SSH框架之Action内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复