JSF Scope problem -
first of sorry english. put question in various german forums didnt answer :-( maybe can me.
i work jsf 2.0. have create webapplication connects backend server informations stored - no problem.
my problem one: have e.g. 2 users. user 1 logs system -> mesage sent backend server -> message received user informations -> user id set 1 user 2 logs system -> ... -> user id set 2. id of user 1 set 1. means both users share 1 instance of user class? thought each user gets own instance of java classes informations stored.
here bit code:
login.xhtml
<h:body> <f:view> <h:inputtext id="name" value="#{user.name}" /> <h:inputsecret id="passwort" value="#{user.password}" /> .... <h:commandbutton id="login" action="#{communicator.validate}" />
you enter user , passwort the communicator sends message backend , receives this.
communicator.java
@managedbean(name = "communicator") @sessionscoped public class communicator implements eventreceiver { @managedproperty(value = "#{user}") private user user; private backendevent backendevent; validate(); login(); public void setuser(user user) { this.user = user; } public user getuser() { return this.user; }
and message backend received containing user informations:
private void handlelogintell(logintell logintell) { logger.addtolog("handle logintell"); user.setsessionid(logintell.getsessionid()); user.setname(logintell.getlogin()); user.setlogged(true); }
the user class simple class getter/setter methods , 3 fields: username , password , sessionid.
if 2 user go on site, thought each user new lifecycle created new instances of sessionscoped beans. but.. here users seem share 1 bean. why? can maybe explain me fault is?
regards johnny
the problem apparently scope of user
variable - how registered in context? more importantly, scope? that's should cause of problem.
clarification: see problem here:
@managedproperty(value = "#{user}") private user user;
what #{user}
? defined? there must managed bean name, or must added context in other way. problem appears have application scope. context variables can have kinds of scopes, not session scope.
Comments
Post a Comment