On Wed, Mar 19, 2008 at 10:54 PM, Igor Vaynberg <[EMAIL PROTECTED]>
wrote:

> yes. there is a phase of processing that goes through and collects the
> feedback messages. you are reporting the error after that phase most
> likely, so it will get picked up next request. i wonder if calling
> feedbackpanel.detach() will help before you add it to the ajax request
> target...
>
> -igor
>
>
> On Wed, Mar 19, 2008 at 7:06 PM, Matthew Young <[EMAIL PROTECTED]> wrote:
> > >>  Overriding onBeforeRender() doesn't work on Ajax, it's not called :(
> >  >
> >  >it is, but only on components that get updated via ajax...so you might
> >  >want to move the code to one of those...
> >
> >  Now the code gets call in Ajax. But the error message still doesn't
> show up
> >  in FeedbackPanel.  Does this make sense to you at all?
> >
> >
> >  On Wed, Mar 19, 2008 at 6:23 PM, Igor Vaynberg <[EMAIL PROTECTED]
> >
> >
> >
> > wrote:
> >
> >  > On Wed, Mar 19, 2008 at 5:54 PM, Matthew Young <[EMAIL PROTECTED]>
> wrote:
> >  > > Hi Igor,
> >  > >
> >  > >  Overriding onBeforeRender() doesn't work on Ajax, it's not called
> :(
> >  >
> >  > it is, but only on components that get updated via ajax...so you
> might
> >  > want to move the code to one of those...
> >  >
> >  > >  Is there anyway to handle this kind of error condition for both
> Ajax
> >  > and
> >  > >  non-Ajax?
> >  >
> >  > see above
> >  >
> >  > >  Having to abandon LoadableDeachableModel is a pity.  The code is
> much
> >  > >  clearer with LoadableDeachableModel.  Anyway, does Wicket have any
> way
> >  > to
> >  > >  let user code handle model error late in the render phase?
> >  >
> >  > yes it is a pity. we consider errors that happen inside models
> >  > unrecoverable because they can happen at a lot of different points in
> >  > the lifecycle of the component. i think throwing a
> >  > restartresponseexception from inside a model might work, but that
> will
> >  > only get you to a different page....hmm, maybe... { error("failed");
> >  > throw restartresponseexception(MyPage.this); } will work, but then
> you
> >  > gotta watch out for an infinite loop... you would have to first check
> >  > if the page contains any error messages...
> >  >
> >  > -igor
> >  >
> >  >
> >  >
> >  >
> >  > >  Thanks!
> >  > >
> >  > >  On Wed, Mar 19, 2008 at 2:53 PM, Igor Vaynberg <
> [EMAIL PROTECTED]
> >  > >
> >  > >  wrote:
> >  > >
> >  > >
> >  > >
> >  > >  > im thinking it might be too late at that point to register the
> >  > >  > messages because the feedback panel might have already
> rendered...
> >  > >  >
> >  > >  > perhaps instead of using a loadable detachable model you do
> something
> >  > like
> >  > >  > this:
> >  > >  >
> >  > >  > class mypage {
> >  > >  >  private List result;
> >  > >  >
> >  > >  >  onbeforerender() {
> >  > >  >      try {
> >  > >  >        result=populatelist();
> >  > >  >      } catch (exception e) {
> >  > >  >        error("foo");
> >  > >  >      }
> >  > >  >      super.onbeforerender();
> >  > >  >   }
> >  > >  >
> >  > >  >   ondetach() { result=null; super.ondetach(); }
> >  > >  >
> >  > >  >
> >  > >  >   .. add(new listview("foo", new propertymodel(this, "result"));
> >  > >  >
> >  > >  > }
> >  > >  >
> >  > >  > -igor
> >  > >  >
> >  > >  >
> >  > >  >
> >  > >  > On Wed, Mar 19, 2008 at 2: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);
> >  > >  > >     }
> >  > >  > >  }
> >  > >  > >
> >  > >  >
> >  > >  >
> ---------------------------------------------------------------------
> >  > >  > 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]
> >  >
> >  >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to