On 4/11/07, Jason Roelofs <[EMAIL PROTECTED]> wrote:
> How do you do this? I have a form with a few fields that onSubmit I want to
> complete redo the page. I know it's not happening by default because there's
> a generated string that doesn't change when it's supposed to.

You probably show the string as follows?

add(new Label("text", "My " + generated + " string"));
or
add(new Label("text", myGenerator.getGeneratedString());

This creates a static binding between the generated string *at
construction time* and the label. What you need to do is to evaluate
the string generation 'lazily', or at render time.

The constructor is only called once for a page, so the static strings
will only be generated once.

The solution for your problem can be anything from using PropertyModel
to creating an inline, anonymous subclass of AbstractReadOnlyModel
like:

add(new Label("text", new AbstractReadOnlyModel() {
    public Object getObject() {
        return generator.getGeneratedText();
    }));

Be sure to read up on models at this page [1].

Martijn

[1] http://cwiki.apache.org/WICKET/working-with-wicket-models.html

-- 
Learn Wicket at ApacheCon Europe: http://apachecon.com
Join the wicket community at irc.freenode.net: ##wicket
Wicket 1.2.5 will keep your server alive. Download Wicket now!
http://wicketframework.org

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to