I have two different paths and this happens only in another one:
SignUp.Xhtml-->SigninUpOkView-->Login.xhtml-->Welcome.xhtml-->UsersController.prepareCreateParty()--->createParty.xhtml-->UsersController.createParty()
SignUp.Xhtml-->SigninUpOkView-->Login.xhtml-->Logout-->Login.xhtml-->Welcome.xhtml-->UsersController.prepareCreateParty()--->createParty.xhtml-->UsersController.createParty()
So what happens: I create a new party-object in controller's method prepareCreateParty() and insert it to the Users-object so that Party is not null when User goes to CreateParty-xhtml page, but it is working only in case 2 where I logout between Signin up and createParty. UserController is a managedBean and UsersController is on SessionScoped. I still have User in Session with name user and I put it there in Login Filter. The cases are identical between Welcome.xhtml---->UsersController.CreateParty() but something really strange happens. I tried to insert default-name to party in createParty-method and in first case, it disappears even if the User object is still there, only Party-property inside the User is NULL. In case two when I logged out and in, it is still there and everything is working fine. What can cause that? I have tried everything and I am starting to be in agony and frustrated.
IN USERS:
@JoinColumn(name = "party_id", referencedColumnName = "party_id")
@ManyToOne
private Party partyId;
IN USERSCONTROLLER (SessionScoped ManagedBean): public UsersController(Users userEntity) { this.currentUser = userEntity; }
public Users getSelected() {
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);
if (currentUser == null) {
currentUser = (Users) session.getAttribute("user");
if(currentUser==null){
currentUser = new Users();
selectedItemIndex = -1;
}
}
public String prepareCreateParty() {
if (currentUser == null) {
currentUser = this.getUsersFromSession();
}
Party party = new Party();
party.setName("Testing default name of the party");
currentUser.setPartyId(party);
return "createParty";
In CreateParty.xhtml-page:
<p:row>
<p:column> <h:outputLabel value="#{bundle.CreatePartyLabel_name}" for="name" /></p:column>
<p:column><p:inputText id="name" value="#{usersController.selected.partyId.name}" title="#{bundle.CreatePartyTitle_name}" required="true" requiredMessage="#{bundle.CreatePartyRequiredMessage_name}"/></p:column>
<p:column><p:tooltip for="name" showEvent="focus" hideEvent="blur" /></p:column>
<p:column><h:outputLabel value=" "/></p:column>
</p:row>
in LoginFilter.doFilter():
if (userPrincipal != null && session.getAttribute("user") == null) {
UsersFacade test = new UsersFacade();
Users userEntity = test.findByUsername(userPrincipal.getName());
session.setAttribute("user", userEntity);
UsersController userController = new UsersController(userEntity);// Unnecessary constructor call!!
Glassfish 3.1.2 Mojarra 2.1.6 PrimeFaces 3.2 Madness 1.100%
What in the world can cause that, I appreciate you help a lot! I hope that you can figure my explanation out even if the English is what it is. Sami