There is one important information that I had forgotten to mention. The link on my start page is not a link. It is a button from within a form.
Andre On Tue, 3 Jul 2012 11:41:36 +0200 (CEST) [email protected] wrote: > Hello, > > thanks for the answers. At the moment I am not able to access my code but let > me explain the code in detail and give you some additional examples. I think > the idea with the stateful behavior could be right but I do not understand > the > reason. > > In detail. > > - I have a starting page where a Link is constructed that depending on the > available > PageParameters links to the second page with or without PageParameters: > > p.. PageParameters > > setResponsePage(MyPage2.class, p) or setResponsePage(MyPage2.class) or > > - After clicking the link on the starting page, the MyPage2 will be opened > and > the constructor adds the elements to the page. A Form will be added and gets > a Model that is created in the constructor: > > MyModel model = new MyModel(); > > The MyModel has two fields. > class MyModel { > private String text; > private List<String> classes; > public void setText .. > public void setClasses... > public String getText ... > public List<String> getClasses... > } > > The "classes" field is pre-filled with 3 entries in the MyModel class. > > Before the end of the constructor, my Form is added with: > add(new MyForm("id", new CompoundPropertyModel(model))); > > When I submit the form, the MyPage3 is opened and the values from > the MyForm are used. > > When I click back to my starting page and click on the link to MyPage2, > the selected values from the first click to this page are filled in the > MyModel. I printed the values of MyModel directly after the line: > MyModel model = new MyModel() > Normally, the pre-filled values should be in the classes variable. BUT ... > I have the selected values from the first call of the MyPage2. > That's my miracle :) > > Thanks for any additional help > Andre > > ----- Original Message ----- > From: [email protected] > To: [email protected] > Date: 03.07.2012 07:44:54 > Subject: Re: Model is not created > > > > On Mon, Jul 2, 2012 at 11:45 PM, Andre Schütz <[email protected]> wrote: > >> Hello, > >> > >> I have a problem with the creation of a model in one of my pages. > >> It works as follows: > >> > >> I have a link that uses setResponsePage(new MyPage(parameters)) on the > >> click > > > > I'd recommend to use setResponsePage(MyPage.class, parameters) instead > > in this case. This way you will have a nice looking url and the page > > may stay stateless if there are no stateful components/behaviors in > > it. > > If you know the parameters earlier then you can even use > > BookmarkablePageLink("id", MyPage.class, parameters) - this will save > > you a http redirect. > > > >> with parameters as PageParameters. > >> At the MyPage site, the constructor creates a: > >> IModel<MyModel> model = new IModel<MyModel>() { > >> public void setObject .. > >> public MyModel getObject.. > >> } > >> > >> This variable is used to create a CompoundPropertyModel for a Form. > >> > >> The first time when I click on my link to the MyPage site, everything > >> is fine. At the second time, the MyModel variable is not empty. The > >> variable is filled with the selected values from the first time when > >> I clicked on the link to the MyPage site. > >> > >> I do not understand this behavior. Normally, the MyModel variable > >> should be empty and not filled with the last selection. > >> > >> Has someone an idea? > >> > >> Thanks, > >> Andre > >> > >> -- > >> Andre Schütz <[email protected]> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > > > > > > > > -- > > Martin Grigorov > > jWeekend > > Training, Consulting, Development > > http://jWeekend.com > > > > --------------------------------------------------------------------- > > 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] -- Andre Schütz <[email protected]> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
