I'm a bit short in time currently, so I haven't taken a very detailed
look at your proposal. However, my first question is why you want to
use bookmarkable pages at all? If you want to preserve state, the way
to go would be to use links and forms.
It looks to me you're looking for a zero state mechanism here. For
that, there's too much at stake to implement a quick resolution. It
(the research at least) is scheduled for 1.2, and will have
consequences for many Wicket internals.
Eelco
On 9/8/05, Michael Jouravlev <[EMAIL PROTECTED]> wrote:
> So any opinions on single-instance Page? The code changes are inline,
> I can submit them as patches if needed.
>
> (1) Page -- added isSingleton flag, mustReset flag and reset() method:
>
> === cut here ===
> /**
> * Flag which is set if the instance of this Page must be reset.
> * Default value for reset flag is <code>false</code>.
> */
> private boolean mustReset;
>
> /**
> * Returns reset flag value. If true, instance of this Page must be reset.
> * Default value for reset flag is <code>false</code>.
> */
> public boolean isMustReset() { return mustReset; }
>
> /**
> * Sets reset flag.
> * @param mustReset reset flag. True means that instance of this Page
> * must be reset before displaying to a user, false
> * means that this Page should not be reset.
> */
> public void setMustReset(boolean mustReset) {
> this.mustReset = mustReset;
> }
>
> /**
> * Resets this Page. Usually this means cleaning up the corresponding
> model,
> * containing input data.
> */
> public void reset() {}
>
> /**
> * Name of singleton flag.
> */
> public static final String SINGLETON_FLAG_NAME = "isSingleton";
>
> /**
> * Flag which should be set if this class should have only one instance.
> */
> static protected boolean isSingleton;
> === cut here ===
>
> (2) WebRequest.parseRequest() -- checking "wicket-reset" request
> parameter and setting reset flag on a page:
>
> === cut here ===
> protected final boolean parseRequest()
> {
> if (callDispatchedComponentListener())
> {
> // if it is, we don't need to update the cluster, etc, and return
> false
> }
> // it wasn't a dispatched listener, try other methods
> else if (callComponentListener() || bookmarkablePage() || homePage())
> {
> Page responsePage = getResponsePage();
>
> // Check reset parameter in request; set page reset flag
> boolean pageReset =
> getWebRequest().getParameter("wicket-reset") != null;
> responsePage.setMustReset(pageReset);
>
> // Returning a page
> return true;
> }
> ...
> }
> === cut here ===
>
> (3) SignInSession -- storing instances for all single-instance page
> classes for SignIn application.
>
> === cut here ===
> /**
> * List of "current" pages, that is, the very recent instances
> * of each concrete Page subclass.
> */
> protected Map recentPages = new HashMap();
> public Map getRecentPages() { return recentPages; }
> === cut here ===
>
> (4) AuthenticatedWebPage -- using existing instance of SignIn page if
> exists; resetting page model.
>
> === cut here ===
> protected boolean checkAccess()
> {
> // Is a user signed into this cycle's session?
> boolean signedIn = getSignInSession().isSignedIn();
>
> // If nobody is signed in
> if (!signedIn)
> {
> Page signInPage = myNewPage(SignIn.class);
>
> // SignIn page should be reset
> signInPage.setMustReset(isMustReset());
>
> // Call reset() unconditionally, let SignIn page check the flag
> // and decide should it reset or not
> signInPage.reset();
>
> // Redirect request to SignIn page
> redirectToInterceptPage(signInPage);
> }
>
> // Return true if someone is signed in and access is okay
> return signedIn;
> }
>
>
> public Page myNewPage(final Class c) {
> Page page = null;
> Field isSingletonField = c.getDeclaredField(SINGLETON_FLAG_NAME);
> boolean isSingleton = isSingletonField.getBoolean(null);
>
> if (isSingleton) {
> // This map is defined in SignInSession class
> Map recentPages = getSignInSession().getRecentPages();
> if (recentPages != null) {
> page = (Page) recentPages.get(SignIn.class.getName());
> }
>
> // Reset existing page, this is what we are after
> if (page != null && page.isMustReset()) {
> page.reset();
> }
>
> // Singleton page not found, create and store
> if (page == null) {
> page = newPage(c);
> recentPages.put(c.getName(), page);
> }
>
> // Page is not singleton, create unconditionally
> } else {
> page = newPage(c);
> }
> return page;
> }
> === cut here ===
>
> (5) SignIn -- implemented reset() method
>
> === cut here ===
> public void SignIn.reset() {
> if (isMustReset()) {
> properties.remove("username");
> properties.remove("password");
> }
> }
> === cut here ===
>
> Michael.
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Wicket-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
>
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop