/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
* @throws UnsupportedEncodingException
*/
public String exAdd() throws UnsupportedEncodingException{
String newName = new String(coach.getName().getBytes( "utf-8" ), "utf-8" );
coach.setName(newName);
coach.setState( 0 );
coachService.save(coach);
ActionContext.getContext().put( "url" , "/coach_coach.do" );
return "redirect" ;
}
/**
* 查看详情页面
* @return
*/
public String view(){
Coach n = coachService.getById(coach.getId());
ActionContext.getContext().put( "Obj" , n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
Coach n = coachService.getById(coach.getId());
ActionContext.getContext().put( "Obj" , n);
return SUCCESS;
}
public String update1(){
Coach n = coachService.getById(coach.getId());
if (n.getState()== null ||n.getState()== 1 ){
n.setState( 0 );
} else {
n.setState( 1 );
}
coachService.update(n);
ActionContext.getContext().put( "url" , "/coach_coach1.do" );
return "redirect" ;
}
/**
* 执行修改
* @return
* @throws UnsupportedEncodingException
*/
public String exUpdate() throws UnsupportedEncodingException{
Coach n = coachService.getById(coach.getId());
String newName = new String(coach.getName().getBytes( "utf-8" ), "utf-8" );
n.setAge(coach.getAge());
n.setName(newName);
n.setLevel(coach.getLevel());
n.setSex(coach.getSex());
n.setPrice(coach.getPrice());
coachService.update(n);
ActionContext.getContext().put( "url" , "/coach_coach.do" );
return "redirect" ;
}
/**
* 删除
* @return
*/
public String delete(){
coachService.delete(coach.getId());
ActionContext.getContext().put( "url" , "/coach_coach.do" );
return "redirect" ;
}