On Thu, Dec 17, 2009 at 2:42 AM, [email protected] <[email protected]> wrote:
> Hi,
>
> I'm stuck with some very basic concepts, even if i read a book about wicket.
>
> Let's stress the counter-example, but first the questions:
> - Basic questions: Why does the counter not increment on reload?

by default wicket provides a redirect-after-post behavior not only for
forms but also for links. you click an "action" url, the one in the
href, wicket executes the action (the onclick handler), and redirects
to a "view" url (the one you end up having in the browser) which only
renders the page.

> - Why is the WebPage created every time I reload the website, I though they
> are only created once?

a web page is created by wicket every time it is accessed via a
bookmarkable url (the mount you created or a bookmarkable link -
generally anything that takes a Class<? extends Page> will generate a
bookmarkable link)

> - Why isn't the Model used, so the Model keeps track where the value comes
> from? (ok, if the page is recreated every time, the model will be recreated,
> too. maybe solved with previous question).

not really sure what you are asking here...if the label renders a
number it is using the model.

-igor

>
> The Code:
>
> public class HomePage extends WebPage {
>
>        private Long value = 0L;
>
>        public HomePage(final PageParameters parameters) {
>                Model m = new Model<Serializable>() {
>
>                        private static final long serialVersionUID = 1L;
>                        // It doesn't matters if I take this, or value
>                        // from the WebPage
>                        private Long val = 0L;
>
>                       �...@override
>                        public Serializable getObject() {
>                                return val++;
>                        }
>
>                };
>
>                add(new Label("counter", m));
>        }
> }
>
> <html
> xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd";
>>
>    <body>
>        Counter: <span wicket:id="counter">mycounter</span><br/>
>    </body>
> </html>
>
>
> I didn't found an anwser by browsing the mailarchive or the web. Maybe the
> anwser is to obvious.
>
> Regards
> Daniel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to