You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by gaurav <gp...@gmail.com> on 2012/03/05 15:57:52 UTC

browser back button, after logout while using Dispatcher

Hi,
I am getting problem in browser back button, after logout when I press
browser's back button 
home page show for few seconds and then it go to login page.
I am new in Tapestry and using Dispatcher for authentication. I got the code
from tapestry-jumpstart or some blog. please check the code:

public class AuthorizationDispatcher implements Dispatcher{
	
	private PageRenderRequestHandler requestHandler;
	private ApplicationStateManager applicationStateManager;

	public AuthorizationDispatcher(PageRenderRequestHandler handler,
			ApplicationStateManager applicationStateManager) {
		super();
		this.requestHandler = handler;
		this.applicationStateManager = applicationStateManager;
	}
	
	

	@Override
	public boolean dispatch(Request request, Response response) throws
IOException {
		
		String loginPageName = Index.class.getSimpleName();
		String path = request.getPath();
		
		if (path.equals("/") || path.toLowerCase().startsWith("/" +
loginPageName.toLowerCase())) {
			return false;
		}
		User user = this.applicationStateManager.getIfExists(User.class);
		
		if (user == null) {

			PageRenderRequestParameters parameters = new
PageRenderRequestParameters(loginPageName, new EmptyEventContext(), false);
			this.requestHandler.handle(parameters);

			return true;
		}
		
		return false;
	}

}

/**********************************************************************/

AppModule code is :

public static void contributeMasterDispatcher(
			OrderedConfiguration configuration) {
	
configuration.addInstance("AuthorizationDispatcher",AuthorizationDispatcher.class,
"after:ComponentEvent","before:PageRender");
	}
  

--
View this message in context: http://tapestry.1045711.n5.nabble.com/browser-back-button-after-logout-while-using-Dispatcher-tp5537754p5537754.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: problem in custom javascript with scriptaculous

Posted by Josh Canfield <jo...@gmail.com>.
Start by saying what isn't working.
On Mar 19, 2012 5:36 AM, "gaurav" <gp...@gmail.com> wrote:

