You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jbrookover <jb...@cast.org> on 2010/06/29 22:47:33 UTC

Model not Updating on Multiple Form Submits

Hey all,

I have a component, ResponseArea, that get's a
HibernateObjectModel<Response>.  This ResponseArea then passes that same
model down to it's sub components (ResponseEditor, ResponseViewer).  

ResponseEditor passes this model further down to a Form<Response>.  I have
some jQuery script that does a timed autosave submit of this form.

When the form submits, I do this (pseudocode):

Response newR = new Response();
newR.setData(Form.this.get("dataField").getDefaultModelObjectAsString();
saveResponse(Form.this.getModelObject(), newR);

The last step of the saveResponse(Response oldR, Response newR) method does
some processing, comparing the two versions of the response, and finally
calls:  

ResponseEditor.this.setDefaultModelObjet(newR);

Now, I expect this effect to propagate up to the parent ResponseArea and
down to the Form to be ready for the next AutoSave.  The problem is this:

At some point in the processing, the Form seems to clone the model and never
gets the new object - it retains the original object as its model object. 
So instead of this behavior

1st Autosave Execute: saveResponse(original, respond1)
2nd Autosave Execute: saveResponse(respond1, respond2)
3rd Autosave Execute: saveResponse(respond2, respond3)

I get this:

1st Autosave Execute: saveResponse(original, respond1)
2nd Autosave Execute: saveResponse(original, respond2)
3rd Autosave Execute: saveResponse(original, respond3)

Since my form would like to see progressive changes, this doesn't work.

Thoughts?

I sense IComponentInheritedModel is involved, but I'm surprised that this
isn't a native behavior.  It also seems to work in every other case - so why
not now?

Thanks!

Jake

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Model-not-Updating-on-Multiple-Form-Submits-tp2272644p2272644.html
Sent from the Wicket - User 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


Re: Model not Updating on Multiple Form Submits

Posted by jbrookover <jb...@cast.org>.
Hello,

Just a follow up on this from awhile back, since someone might encounter it
again.

The problem, which someone pointed out off-list, is that triggering an ajax
form submit using jQuery does a complete non-Ajax page load, but then dumps
that page.  So, the model was being updated on subsequent pages, but those
pages were not being displayed and the original page had stale data.

Perhaps there is a way to access the page map and make the appropriate
adjustments, but I decided to dive into the wicket-ajax.js and execute the
wicketSubmitFormById() myself.  

The end result is that I have a AjaxAutoSavingSubmitLink (which extends
AjaxSubmitLink) with some supporting Javascript and it's working well with
TinyMCE, and SvgEditors. 

Thanks for the help!

Jake


jbrookover wrote:
> 
> Hey all,
> 
> I have a component, ResponseArea, that get's a
> HibernateObjectModel<Response>.  This ResponseArea then passes that same
> model down to it's sub components (ResponseEditor, ResponseViewer).  
> 
> ResponseEditor passes this model further down to a Form<Response>.  I have
> some jQuery script that does a timed autosave submit of this form.
> 
> When the form submits, I do this (pseudocode):
> 
> Response newR = new Response();
> newR.setData(Form.this.get("dataField").getDefaultModelObjectAsString();
> saveResponse(Form.this.getModelObject(), newR);
> 
> The last step of the saveResponse(Response oldR, Response newR) method
> does some processing, comparing the two versions of the response, and
> finally calls:  
> 
> ResponseEditor.this.setDefaultModelObjet(newR);
> 
> Now, I expect this effect to propagate up to the parent ResponseArea and
> down to the Form to be ready for the next AutoSave.  The problem is this:
> 
> At some point in the processing, the Form seems to clone the model and
> never gets the new object - it retains the original object as its model
> object.  So instead of this behavior
> 
> 1st Autosave Execute: saveResponse(original, respond1)
> 2nd Autosave Execute: saveResponse(respond1, respond2)
> 3rd Autosave Execute: saveResponse(respond2, respond3)
> 
> I get this:
> 
> 1st Autosave Execute: saveResponse(original, respond1)
> 2nd Autosave Execute: saveResponse(original, respond2)
> 3rd Autosave Execute: saveResponse(original, respond3)
> 
> Since my form would like to see progressive changes, this doesn't work.
> 
> Thoughts?
> 
> I sense IComponentInheritedModel is involved, but I'm surprised that this
> isn't a native behavior.  It also seems to work in every other case - so
> why not now?
> 
> Thanks!
> 
> Jake
> 
> 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Model-not-Updating-on-Multiple-Form-Submits-tp2272644p2286475.html
Sent from the Wicket - User 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


Re: Model not Updating on Multiple Form Submits

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Too many variables to debug without seeing the actual code.  The best thing
for you to do would be to create a quickstart so that we could try to run
it.  Of course, most people find their problem while creating the
quickstart.

On Tue, Jun 29, 2010 at 3:56 PM, jbrookover <jb...@cast.org> wrote:

>
> To clarify even further, I did try to hack it so I changed the model of the
> form directly (even though, I presume, it's all the same model propagated
> up
> and down the hierarchy).  That also did not work.  Nothing I've done will
> force the Form to take a new object before its next submission.
>
> Thanks again!
>
> Jake
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Model-not-Updating-on-Multiple-Form-Submits-tp2272644p2272646.html
> Sent from the Wicket - User 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
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: Model not Updating on Multiple Form Submits

Posted by jbrookover <jb...@cast.org>.
To clarify even further, I did try to hack it so I changed the model of the
form directly (even though, I presume, it's all the same model propagated up
and down the hierarchy).  That also did not work.  Nothing I've done will
force the Form to take a new object before its next submission.

Thanks again!

Jake
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Model-not-Updating-on-Multiple-Form-Submits-tp2272644p2272646.html
Sent from the Wicket - User 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