hmmm

new Button<Object>(form,"previous") {
                      public void onSubmit() {

getPage().getVersion(getPage().getCurrentVersionNumber()-1);
                      }
              };

This would work fine now i guess in the latest code of 1.3
But that is because a page version is now always a different instance.
Because we don't rollback anymore
the same page instance (there is no changelist anymore)

But this will not work when you use the accessstackpagemap (the normal
httpsessionstore impl)
Because then what happens is that the current page is changed underneath
your own call.
that could really result in all kind of strange things.

That page getVersion is really an wicket internal thing...

I also don't know if currentversionnumber-1 is the right page you want.
Because if the version number is already increased before that onsubmit call
(not very likely)
then -1 is the page you just got from and not the page before that.

johan



On 2/7/07, Jan Vermeulen <[EMAIL PROTECTED]> wrote:


Here is the code of a page that can simulate the problem:

The java source:

import wicket.markup.html.WebPage;
import wicket.markup.html.basic.Label;
import wicket.markup.html.form.Button;
import wicket.markup.html.form.Form;
import wicket.markup.html.form.TextField;
import wicket.model.IModel;
import wicket.model.Model;

public class TestPage extends WebPage {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("serial")
        public TestPage()
        {
                super();

                Form form = new Form(this,"form");
                new TextField<String>(form,"input",new
Model<String>()).setVersioned(true);
                new Button<String>(form,"ok") {
                        public void onSubmit() {
                        }
                };
                new Button<Object>(form,"previous") {
                        public void onSubmit() {

                                
getPage().getVersion(getPage().getCurrentVersionNumber()-1);
                        }
                };

                IModel<Integer> outputModel = new IModel<Integer>() {
                        public Integer getObject() {

                                return(getPage().getCurrentVersionNumber());
                        }
                        public void setObject(Integer object) {}
                        public void detach() {}
                };
                new Label(this,"output",outputModel);
        }
}

the markup:
<html>
    <head>
        <title>TestPage</title>
   </head>
    <body>
    <h1>TestPage</h1>
    <form wicket:id="form">
    <input type="text" wicket:id="input"></input>
    <button wicket:id="ok" type=submit>OK</button>
    <button wicket:id="previous" type=submit>Previous</button>
    </form>
    Version: <span wicket:id="output"></span>
         </body>
</html>

The problem occurs whenever you change the value of the input field, and
hits the Previous button.
If you created 3 versions already, it will render the contents of the
version 1 with versionnumber 2.
And if you hit the Previous buton once again, it will render the contents
of
version 3 with versionnumber 1 (this last one because it finally called
endVersion after the undo, saving the pending changeList).

So you are telling me I cannot call getVersion(oldVersionNumber) on a page
while the flag FLAG_NEW_VERSION is true ? I cannot read this flag from
outside. If what I do is wrong, shouldn't there be some protection against
this type of erroneous usage ?

Jan.


Johan Compagner wrote:
>
>>
>> * each time beginVersion is called, the versionNumber is incremented
and
>> a
>> new changeList is created. But that new changeList is NOT added to the
>> stack
>> of changeLists.
>
>
> yes thats right that is done in the endVersion() call.
> Adding it before hand shouldn't make any sense.
>
>
> * when getVersion(int versionNumber) is called with an older
versionNumber
>> after a call to beginVersion() and before a call to endVersion(), the
>> undo()
>> method is called, which pops the last changeList from the stack and
>> decrements the versionNumber. Since the 'current' changeList is not yet
>> on
>> the stack, it pops one more changeList from the stack than it should.
>
>
> This is really really wrong. This should never be possible
> How does it happens that that call to getVersion() is done twice at the
> same
> time??
> A page shouldn't be accesses more then once (at the same time)
>
>
> Something to be corrected ? Mayby the newly created changeList should be
>> added to the stack immediately ? Or is it more correct to not increment
>> the
>> versionNumber until the call to endVersion() ?
>
>
>
> No it shouldn't because when happens then if the second call did happen
> for
> an old version?
> And another request is happening at the same time for another?
> Thats really bad, shouldn't happen at anytime. So if you have a test
case
> for that then
> i would really like to see it.
>
> johan
>
>

--
View this message in context:
http://www.nabble.com/Single-page-applications%3A-bad-idea-in-Wicket---tf3182341.html#a8850275
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Reply via email to