AccountEventView.java
1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package fi.codecrew.moya.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class AccountEventView extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = -1873486276276870190L;
@EJB
private transient ProductBeanLocal productBean;
private AccountEvent accountevent;
private Integer accountid;
@Inject
private UserView userview;
private boolean canSave;
public void initView() {
accountevent = productBean.find(getAccountid());
if (accountevent != null && requirePermissions(permbean.isCurrentUser(accountevent.getUser()) || permbean.hasPermission(UserPermission.VIEW_ACCOUNTEVENTS))) {
userview.setUser(accountevent.getUser());
beginConversation();
setCanSave(permbean.hasPermission(UserPermission.MODIFY_ACCOUNTEVENTS));
} else {
accountevent = null;
}
}
public String save()
{
super.addFaceMessage("accountevent.saved");
accountevent = productBean.merge(accountevent);
userview.setUser(accountevent.getUser());
return null;
}
public String delete()
{
userview.setUser(productBean.delete(accountevent));
return "/useradmin/accountEvents";
}
public void setAccountid(Integer accountid) {
this.accountid = accountid;
}
public Integer getAccountid() {
return accountid;
}
public void setAccountevent(AccountEvent accountevent) {
this.accountevent = accountevent;
}
public AccountEvent getAccountevent() {
return accountevent;
}
public void setCanSave(boolean canSave) {
this.canSave = canSave;
}
public boolean isCanSave() {
return canSave;
}
public UserView getUserview() {
return userview;
}
public void setUserview(UserView userview) {
this.userview = userview;
}
}