On 3/15/08, Matej Knopp <[EMAIL PROTECTED]> wrote:
> Your page implementing Externalizable breaks wicket. Wicket relies of
>  Page#writeReplace, writeObject, readObject being called. Are you sure
>  you're no seing any stacktrace?
>

Ok, I think I'm getting somewhere with this.  I changed my exploration
code a bit.  Here's my HomePage class (sorry for the verbose email,
but I'm trying to understand this better):

public class HomePage extends WebPage
{
    private static final long serialVersionUID = 1L;
    private static final Logger log = LoggerFactory.getLogger(HomePage.class);

    private int counter;

    /**
     * Constructor that is invoked when page is invoked without a session.
     *
     * @param parameters Page parameters
     */
    public HomePage( final PageParameters parameters )
    {
        // Add the simplest type of label
        add(new Label("message", new LoadableDetachableModel()
        {
            protected Object load()
            {
                return "I've been called " + counter++ + " times.";
            }
        }));
        add(new Link("refreshLink")
        {
            public void onClick()
            {
                log.info("I'm being called on object with identity " +
System.identityHashCode(HomePage.this));
                setResponsePage(HomePage.this);
            }
        });
    }


    protected Object writeReplace() throws ObjectStreamException
    {
        final Object replacement = super.writeReplace();
        log.info("I'm (identity " + System.identityHashCode(this) + ")
being write replaced by object " + replacement);
        return replacement;
    }
}

And, here's the HomePage.html file:

<html>
    <head>
        <title>Wicket Quickstart Archetype Homepage</title>
    </head>
    <body>
        <strong>Wicket Quickstart Archetype Homepage</strong>
        <br/><br/>
        <span wicket:id="message">message will be here</span>
    <p>
        Click <a href="." wicket:id="refreshLink">here</a> to refresh me!
    </p>
    </body>
</html>

Now, I see the expected behavior in IE7, but not in Firefox.  When I
hit the back button in IE7, the page is actually refreshed.  When I
hit the back button in Firefox, it isn't.  Does the page completely
have to refresh (when hitting "back") to get the functionality to work
properly?  I would think that the link URL would tell you enough to go
get the proper version of the page.  What I expect to happen is that
when you hit back and click the link, it should display "I have been
called 1 times."  Am I understanding what's supposed to be going on
correctly?  Here's what happens with IE7:

1.  View the HomePage (counter == 0)

INFO  - HomePage                   - I'm (identity 8940240) being
write replaced by object [Page class =
com.carmanconsulting.wicket.demo.HomePage, id = 0, version = 0]

2.  Click the link (counter == 1)

INFO  - HomePage                   - I'm being called on object with
identity 8940240
INFO  - HomePage                   - I'm (identity 8940240) being
write replaced by object [Page class =
com.carmanconsulting.wicket.demo.HomePage, id = 0, version = 0]

3.  Hit the back button (counter == 0)

INFO  - HomePage                   - I'm (identity 4113761) being
write replaced by object [Page class =
com.carmanconsulting.wicket.demo.HomePage, id = 1, version = 0]

4.  Click the link again (counter == 1)

INFO  - HomePage                   - I'm being called on object with
identity 4113761
INFO  - HomePage                   - I'm (identity 4113761) being
write replaced by object [Page class =
com.carmanconsulting.wicket.demo.HomePage, id = 1, version = 0]

And, here's what happens with Firefox:

1.  View the HomePage (counter == 0)

INFO  - HomePage                   - I'm (identity 5068149) being
write replaced by object [Page class =
com.carmanconsulting.wicket.demo.HomePage, id = 0, version = 0]

2.  Click the link (counter == 1)

INFO  - HomePage                   - I'm being called on object with
identity 5068149
INFO  - HomePage                   - I'm (identity 5068149) being
write replaced by object [Page class =
com.carmanconsulting.wicket.demo.HomePage, id = 0, version = 0]

3.  Hit the back button (counter == 0)

*** No Output! ***

4.  Click the link again (counter == 2)

INFO  - HomePage                   - I'm being called on object with
identity 5068149
INFO  - HomePage                   - I'm (identity 5068149) being
write replaced by object [Page class =
com.carmanconsulting.wicket.demo.HomePage, id = 0, version = 0]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to