You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by David Berkman <da...@glu.com> on 2011/10/25 20:56:54 UTC

Problem with Panel default model

Thank you. Upgrade to 1.5.2 did seem to resolve the issue with the last ajax request parameters being pushed onto the base url. However, testing that resolution exposed a further problem. I'm using a org.apache.wicket.markup.html.panel.Panel into which I'm handing the a org.apache.wicket.model.Model and setting it as the default model via the constructor...

  public class MyPanel extends Panel {

    public MyPanel (final String id, final IModel<> model) {

      super(id, model);
    }
  }


The model in question stores a java Enum, call it MyEnum...

  public enum MyEnum {

    ONE, TWO, THREE
  }

  new MyPanel("panelId", new Model<MyEnum>(MyEnum.values()[0]));


On an ajax callback I update the model on this panel...

  public class MyPanel extends Panel {

    ...

    public void setValue (String value) {

      setDefaultModelObject(MyEnum.value(value));
    }
  }

...all of which works fine. The problem is that the value which is set at the time of the first page reload is the value that will be reset upon any subsequent page reload. The model updates correctly on the MyPanel instance responding to each ajax callback. Not a problem. But when I reload the page, the value of the model will revert to whatever value it had after the *first* page reload. I notice that the default model instance changes upon page reload. So, for example...

1) MyPanel holds Model@1234
2) set Model@1234 to value MyEnum.TWO, no problem
3) page reload...
4) MyPanel now holds Model@2345 which holds MyEnum.TWO... this is correct, but the Model instance has changed.
5) set Model@2345 to value MyEnum.THREE, no problem
6) page reload...
7) MyPanel now holds Model@3456 which holds MyEnum.TWO, where did MyEnum.TWO come from?
8) I can now continue to set the model value via ajax callbacks, and all is well, and the Model@3456 holds its values just fine
9) page reload...
10) No matter what the value of the Model@3456 was last set to, MyPanel now holds new instance Model@4567 which *will* hold MyEnum.TWO

Anyone know what's going on?

Thank you,
David


-----Original Message-----
From: Martin Grigorov [mailto:mgrigorov@apache.org] 
Sent: Monday, October 24, 2011 10:24 PM
To: users@wicket.apache.org
Subject: Re: Problem with ajax base url

Hi

Try with 1.5.2.
This is fixed with https://issues.apache.org/jira/browse/WICKET-4109


RE: Problem with Panel default model

Posted by David Berkman <da...@glu.com>.
It does...

  private static final ThreadLocal<Boolean> STRIP_TAGS_LOCAL = new ThreadLocal<Boolean>();

  @Override
  protected void onBeforeRender () {

    super.onBeforeRender();

    STRIP_TAGS_LOCAL.set(Application.get().getMarkupSettings().getStripWicketTags());
    Application.get().getMarkupSettings().setStripWicketTags(true);
  }

  @Override
  protected void onAfterRender () {

    Application.get().getMarkupSettings().setStripWicketTags(STRIP_TAGS_LOCAL.get());

    super.onAfterRender();
  }

...using these methods to strip wicket tags for the rendering of this panel only. But, both onBeforeRender() and onAfterRender() are calling the same methods on their super class, which is Panel, and I'm not touching any models.

David 


-----Original Message-----
From: Andrea Del Bene [mailto:adelbene@ciseonweb.it] 
Sent: Wednesday, October 26, 2011 1:13 AM
To: users@wicket.apache.org
Subject: Re: Problem with Panel default model

Hi,