> Hi,
> I created a drop down box and want to add scriptaculous Draggable in my
> drop
> down box but it is not working together. So how can I fix the things.
>
>               @AfterRender
>                void afterRender(MarkupWriter writer)
>                {
>                         writer.end(); //end of box div
>                         writer.end(); //end of container div
>                         javaScriptSupport.addScript("new
> DropDownBox('%s','%s','%s')",elementId,dropBoxId,elementClass);
>                         javaScriptSupport.addScript( "new
> Draggable('%s')", dropBoxId);
>
>                }
>
> Javascript code :
>
> var DropDownBox = Class.create({
>            initialize:
> function(targetElement,dropDownBoxElement,targetElementClass){
>                   this.target = $(targetElement);
>                   this.boxElement = $(dropDownBoxElement);
>                   this.targetElementClass = targetElementClass;
>                   Event.observe(this.target, 'click',
> this.toggleBox.bindAsEventListener(this));
>            },
>            toggleBox : function(event){
>                Event.stop(event);
>                        this.boxElement.toggle();
>
>  this.target.toggleClassName(this.targetElementClass);
>    }
> });
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/browser-back-button-after-logout-while-using-Dispatcher-tp5537754p5576973.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.

problem in custom javascript with scriptaculous

Posted by gaurav <gp...@gmail.com>.
Hi,
I created a drop down box and want to add scriptaculous Draggable in my drop
down box but it is not working together. So how can I fix the things.

               @AfterRender
		void afterRender(MarkupWriter writer)
		{   
			 writer.end(); //end of box div
			 writer.end(); //end of container div
			 javaScriptSupport.addScript("new
DropDownBox('%s','%s','%s')",elementId,dropBoxId,elementClass);
			 javaScriptSupport.addScript( "new Draggable('%s')", dropBoxId);
			
		}

Javascript code : 

var DropDownBox = Class.create({
	    initialize:
function(targetElement,dropDownBoxElement,targetElementClass){
		   this.target = $(targetElement);
		   this.boxElement = $(dropDownBoxElement);
		   this.targetElementClass = targetElementClass;
		   Event.observe(this.target, 'click',
this.toggleBox.bindAsEventListener(this)); 
	    },
	    toggleBox : function(event){
	    	Event.stop(event);
			this.boxElement.toggle();
			this.target.toggleClassName(this.targetElementClass);
    }
});




--
View this message in context: http://tapestry.1045711.n5.nabble.com/browser-back-button-after-logout-while-using-Dispatcher-tp5537754p5576973.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: browser back button, after logout while using Dispatcher

Posted by gaurav <gp...@gmail.com>.
Thanks A lot Taha,
well I checked userExist in onActive() method so it sendredirect to login
page.
I am new in tapestry just started 1 month back. So it is hard to use Apache
Shiro so early
but I will try later.
Thanks & Regards
Gaurav P Singh


--
View this message in context: http://tapestry.1045711.n5.nabble.com/browser-back-button-after-logout-while-using-Dispatcher-tp5537754p5557742.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: browser back button, after logout while using Dispatcher

Posted by gaurav <gp...@gmail.com>.
Thank you Sahpaski,
It seems not to be the case of caching if it's caching problem then it would
stay on the last page (which was last visited) but it will immediately go
back to login page.
I added cache-control and the expires in my page but it will not help to
much.
Thanks & Regards
Gaurav P Singh
 

  



--
View this message in context: http://tapestry.1045711.n5.nabble.com/browser-back-button-after-logout-while-using-Dispatcher-tp5537754p5557837.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: browser back button, after logout while using Dispatcher

Posted by Dragan Sahpaski <dr...@gmail.com>.
Also check out this thread on the same topic (back button).
http://tapestry.1045711.n5.nabble.com/Browser-Back-Button-td4909542.html#a4917143

The reply from Vangel is very detailed and explanatory.

Cheers,
Dragan Sahpaski



On Mon, Mar 5, 2012 at 5:49 PM, Taha Hafeez Siddiqi <
tawus.tapestry@gmail.com> wrote:

> Hi
>
> The browser back button usually shows an offline page till you refresh it.
> So, I don't think it is an issue as long as you are not able to access any
> secure links from there.
>
> Also does your logout page perform a Session#invalidate(), as it will
> ensure that the session is cleared.
>
> Finally, I will prefer to use Tynamo's tapestry-security based on Apache
> Shiro, even for the simplest of security implementation :)
>
> regards
> Taha
>
>
>
> On Mar 5, 2012, at 8:27 PM, gaurav wrote:
>
> > Hi,
> > I am getting problem in browser back button, after logout when I press
> > browser's back button
> > home page show for few seconds and then it go to login page.
> > I am new in Tapestry and using Dispatcher for authentication. I got the
> code
> > from tapestry-jumpstart or some blog. please check the code:
> >
> > public class AuthorizationDispatcher implements Dispatcher{
> >
> >       private PageRenderRequestHandler requestHandler;
> >       private ApplicationStateManager applicationStateManager;
> >
> >       public AuthorizationDispatcher(PageRenderRequestHandler handler,
> >                       ApplicationStateManager applicationStateManager) {
> >               super();
> >               this.requestHandler = handler;
> >               this.applicationStateManager = applicationStateManager;
> >       }
> >
> >
> >
> >       @Override
> >       public boolean dispatch(Request request, Response response) throws
> > IOException {
> >
> >               String loginPageName = Index.class.getSimpleName();
> >               String path = request.getPath();
> >
> >               if (path.equals("/") || path.toLowerCase().startsWith("/" +
> > loginPageName.toLowerCase())) {
> >                       return false;
> >               }
> >               User user =
> this.applicationStateManager.getIfExists(User.class);
> >
> >               if (user == null) {
> >
> >                       PageRenderRequestParameters parameters = new
> > PageRenderRequestParameters(loginPageName, new EmptyEventContext(),
> false);
> >                       this.requestHandler.handle(parameters);
> >
> >                       return true;
> >               }
> >
> >               return false;
> >       }
> >
> > }
> >
> > /**********************************************************************/
> >
> > AppModule code is :
> >
> > public static void contributeMasterDispatcher(
> >                       OrderedConfiguration configuration) {
> >
> >
> configuration.addInstance("AuthorizationDispatcher",AuthorizationDispatcher.class,
> > "after:ComponentEvent","before:PageRender");
> >       }
> >
> >
> > --
> > View this message in context:
> http://tapestry.1045711.n5.nabble.com/browser-back-button-after-logout-while-using-Dispatcher-tp5537754p5537754.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: browser back button, after logout while using Dispatcher

Posted by Taha Hafeez Siddiqi <ta...@gmail.com>.
Hi

The browser back button usually shows an offline page till you refresh it. So, I don't think it is an issue as long as you are not able to access any secure links from there. 

Also does your logout page perform a Session#invalidate(), as it will ensure that the session is cleared.

Finally, I will prefer to use Tynamo's tapestry-security based on Apache Shiro, even for the simplest of security implementation :)

regards
Taha



On Mar 5, 2012, at 8:27 PM, gaurav wrote:

> Hi,
> I am getting problem in browser back button, after logout when I press
> browser's back button 
> home page show for few seconds and then it go to login page.
> I am new in Tapestry and using Dispatcher for authentication. I got the code
> from tapestry-jumpstart or some blog. please check the code:
> 
> public class AuthorizationDispatcher implements Dispatcher{
> 	
> 	private PageRenderRequestHandler requestHandler;
> 	private ApplicationStateManager applicationStateManager;
> 
> 	public AuthorizationDispatcher(PageRenderRequestHandler handler,
> 			ApplicationStateManager applicationStateManager) {
> 		super();
> 		this.requestHandler = handler;
> 		this.applicationStateManager = applicationStateManager;
> 	}
> 	
> 	
> 
> 	@Override
> 	public boolean dispatch(Request request, Response response) throws
> IOException {
> 		
> 		String loginPageName = Index.class.getSimpleName();
> 		String path = request.getPath();
> 		
> 		if (path.equals("/") || path.toLowerCase().startsWith("/" +
> loginPageName.toLowerCase())) {
> 			return false;
> 		}
> 		User user = this.applicationStateManager.getIfExists(User.class);
> 		
> 		if (user == null) {
> 
> 			PageRenderRequestParameters parameters = new
> PageRenderRequestParameters(loginPageName, new EmptyEventContext(), false);
> 			this.requestHandler.handle(parameters);
> 
> 			return true;
> 		}
> 		
> 		return false;
> 	}
> 
> }
> 
> /**********************************************************************/
> 
> AppModule code is :
> 
> public static void contributeMasterDispatcher(
> 			OrderedConfiguration configuration) {
> 	
> configuration.addInstance("AuthorizationDispatcher",AuthorizationDispatcher.class,
> "after:ComponentEvent","before:PageRender");
> 	}
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/browser-back-button-after-logout-while-using-Dispatcher-tp5537754p5537754.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.


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