This doesn't work because the model.getObject method is only called
when the value is pulled out of the model, which is on label render.
Even if you refresh it on ajax request, it might be too late because
the feedback panel retrieves the feedback messages in onBeforeRender
(before actual rendering).

-Matej

On Wed, Mar 19, 2008 at 10:04 PM, Matthew Young <[EMAIL PROTECTED]> wrote:
>  I register an error to the page in the model but the feedback message
>  doesn't show in FeedbackPanel.  Only the error message register in
>  onSubmit() event handler shows.  Please have a look.  Thanks!
>
>  HomePage.html:
>
>  <html>
>  <head></head>
>     <span wicket:id="message">message will be here</span>
>     <form wicket:id="form">
>         <input type="text" wicket:id="word"/>
>         <input type="submit" value="Enter" wicket:id="submitButton"/>
>     </form>
>     <span wicket:id="feedback">FEEDBACK</span>
>  </html>
>
>
>  HomePage.java
>
>  import ...
>
>  public class HomePage extends WebPage {    private static final long
>  serialVersionUID = 1L;
>
>     private String word;
>
>     public HomePage(final PageParameters parameters) {
>
>         add(new
>  FeedbackPanel("feedback").setOutputMarkupPlaceholderTag(true));
>         // if the word 'blowup' is entered, this model register a error
>  message to the page
>         IModel model = new Model() {            private static final long
>  serialVersionUID = 1L;
>             @Override public Object getObject() {
>                 if (word != null && word.equals("blowup")) {
>                     word = "-b-l-o-w-u-p-";
>                     HomePage.this.fatal("This message is from model.");
>                     return "BAD THING HAPPENED IN MODEL";
>                 } else {
>                     return "The word is: \"" + (word == null ? " n u l l " :
>  word) + "\"";
>                 }
>             }
>         };
>         add(new Label("message", model).setOutputMarkupId(true));
>         Form form = new Form("form", new CompoundPropertyModel(this));
>         add(form);
>         form.add(new TextField("word").setRequired(true));
>
>         AjaxFallbackButton submitButton = new
>  AjaxFallbackButton("submitButton", form) {
>             private static final long serialVersionUID = 1L;
>             @Override protected void onSubmit(AjaxRequestTarget target, Form
>  f) {
>                 if (word != null && word.equals("blowup")) {
>                     HomePage.this.error("This message is from onSubmit.
>  There should also be a message from model");
>                 }
>                 if (target != null) {
>                     target.addComponent(HomePage.this.get("feedback"));
>                     target.addComponent(HomePage.this.get("message"));
>                 }
>             }
>
>             @Override protected void onError(AjaxRequestTarget target, Form
>  f) {
>                 target.addComponent(HomePage.this.get("feedback"));
>  // show updated error feedback
>             }
>         };
>         form.add(submitButton);
>     }
>  }
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

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

Reply via email to