Commit ce99b29c by Tuukka Kivilahti

when returning from shop to incomingview, store user, so you can give card heti

1 parent 4c61cf39
package fi.codecrew.moya.web.flow;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
/**
* Place to store userid between pageloads
* @author tuukka
*
*/
@Named
@SessionScoped
public class FlowUserContainer extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L;
private Integer userId;
/**
* Get current userid, remember to clear this, so there is no weird bugs
* @return
*/
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
}
...@@ -56,6 +56,10 @@ public class IncomingView extends GenericCDIView { ...@@ -56,6 +56,10 @@ public class IncomingView extends GenericCDIView {
@Inject @Inject
private ReaderNameContainer namecontainer; private ReaderNameContainer namecontainer;
@Inject
private FlowUserContainer flowUserContainer;
@EJB @EJB
private BarcodeBeanLocal barcodeBean; private BarcodeBeanLocal barcodeBean;
...@@ -127,6 +131,14 @@ public class IncomingView extends GenericCDIView { ...@@ -127,6 +131,14 @@ public class IncomingView extends GenericCDIView {
if (!initialized) { if (!initialized) {
logger.debug("INITIALIZING!!!!"); logger.debug("INITIALIZING!!!!");
if(flowUserContainer.getUserId() != null && flowUserContainer.getUserId() > 0) {
userview.setUserid(flowUserContainer.getUserId());
}
flowUserContainer.setUserId(null);
// initializePoller(); // initializePoller();
initialized = true; initialized = true;
super.beginConversation(); super.beginConversation();
......
...@@ -45,6 +45,9 @@ public class flowShopView extends GenericCDIView { ...@@ -45,6 +45,9 @@ public class flowShopView extends GenericCDIView {
@Inject @Inject
private ReaderView readerView; private ReaderView readerView;
@Inject
private FlowUserContainer flowUserContainer;
public void initView() { public void initView() {
if(userId == null || userId == 0) { if(userId == null || userId == 0) {
...@@ -68,8 +71,10 @@ public class flowShopView extends GenericCDIView { ...@@ -68,8 +71,10 @@ public class flowShopView extends GenericCDIView {
public void changeUser(SelectEvent event) { public void changeUser(SelectEvent event) {
if (infoView.getMultiSearchUser() != null) { if (infoView.getMultiSearchUser() != null) {
flowUserContainer.setUserId(infoView.getMultiSearchUser().getUser().getId());
super.navihandler.redirectNavigation("shop.jsf?userid=" + infoView.getMultiSearchUser().getUser().getId()); super.navihandler.redirectNavigation("shop.jsf?userid=" + infoView.getMultiSearchUser().getUser().getId());
infoView.setMultiSearchUser(null);
} }
} }
...@@ -89,6 +94,7 @@ public class flowShopView extends GenericCDIView { ...@@ -89,6 +94,7 @@ public class flowShopView extends GenericCDIView {
if (!user.equals(userView.getUser())) { if (!user.equals(userView.getUser())) {
logger.info("found user {}, redirecting", user.getNick()); logger.info("found user {}, redirecting", user.getNick());
userView.setUser(user); userView.setUser(user);
flowUserContainer.setUserId(user.getUser().getId());
super.navihandler.redirectNavigation("shop.jsf?userid=" + user.getUser().getId()); super.navihandler.redirectNavigation("shop.jsf?userid=" + user.getUser().getId());
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!