does your page override onBeforeRender method? Can you show the code?
> Thank you. Upgrade to 1.5.2 did seem to resolve the issue with the last ajax request parameters being pushed onto the base url. However, testing that resolution exposed a further problem. I'm using a org.apache.wicket.markup.html.panel.Panel into which I'm handing the a org.apache.wicket.model.Model and setting it as the default model via the constructor...
>
>    public class MyPanel extends Panel {
>
>      public MyPanel (final String id, final IModel<>  model) {
>
>        super(id, model);
>      }
>    }
>
>
> The model in question stores a java Enum, call it MyEnum...
>
>    public enum MyEnum {
>
>      ONE, TWO, THREE
>    }
>
>    new MyPanel("panelId", new Model<MyEnum>(MyEnum.values()[0]));
>
>
> On an ajax callback I update the model on this panel...
>
>    public class MyPanel extends Panel {
>
>      ...
>
>      public void setValue (String value) {
>
>        setDefaultModelObject(MyEnum.value(value));
>      }
>    }
>
> ...all of which works fine. The problem is that the value which is set at the time of the first page reload is the value that will be reset upon any subsequent page reload. The model updates correctly on the MyPanel instance responding to each ajax callback. Not a problem. But when I reload the page, the value of the model will revert to whatever value it had after the *first* page reload. I notice that the default model instance changes upon page reload. So, for example...
>
> 1) MyPanel holds Model@1234
> 2) set Model@1234 to value MyEnum.TWO, no problem
> 3) page reload...
> 4) MyPanel now holds Model@2345 which holds MyEnum.TWO... this is correct, but the Model instance has changed.
> 5) set Model@2345 to value MyEnum.THREE, no problem
> 6) page reload...
> 7) MyPanel now holds Model@3456 which holds MyEnum.TWO, where did MyEnum.TWO come from?
> 8) I can now continue to set the model value via ajax callbacks, and all is well, and the Model@3456 holds its values just fine
> 9) page reload...
> 10) No matter what the value of the Model@3456 was last set to, MyPanel now holds new instance Model@4567 which *will* hold MyEnum.TWO
>
> Anyone know what's going on?
>
> Thank you,
> David
>
>
> -----Original Message-----
> From: Martin Grigorov [mailto:mgrigorov@apache.org]
> Sent: Monday, October 24, 2011 10:24 PM
> To: users@wicket.apache.org
> Subject: Re: Problem with ajax base url
>
> Hi
>
> Try with 1.5.2.
> This is fixed with https://issues.apache.org/jira/browse/WICKET-4109
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Problem with Panel default model

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Hi,

does your page override onBeforeRender method? Can you show the code?
> Thank you. Upgrade to 1.5.2 did seem to resolve the issue with the last ajax request parameters being pushed onto the base url. However, testing that resolution exposed a further problem. I'm using a org.apache.wicket.markup.html.panel.Panel into which I'm handing the a org.apache.wicket.model.Model and setting it as the default model via the constructor...
>
>    public class MyPanel extends Panel {
>
>      public MyPanel (final String id, final IModel<>  model) {
>
>        super(id, model);
>      }
>    }
>
>
> The model in question stores a java Enum, call it MyEnum...
>
>    public enum MyEnum {
>
>      ONE, TWO, THREE
>    }
>
>    new MyPanel("panelId", new Model<MyEnum>(MyEnum.values()[0]));
>
>
> On an ajax callback I update the model on this panel...
>
>    public class MyPanel extends Panel {
>
>      ...
>
>      public void setValue (String value) {
>
>        setDefaultModelObject(MyEnum.value(value));
>      }
>    }
>
> ...all of which works fine. The problem is that the value which is set at the time of the first page reload is the value that will be reset upon any subsequent page reload. The model updates correctly on the MyPanel instance responding to each ajax callback. Not a problem. But when I reload the page, the value of the model will revert to whatever value it had after the *first* page reload. I notice that the default model instance changes upon page reload. So, for example...
>
> 1) MyPanel holds Model@1234
> 2) set Model@1234 to value MyEnum.TWO, no problem
> 3) page reload...
> 4) MyPanel now holds Model@2345 which holds MyEnum.TWO... this is correct, but the Model instance has changed.
> 5) set Model@2345 to value MyEnum.THREE, no problem
> 6) page reload...
> 7) MyPanel now holds Model@3456 which holds MyEnum.TWO, where did MyEnum.TWO come from?
> 8) I can now continue to set the model value via ajax callbacks, and all is well, and the Model@3456 holds its values just fine
> 9) page reload...
> 10) No matter what the value of the Model@3456 was last set to, MyPanel now holds new instance Model@4567 which *will* hold MyEnum.TWO
>
> Anyone know what's going on?
>
> Thank you,
> David
>
>
> -----Original Message-----
> From: Martin Grigorov [mailto:mgrigorov@apache.org]
> Sent: Monday, October 24, 2011 10:24 PM
> To: users@wicket.apache.org
> Subject: Re: Problem with ajax base url
>
> Hi
>
> Try with 1.5.2.
> This is fixed with https://issues.apache.org/jira/browse/WICKET-4109
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Problem with Panel default model

Posted by kiranduba <ki...@gmail.com>.
Hi David,
Did you found the solution for this problem? I'm also facing such kind of
issue. I have a Model with list of POJO. On drag/drop i'm giving ajax call
and updating the paramter in POJO which is in Model. If I call sort on the
list of POJO based on parameter the Model reset's to the initial stage when
page is rendered. So if i do drag/drop again it picks up the wrong POJO
element in the model. Please suggest I'm stuck at this point. I'm using
Wicket 6 with AbstractAjaxBehaviour.

Thanks,
Kiran Duba



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-with-ajax-base-url-tp3934751p4661243.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org