Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 33 → Rev 37

/trunk/src/ch/ffhs/webE/action/UserAction.java
7,7 → 7,7
 
import org.apache.struts2.StrutsStatics;
 
import ch.ffhs.webE.dao.UserDAOImpl;
import ch.ffhs.webE.dao.UserDAO;
import ch.ffhs.webE.domain.User;
 
import com.opensymphony.xwork2.Action;
22,8 → 22,12
 
private User user = new User();
private List<User> userList = new ArrayList<User>();
private final UserDAOImpl userDAO = new UserDAOImpl();
private final UserDAO userDAO = new UserDAO();
 
public boolean edit = false;
public boolean added = false;
public User savedUser;
 
@Override
public User getModel()
{
31,24 → 35,29
}
 
/**
* Executes the DB query to save the user
* DB query for userList
*
* @return
* @return SUCCESS
*/
public String addOrUpdate()
public String list()
{
this.userDAO.saveOrUpdateUser(this.user);
this.userList = this.userDAO.getList();
return Action.SUCCESS;
}
 
/**
* DB query for userList
* Executes the DB query to save the user
*
* @return SUCCESS
* @return
*/
public String list()
public String save()
{
this.userList = this.userDAO.listUser();
this.userDAO.saveOrUpdate(this.user);
this.savedUser = this.user;
this.user = null;
 
this.list();
 
return Action.SUCCESS;
}
 
56,15 → 65,17
{
int id = this.getIdParameter();
 
String result = Action.ERROR;
if (id > 0)
{
this.user = this.userDAO.listUserById(id);
return Action.SUCCESS;
this.user = this.userDAO.getById(id);
this.edit = true;
result = Action.SUCCESS;
}
else
{
return Action.ERROR;
}
 
this.list();
 
return result;
}
 
/**
104,7 → 115,7
// Check for malicious ID values
if (id > 0)
{
this.userDAO.deleteUser(id);
this.userDAO.delete(id);
return Action.SUCCESS;
}
else