Well, I once wrote a servlet filter for use with wicket that can
conceal the whole URL. Actually, it was inspired by your wizard
example :)
What it does is that the whole URL is stored in session, so there's
no URL visible in browser URL field, back button is disabled on IE
and Opera and the application can be only in one state for each user
(no way to work in two windows at the same time).
Altough I'm quite uncertain, about how usable this can be because
this way you're pretty limiting the user.
I have the filter attached, if you want to play with it. I tested it
with hangman and library example and it worked well. But beware, If
you've got any exception, the only way to return to the application
home page is /library?someAttribute where someAttribute can be
anything.
Michael Jouravlev wrote:
Hi,
I am just reading the doc (the old pdf), have not started with the
code yet. Got some questions.
(1)
"All non-external pages in Wicket are not bookmarkable because they
will contain information in the URL (query parameters) that refers to
session information (which will not be available at a later time)."
Why session information is passed/stored as request variables? I would
say that the whole point of session state is to store everything on
server and to have "clean URLs", that is, without parameters.
(2)
I played with online demos a little.
http://www.wicket-library.com/wicket-examples/forminput shows page
with default content. After submit it redirects which is good, but URL
shows
http://www.wicket-library.com/wicket-examples/forminput?component=3&version=0&interface=IRedirectListener
. Why cannot it redirect to the same
http://www.wicket-library.com/wicket-examples/forminput ? It is not
version, because in case of this form version is always 0 despite of
different POST data. So, I guess this form is initialized to defaults
when there are no parameters.
Is it possible to change it to something like this (if not as
"approved" style, then as a custom style):
* http://www.wicket-library.com/wicket-examples/forminput (no params)
displays form in its current state whatever it may be. If form is
accessed for the very first time, it displays default values.
*
http://www.wicket-library.com/wicket-examples/forminput?someparam&someparam2&someparam3
issues a command on the page object, then it redirects to the "clean"
URL, which displays page in its current state.
Suggested approach allows to have only one entry in browser page
history in some (I'd say, in most) browsers. So, a user would not be
able to see stale page at all using Back button.
I hope this would not be considered as advertisement, because my
library is not a rival to Wicket framework (hi Eelco, I am thinking
about adapting my stuff to Wicket). See the sample of wizard here:
http://www.superinterface.com/wizard/signupWizard.do Open it in a
separate window and see, that back button is not enabled. This is the
point of having "clean" URL after redirect.
Can I have the same in Wicket?
(3)
"add(new ExternalPageLink("page1Link", Page1.class));"
Seems that Wicket has Page Controller paradigm: navigate to page,
render page content. Is it possible to
assign several html pages to one page class and to select one
according to Page class state? How about a component of a page? I
assume it is possible, after reading this:
http://sourceforge.net/mailarchive/message.php?msg_id=12288711
(4)
I suppose that default processing of Back button is to rollback model
to the stale page. Is it possible and how to use only one server
state, no versioning?
Thanks,
Michael.
I will be returning with more questions soon ;)
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar
happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in
dual
core and dual graphics technology at this free one hour event
hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
------------------------------------------------------------------------
/*
* URLFilter.java
*
* Created on Monday, 2005, june 27, 10:45
*/
package wicket.examples;
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
*
* @author Matej Knopp
* @version
*/
public class URLFilter implements Filter {
// The filter configuration object we are associated with. If
// this value is null, this filter instance is not currently
// configured.
private FilterConfig filterConfig = null;
public URLFilter () {
}
/* * This response wrapper is here to determine if servlet
wanted
* to send redirect. */
static class ResponseWrapper extends HttpServletResponseWrapper {
public String redirect = null;
ResponseWrapper (HttpServletResponse response) {
super (response);
}
public void sendRedirect (String location) throws
IOException {
redirect = location;
}
public void sendRedirectReal (String location) throws
IOException {
super.sendRedirect (location);
}
}
String attrName = "URL";
/**
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/ public void doFilter (ServletRequest req,
ServletResponse resp,
FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request =
(HttpServletRequest) req;
ResponseWrapper response = new ResponseWrapper
((HttpServletResponse) resp);
HttpSession session = request.getSession ();
String iface = request.getParameter ("interface");
if (iface == null)
iface = "";
if (request.getQueryString () == null &&
session.getAttribute (attrName) != null) { //
no query string and url is in session -> forward the request
request.getRequestDispatcher
((String)session.getAttribute (attrName))
.forward (request, response);
} else if (iface.equalsIgnoreCase ("IRedirectListener") ||
request.getParameter ("bookmarkablePage") != null) {
// we have a bookmarkable page or a redirect listener
// store the URL in session and redirect to a page with
no // query parameters
String url = request.getServletPath ();
url = url + "?" + request.getQueryString () +
"&doNotTouch=1";
session.setAttribute (attrName, url);
response.sendRedirectReal (request.getServletPath
().substring (1));
} else {
// otherwise do the filter chain
chain.doFilter (request, response);
// did we get redirect?
if (response.redirect != null) {
// yes we did. get the query string
int paramStart = response.redirect.indexOf ("?");
String parameters;
if (paramStart != -1) // do we have one?
parameters = response.redirect.substring
(paramStart) + "&doNotTouch=1"; else
parameters = "?doNotTouch=1"; //
put the url requested by redirect to session (it's converted to
local path,
// because of the forwarding
session.setAttribute (attrName,
request.getServletPath () + parameters);
// redirect to a page without query parameters
response.sendRedirectReal (request.getServletPath
().substring (1));
} else {
// no redirect
// If the render policy is set to render to buffer,
// this will redirect to a page with no query
parameters,
// otherwise this will do nothing, since the content
of a page
// is already written
String url = request.getServletPath ();
url = url + "?" + request.getQueryString () +
"&doNotTouch=1";
// put the current URL in session
session.setAttribute (attrName,
url); // redirect to a page
without query parameters
response.sendRedirectReal (request.getServletPath
().substring
(1));
} } }
/**
* Return the filter configuration object for this filter.
*/
public FilterConfig getFilterConfig () {
return (this.filterConfig);
}
/**
* Set the filter configuration object for this filter.
*
* @param filterConfig The filter configuration object
*/
public void setFilterConfig (FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}
/**
* Destroy method for this filter
*
*/
public void destroy () {
}
/**
* Init method for this filter
*
*/
public void init (FilterConfig filterConfig) {
this.filterConfig = filterConfig;
if (filterConfig != null) {
if (debug) {
log ("URLFilter:Initializing filter");
}
if (filterConfig.getInitParameter ("attrName") != null) {
this.attrName = filterConfig.getInitParameter
("attrName");
}
}
}
public void log (String msg) {
filterConfig.getServletContext ().log (msg);
}
private static final boolean debug = true;
}