You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Simon Raveh <Si...@nominum.com> on 2003/09/20 01:46:51 UTC

Visit Object and multiple frames

Hi,

I'm working on a multiple frame application, the home page is a frameset
that loads 5 frames.

The home page is a protected page so I implemented the pageValidate and if
the user is not log in I'm throwing PageRedirectException to the login page.
The first time the user login everything works fine, I see that the user is
not login, I redirect him to the login screen and after that load the home
page with all the frames.
The problems start When the user logout using the logout link and try to
login again. I get a very strange behavior:
1 The user get the login screen and performs the login
2 After the user is login I start to load the home page with all the frames.
3 For some reason each frame gets each own new copy of the visit object with
all the fields initialize to their defaults which cause me to redirect the
user to the login page again.

When running in debug mode using the debugger the application behave
normally what make me think that this is a race condition.

Any Suggestions

Thanks Simon

the home page template is

html>
	<head>
		<title>Nominum Foundation Management Center</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<link rel="stylesheet" href="css/styles.css" type="text/css">
	</head>

	<frameset rows="83,*,128" cols="*">
  		<frame name="topFrame" src="Border.html" noresize scrolling="no"
jwcid="topFrame@Frame" page="TopFrame" />
    	<frameset cols="190,*,300" rows="*">
      		<frame name="leftFrame" src="ContextViewerPage.html" scrolling="yes"
jwcid="leftFrame@Frame"   page="ContextViewerPage" />
      		<frame scrolling="yes"  name="mainFrame"
src="AddressBlockPage.html"  jwcid="mainFrame@Frame"
page="AddressBlockPage" />
      		<frame scrolling="yes"  name="detailFrame"
src="DetailFramePage.html"   jwcid="detailFrame@Frame"
page="DetailFramePage"/>
    	</frameset>
  		<frame src="EventFrame.html" noresize scrolling="no" />
	</frameset>
	<noframes>
		<body bgcolor="#FFFFFF" text="#000000">
			This application requires a browser that supports framesets.
		</body>
	</noframes>
</html

the home.page file

<page-specification
class="com.nominum.management.web.presentation.pages.Home" >
	<property-specification name="error"    type="java.lang.String"/>
</page-specification>

the Logout code is

public void logout( IRequestCycle cycle )
{
	FMCEngine engine = (FMCEngine)getEngine();
	Home home = ( Home ) cycle.getPage( "Home" );
	engine.logout();
	throw new PageRedirectException( home );
}

//The FMCEngine.logout

public void logout()
{
	Visit visit = (Visit) getVisit();
	if ( visit != null )
	{
		visit.setToken( null );
		visit.setUser( null );
		visit = null;
	}
		m_killSession = true;
}

// The page validate method
public void pageValidate( PageEvent event )
{
	Visit visit = ( Visit ) getVisit();
	LogFactory.getLog( getClass() ).debug( "Using visit object " + visit );
	if( visit != null && visit.isUserLoggedIn() )
		return;

	// User not logged in ... redirect through the Login page.
	Login login = ( Login ) getRequestCycle().getPage( "Login" );
	login.setCallback( new PageCallback( this ) );
	throw new PageRedirectException( login );
}



here are the debug statments, I left only the ones that are related

The first time the user login

