You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andrew Easter <an...@gmail.com> on 2009/08/06 13:27:14 UTC

Wicket pages as actions

Would it be considered bad practice to use a Wicket page as an action? i.e.
it doesn't do anything but perform some particular action (e.g. logout) and
then forward onto another page.

I'm coming up, again, against my biggest annoyance with Wicket - URLs. I
want to create a logout function in my application and so have created a
logout link component:

public class LogoutLink extends Link<Void>
{
   public LogoutLink( String id )
   {
      super( id );
   }

   @Override
   public void onClick()
   {
      AuthenticatedWebSession session = AuthenticatedWebSession.get();
      session.signOut();
      setResponsePage( LogoutPage.class );
   }
}

When I put this component within a page (in my case, an AccessDeniedPage),
as the AccessDeniedPage will handle the request, the URL for logging out is:

http://localhost:8080/web/?wicket:interface=:3:logout::ILinkListener::

I don't see the need to expose implementation details (i.e. ?wicket in the
URL) at this point. Therefore, does it make more sense that the LogoutPage
(the response page) itself performs the logout action? The link for logging
out would then simply become a bookmarkable link to the logout page. For
some reason, this doesn't really feel right to me, though.

I'd much rather keep the functionality as is and, instead, have the URL
disguised. I do understand the basics of URL mounting and encoding but don't
understand how I can use it to disguise this particular scenario.

Regards,

Andrew

Re: Wicket pages as actions

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> http://localhost:8080/web/?wicket:interface=:3:logout::ILinkListener::
> 
> I don't see the need to expose implementation details (i.e. ?wicket in
> the
> URL) at this point. Therefore, does it make more sense that the
> LogoutPage
> (the response page) itself performs the logout action? The link for
> logging
> out would then simply become a bookmarkable link to the logout page.
> For
> some reason, this doesn't really feel right to me, though.

It does make sense to me; in that case you just mount("/logout", LogoutPage.class); in your app, and sign out in a suitable method. Having it as a separate page you can also give a "goodbye message" to the user.

> I'd much rather keep the functionality as is and, instead, have the URL
> disguised. I do understand the basics of URL mounting and encoding but
> don't
> understand how I can use it to disguise this particular scenario.

Try looking into the relationship between IRequestTarget (which you can reimplement your button as) and IRequestTargetUrlCodingStrategy and/or urlFor().

- Tor Iver

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