Rich M wrote: > > On 06/06/2011 12:48 PM, robnangle wrote: >> Rich M wrote: > Fair enough, I was trying to hypothesize at what might be your problem > based on the small subset of related code shown. But you're right, that > result does not seem to fit with what I said. > > It would be more clear to see what is happening to the User object if we > could see that code that stores and authorizes the User object before it > gets to this page where it can be cleared. >
package FantasyGaa.pages; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.apache.tapestry5.annotations.ApplicationState; import org.apache.tapestry5.annotations.Component; import org.apache.tapestry5.annotations.InjectPage; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.PasswordField; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.ApplicationStateManager; import org.apache.tapestry5.services.Request; import org.apache.tapestry5.services.Session; import Db.AppendPlayerNames; import Db.GenerateFixtures; import Db.Handler; import Db.JoinLeague; import Db.Transfers; import Entities.Fixture; import Entities.Player; import Entities.PrivateLeague; import Entities.Team; import Entities.User; import FantasyGaa.pages.Private.JoinPrivateLeague; import FantasyGaa.pages.login.Login; import FantasyGaa.pages.team.SelectPlayers; import FantasyGaa.pages.user.EditUser; public class Index { private Handler handler; private GenerateFixtures genFix; private Connection conn; private PreparedStatement prep; @Property private Transfers transfers; private List<Fixture> fixtures; private Fixture temp; @Component private Form login; @Component private Form logout; @InjectPage private Index index; @InjectPage private EditUser edit; @InjectPage private Login loginPage; @SessionState(create=false) @Property private User user; @Property private boolean userExists; @Persist private boolean adminUser; @Component private Form side1; @Inject private Request request; public Index() throws Exception { createDb(); transfers = new Transfers(); transfers.getTransferWeek(); transfers.getCloseWeek(); } public void createDb() throws Exception { Handler handler = new Handler(); conn = handler.getConnection(); prep = handler.getPreparedStatement(); } public boolean adminUser() { if(user.getUserType() != null && user.getUserType().equalsIgnoreCase("Admin")) { adminUser = true; setAdminUser(true); System.out.println("true"); } else { adminUser = false; System.out.println("false"); } return adminUser; } public boolean getAdminUser() { return adminUser; } public void setAdminUser(boolean adminUser) { this.adminUser = adminUser; } public Object onSubmitFromLogin() throws Exception { createDb(); if (validUser()) { adminUser(); return index; } else { login.recordError("Invalid Login"); return loginPage; } } public Object onSubmitFromLogout() throws Exception { user = null; Session session = request.getSession(false); if (session != null) { session.invalidate(); } return index; } public boolean validUser() throws SQLException { boolean valid = false; String check = "Select * from users WHERE (username=?) AND (password=?)"; prep = conn.prepareStatement(check); prep.setString(1, username); prep.setString(2, password); ResultSet rs = (ResultSet) prep.executeQuery(); while(rs.next()) { valid = true; user = new User(); user.setTitle(rs.getString("title")); user.setFirstName(rs.getString("firstName")); user.setLastName(rs.getString("lastName")); user.setAddress1(rs.getString("address1")); user.setAddress2(rs.getString("address2")); user.setCity(rs.getString("city")); user.setCounty(rs.getString("county")); user.setPhone(rs.getString("phone")); user.setEmail(rs.getString("email")); user.setUsername(rs.getString("username")); user.setPassword(rs.getString("password")); user.setUserType(rs.getString("userType")); } return valid; } } Rich M wrote: > > Any luck with some debugging messages to verify what methods are getting > called in between the working and broken states? > Well what I thought was correct. When the admin user logs in, he can view one correct page. After this any navigation to an admin page will print false, i.e. he has not passed the admin test, meaning it has reverted to the previous user... -- View this message in context: http://tapestry.1045711.n5.nabble.com/Clearing-SessionState-tp4458525p4459274.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org