290538 PageLoader [INFO] Loaded page
com.nominum.management.web.presentation.pages.Home$Enhance_0@feba0ed7[Home]
with
components (maximum depth 2)
290648 Home$Enhance_0 [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
290718 Visit [DEBUG] IsUserLogin: User token is set to null
293362 PageLoader [INFO] Loaded page
com.nominum.management.web.presentation.pages.Login$Enhance_2@fedfc783[Login
] wi
11 components (maximum depth 3)

306511 Login [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
306641 Visit [DEBUG] Set user token to
com.nominum.management.common.security.UserToken@ff616332
306781 Home$Enhance_0 [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
306961 Visit [DEBUG] IsUserLogin: User token is set to
com.nominum.management.common.security.UserToken@ff616332

310426 AbstractEngine [INFO] Begin service /fmc-web/app
312690 PageLoader [INFO] Loaded page
com.nominum.management.web.presentation.pages.TopFrame$Enhance_11@fece0fb2[T
opFr
] with 8 components (maximum depth 2)
312850 TopFrame$Enhance_11 [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
313250 Visit [DEBUG] IsUserLogin: User token is set to
com.nominum.management.common.security.UserToken@ff616332
313551 AbstractEngine [INFO] End service
{}
315954 PageLoader [INFO] Loaded page
com.nominum.management.web.presentation.pages.AddressBlockPage$Enhance_12@fe
bb9f
AddressBlockPage] with 21 components (maximum depth 3)
316155 AddressBlockPage$Enhance_12 [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
316315 Visit [DEBUG] IsUserLogin: User token is set to
com.nominum.management.common.security.UserToken@ff616332
316385 PageLoader [INFO] Loaded page
com.nominum.management.web.presentation.pages.ContextViewerPage$Enhance_14@f
eb3a
[ContextViewerPage] with 23 components (maximum depth 3)
316605 ContextViewerPage$Enhance_14 [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
316775 Visit [DEBUG] IsUserLogin: User token is set to
com.nominum.management.common.security.UserToken@ff616332

The user is logging out.

327120 TopFrame$Enhance_11 [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
327211 Visit [DEBUG] IsUserLogin: User token is set to
com.nominum.management.common.security.UserToken@ff616332
327311 Visit [DEBUG] Set user token to null
327411 Home$Enhance_0 [DEBUG] Using visit object
com.nominum.management.web.Visit@fee98017
327501 Visit [DEBUG] IsUserLogin: User token is set to null

The second login

333550 Login [DEBUG] Using visit object
com.nominum.management.web.Visit@ffc402e3
333660 Visit [DEBUG] Set user token to
com.nominum.management.common.security.UserToken@ffb7de17
333770 Home$Enhance_0 [DEBUG] Using visit object
com.nominum.management.web.Visit@ffc402e3
333880 Visit [DEBUG] IsUserLogin: User token is set to
com.nominum.management.common.security.UserToken@ffb7de17

334781 TopFrame$Enhance_11 [DEBUG] Using visit object
com.nominum.management.web.Visit@ffb291d7
334972 AddressBlockPage$Enhance_12 [DEBUG] Using visit object
com.nominum.management.web.Visit@ffb1cb22
335062 AbstractEngine [INFO] End service
335122 Visit [DEBUG] IsUserLogin: User token is set to null
335172 Visit [DEBUG] IsUserLogin: User token is set to null
335613 AbstractEngine [INFO] End service
{}
336003 AbstractEngine [INFO] End service
336434 AbstractEngine [INFO] Begin service /fmc-web/app
336584 ContextViewerPage$Enhance_14 [DEBUG] Using visit object
com.nominum.management.web.Visit@ffb1cb22
336744 Visit [DEBUG] IsUserLogin: User token is set to null

338527 Home$Enhance_0 [DEBUG] Using visit object
com.nominum.management.web.Visit@ffb1cb22
338727 PageLoader [INFO] Loaded page
com.nominum.management.web.presentation.pages.Home$Enhance_0@feec26f5[Home]
with
components (maximum depth 2)
338897 Visit [DEBUG] IsUserLogin: User token is set to null
339138 Home$Enhance_0 [DEBUG] Using visit object
com.nominum.management.web.Visit@ffb1cb22
339378 AbstractEngine [INFO] End service
339458 Visit [DEBUG] IsUserLogin: User token is set to null
339859 AbstractEngine [INFO] End service
339999 AbstractEngine [INFO] Begin service /fmc-web/app
340129 Home$Enhance_0 [DEBUG] Using visit object
com.nominum.management.web.Visit@ffb1cb22
340289 Visit [DEBUG] IsUserLogin: User token is set to null


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Visit Object and multiple frames

Posted by Jim Frederic <ji...@isogen.com>.
I believe the problem is that you are killing the session and remaining 
on the server to go back to the login page.  Instead, try a client-side 
redirect, like this:

public void logout( IRequestCycle cycle )
{
	FMCEngine engine = (FMCEngine)getEngine();
	Home home = ( Home ) cycle.getPage( "Home" );
	engine.logout();
	// throw new PageRedirectException( home );
	cycle.getRequestContext().getSession().invalidate();
	// go back to the beginning.
	try {
		String uri = cycle.getRequestContext().getRequestURI();
		cycle.getRequestContext().redirect(uri);
	} catch (IOException e) {
		// Log this
	}
	
}



Simon Raveh wrote:

>Hi,
>
>I'm working on a multiple frame application, the home page is a frameset
>that loads 5 frames.
>
>The home page is a protected page so I implemented the pageValidate and if
>the user is not log in I'm throwing PageRedirectException to the login page.
>The first time the user login everything works fine, I see that the user is
>not login, I redirect him to the login screen and after that load the home
>page with all the frames.
>The problems start When the user logout using the logout link and try to
>login again. I get a very strange behavior:
>1 The user get the login screen and performs the login
>2 After the user is login I start to load the home page with all the frames.
>3 For some reason each frame gets each own new copy of the visit object with
>all the fields initialize to their defaults which cause me to redirect the
>user to the login page again.
>
>When running in debug mode using the debugger the application behave
>normally what make me think that this is a race condition.
>
>Any Suggestions
>
>Thanks Simon
>
>the home page template is
>
>html>
>	<head>
>		<title>Nominum Foundation Management Center</title>
>		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>		<link rel="stylesheet" href="css/styles.css" type="text/css">
>	</head>
>
>	<frameset rows="83,*,128" cols="*">
>  		<frame name="topFrame" src="Border.html" noresize scrolling="no"
>jwcid="topFrame@Frame" page="TopFrame" />
>    	<frameset cols="190,*,300" rows="*">
>      		<frame name="leftFrame" src="ContextViewerPage.html" scrolling="yes"
>jwcid="leftFrame@Frame"   page="ContextViewerPage" />
>      		<frame scrolling="yes"  name="mainFrame"
>src="AddressBlockPage.html"  jwcid="mainFrame@Frame"
>page="AddressBlockPage" />
>      		<frame scrolling="yes"  name="detailFrame"
>src="DetailFramePage.html"   jwcid="detailFrame@Frame"
>page="DetailFramePage"/>
>    	</frameset>
>  		<frame src="EventFrame.html" noresize scrolling="no" />
>	</frameset>
>	<noframes>
>		<body bgcolor="#FFFFFF" text="#000000">
>			This application requires a browser that supports framesets.
>		</body>
>	</noframes>
></html
>
>the home.page file
>
><page-specification
>class="com.nominum.management.web.presentation.pages.Home" >
>	<property-specification name="error"    type="java.lang.String"/>
></page-specification>
>
>the Logout code is
>
>public void logout( IRequestCycle cycle )
>{
>	FMCEngine engine = (FMCEngine)getEngine();
>	Home home = ( Home ) cycle.getPage( "Home" );
>	engine.logout();
>	throw new PageRedirectException( home );
>}
>
>//The FMCEngine.logout
>
>public void logout()
>{
>	Visit visit = (Visit) getVisit();
>	if ( visit != null )
>	{
>		visit.setToken( null );
>		visit.setUser( null );
>		visit = null;
>	}
>		m_killSession = true;
>}
>
>// The page validate method
>public void pageValidate( PageEvent event )
>{
>	Visit visit = ( Visit ) getVisit();
>	LogFactory.getLog( getClass() ).debug( "Using visit object " + visit );
>	if( visit != null && visit.isUserLoggedIn() )
>		return;
>
>	// User not logged in ... redirect through the Login page.
>	Login login = ( Login ) getRequestCycle().getPage( "Login" );
>	login.setCallback( new PageCallback( this ) );
>	throw new PageRedirectException( login );
>}
>
>
>
>here are the debug statments, I left only the ones that are related
>
>The first time the user login
>
>290538 PageLoader [INFO] Loaded page
>com.nominum.management.web.presentation.pages.Home$Enhance_0@feba0ed7[Home]
>with
>components (maximum depth 2)
>290648 Home$Enhance_0 [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>290718 Visit [DEBUG] IsUserLogin: User token is set to null
>293362 PageLoader [INFO] Loaded page
>com.nominum.management.web.presentation.pages.Login$Enhance_2@fedfc783[Login
>] wi
>11 components (maximum depth 3)
>
>306511 Login [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>306641 Visit [DEBUG] Set user token to
>com.nominum.management.common.security.UserToken@ff616332
>306781 Home$Enhance_0 [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>306961 Visit [DEBUG] IsUserLogin: User token is set to
>com.nominum.management.common.security.UserToken@ff616332
>
>310426 AbstractEngine [INFO] Begin service /fmc-web/app
>312690 PageLoader [INFO] Loaded page
>com.nominum.management.web.presentation.pages.TopFrame$Enhance_11@fece0fb2[T
>opFr
>] with 8 components (maximum depth 2)
>312850 TopFrame$Enhance_11 [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>313250 Visit [DEBUG] IsUserLogin: User token is set to
>com.nominum.management.common.security.UserToken@ff616332
>313551 AbstractEngine [INFO] End service
>{}
>315954 PageLoader [INFO] Loaded page
>com.nominum.management.web.presentation.pages.AddressBlockPage$Enhance_12@fe
>bb9f
>AddressBlockPage] with 21 components (maximum depth 3)
>316155 AddressBlockPage$Enhance_12 [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>316315 Visit [DEBUG] IsUserLogin: User token is set to
>com.nominum.management.common.security.UserToken@ff616332
>316385 PageLoader [INFO] Loaded page
>com.nominum.management.web.presentation.pages.ContextViewerPage$Enhance_14@f
>eb3a
>[ContextViewerPage] with 23 components (maximum depth 3)
>316605 ContextViewerPage$Enhance_14 [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>316775 Visit [DEBUG] IsUserLogin: User token is set to
>com.nominum.management.common.security.UserToken@ff616332
>
>The user is logging out.
>
>327120 TopFrame$Enhance_11 [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>327211 Visit [DEBUG] IsUserLogin: User token is set to
>com.nominum.management.common.security.UserToken@ff616332
>327311 Visit [DEBUG] Set user token to null
>327411 Home$Enhance_0 [DEBUG] Using visit object
>com.nominum.management.web.Visit@fee98017
>327501 Visit [DEBUG] IsUserLogin: User token is set to null
>
>The second login
>
>333550 Login [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffc402e3
>333660 Visit [DEBUG] Set user token to
>com.nominum.management.common.security.UserToken@ffb7de17
>333770 Home$Enhance_0 [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffc402e3
>333880 Visit [DEBUG] IsUserLogin: User token is set to
>com.nominum.management.common.security.UserToken@ffb7de17
>
>334781 TopFrame$Enhance_11 [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffb291d7
>334972 AddressBlockPage$Enhance_12 [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffb1cb22
>335062 AbstractEngine [INFO] End service
>335122 Visit [DEBUG] IsUserLogin: User token is set to null
>335172 Visit [DEBUG] IsUserLogin: User token is set to null
>335613 AbstractEngine [INFO] End service
>{}
>336003 AbstractEngine [INFO] End service
>336434 AbstractEngine [INFO] Begin service /fmc-web/app
>336584 ContextViewerPage$Enhance_14 [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffb1cb22
>336744 Visit [DEBUG] IsUserLogin: User token is set to null
>
>338527 Home$Enhance_0 [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffb1cb22
>338727 PageLoader [INFO] Loaded page
>com.nominum.management.web.presentation.pages.Home$Enhance_0@feec26f5[Home]
>with
>components (maximum depth 2)
>338897 Visit [DEBUG] IsUserLogin: User token is set to null
>339138 Home$Enhance_0 [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffb1cb22
>339378 AbstractEngine [INFO] End service
>339458 Visit [DEBUG] IsUserLogin: User token is set to null
>339859 AbstractEngine [INFO] End service
>339999 AbstractEngine [INFO] Begin service /fmc-web/app
>340129 Home$Enhance_0 [DEBUG] Using visit object
>com.nominum.management.web.Visit@ffb1cb22
>340289 Visit [DEBUG] IsUserLogin: User token is set to null
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org