0

Here's the deal: I've got a class that extends AbstractAjaxBehavior. It's got an instance on a Page, where one of its methods is overriden, tying its output to an object (or a model of it) that is the model for a form. I want that method's output to change when the form is submitted, reflecting the form's newly submitted values. What I want to update, based on a form, is something similar to this:

final MyAjaxBehavior myBehavior = new MyAjaxBehavior(){

    @Override
    protected String getName(){
        return form.getModelObject().getName();
    }
}

I can get it to work on the first form submit, but if the form's fields are changed and it is submitted again, though the rest of the page is updated, the behavior isn't.

I'm not really well-versed on models' inner workings, so I'm at a loss here.

Thanks!

EDIT: just to clarify, since Behaviors aren't usually employed like this, the Behavior I'm using is actually this thing. I'm overwriting getFileName(), and I want it to take into account changes in form model.

userBigNum
  • 227
  • 2
  • 12
  • Can you explain more clearly what you want to archive? I don 't think an AjaxBehaviour is the right choice here. – bert Jul 06 '12 at 11:05
  • Edited it with a link to the actual AjaxBehavior I'm using. I agree that using AjaxBehaviors in this kinda situation is unconventional, but the usage on the link seems rather usual, judging from how often it appears on Google results related to download-initiating in Wicket. – userBigNum Jul 06 '12 at 14:30
  • It looks to me like it should in fact work. Do you have some more code you could show? Are you certain the form is submitted without errors (i.e., is onSubmit properly called and working? Are the models updated?) – Carl-Eric Menzel Jul 25 '12 at 11:30
  • I can't show the code since I've switched jobs (and countries) and the code implemented some security stuff, so I don't even have access to it anymore (though whoever's taking care of its maintenance is likely to check my StackOverflow posts). But yup, onSubmit was called and the form's model was being updated alright. Which is why my suspicion was that the behavior was not being re-rendered at all. – userBigNum Sep 06 '12 at 20:01

0 Answers0