You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Edgar Merino <do...@gmail.com> on 2013/08/29 21:33:52 UTC

Custom FormComponent and model update

Hello, I'm having a problem with a FormComponent I'm implementing, I'm 
manually calling FormComponent#validate(), FormComponent#valid() and 
FormComponent#updateModel() inside MyBehavior#onRequest() since the 
object is not attached to a Form, I'm using a custom Behavior 
(MyBehavior, which extends AbstractAjaxBehavior, I don't need any of the 
functionality provided by AjaxDefaultAbstractBehavior), the model 
changes for this request but every time a new request is handled I see 
the component still uses the old model that was supposed to be replaced 
in the previous request.

By debugging the application I can see that everytime a new request is 
handled, the FormComponent will look for the model in the Component#data 
attribute array, which holds the initially set IModel and is never 
changed... I don't have a clue on how to change this, I bet this is the 
key to solve this, does anyone have a clue on how to do this?


Thanks in advance,
Edgar Merino.

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


Re: Custom FormComponent and model update

Posted by Edgar Merino <do...@gmail.com>.
I managed to got it working, but in the end I gave up trying to 
integrate my js library and did it using pure wicket, the end result was 
a lot nicer and much easier to maintain.

Thank you for your answer.

On 30/08/13 03:09, Martin Grigorov wrote:
> Hi,
>
> There is a special handling for Ajax requests - the page is marked as dirty
> and stored, but its pageId is not incremented. So the new state completely
> overrides the old in the store.
>
> By "the object is not attached to a Form" I understand that you try to
> update the model of a Component which is not in the page's component tree.
> Since this component is not visible/reachable by the page then its stateful
> behavior is not reachable too. So at the end the page may be still
> stateless and thus never stored.
> Try with: page.setStatelessHint(false)
>
>
> On Fri, Aug 30, 2013 at 8:22 AM, Edgar Merino <do...@gmail.com> wrote:
>
>> I'm completely lost here, I've been debugging AjaxCheckBox just to see how
>> it manages to not make the page dirty, but something strange happens when
>> calling Component#dirty(boolean) on Component#modelChanging(), I set a
>> breakpoint in the beginning of the Component#dirty(boolean) method but it
>> never gets there... although it is being called by Component#dirty().
>> However, when using my custom FormComponent, it will always mark the page
>> as dirty (it will enter the method) making my changes to be visible only on
>> the next version of the page, which is not what I want, any idea how to
>> solve this?
>>
>>
>>
>>
>> On 29/08/13 23:05, Edgar Merino wrote:
>>
>>> Found the problem, it has to do with versioning of pages... my callback
>>> is not changing the version number in the URL so everytime I refresh the
>>> web page I'm retrieving the older version of the page. I'm gonna have to
>>> work with AjaxRequestTarget in order to avoid this I guess.
>>>
>>>
>>> On 29/08/13 22:52, Edgar Merino wrote:
>>>
>>>> I have track this down to the Component#modelChanging() method, it seems
>>>> that the actual modified page is not being stored in the session (perhaps
>>>> it has something to do with dirty pages?). I'm a bit lost here, any clue
>>>> would be appreciated.
>>>>
>>>> Thank you.
>>>>
>>>> On 29/08/13 14:33, Edgar Merino wrote:
>>>>
>>>>> Hello, I'm having a problem with a FormComponent I'm implementing, I'm
>>>>> manually calling FormComponent#validate(), FormComponent#valid() and
>>>>> FormComponent#updateModel() inside MyBehavior#onRequest() since the object
>>>>> is not attached to a Form, I'm using a custom Behavior (MyBehavior, which
>>>>> extends AbstractAjaxBehavior, I don't need any of the functionality
>>>>> provided by AjaxDefaultAbstractBehavior), the model changes for this
>>>>> request but every time a new request is handled I see the component still
>>>>> uses the old model that was supposed to be replaced in the previous request.
>>>>>
>>>>> By debugging the application I can see that everytime a new request is
>>>>> handled, the FormComponent will look for the model in the Component#data
>>>>> attribute array, which holds the initially set IModel and is never
>>>>> changed... I don't have a clue on how to change this, I bet this is the key
>>>>> to solve this, does anyone have a clue on how to do this?
>>>>>
>>>>>
>>>>> Thanks in advance,
>>>>> Edgar Merino.
>>>>>
>>>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


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


Re: Custom FormComponent and model update

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

There is a special handling for Ajax requests - the page is marked as dirty
and stored, but its pageId is not incremented. So the new state completely
overrides the old in the store.

By "the object is not attached to a Form" I understand that you try to
update the model of a Component which is not in the page's component tree.
Since this component is not visible/reachable by the page then its stateful
behavior is not reachable too. So at the end the page may be still
stateless and thus never stored.
Try with: page.setStatelessHint(false)


On Fri, Aug 30, 2013 at 8:22 AM, Edgar Merino <do...@gmail.com> wrote:

> I'm completely lost here, I've been debugging AjaxCheckBox just to see how
> it manages to not make the page dirty, but something strange happens when
> calling Component#dirty(boolean) on Component#modelChanging(), I set a
> breakpoint in the beginning of the Component#dirty(boolean) method but it
> never gets there... although it is being called by Component#dirty().
> However, when using my custom FormComponent, it will always mark the page
> as dirty (it will enter the method) making my changes to be visible only on
> the next version of the page, which is not what I want, any idea how to
> solve this?
>
>
>
>
> On 29/08/13 23:05, Edgar Merino wrote:
>
>> Found the problem, it has to do with versioning of pages... my callback
>> is not changing the version number in the URL so everytime I refresh the
>> web page I'm retrieving the older version of the page. I'm gonna have to
>> work with AjaxRequestTarget in order to avoid this I guess.
>>
>>
>> On 29/08/13 22:52, Edgar Merino wrote:
>>
>>> I have track this down to the Component#modelChanging() method, it seems
>>> that the actual modified page is not being stored in the session (perhaps
>>> it has something to do with dirty pages?). I'm a bit lost here, any clue
>>> would be appreciated.
>>>
>>> Thank you.
>>>
>>> On 29/08/13 14:33, Edgar Merino wrote:
>>>
>>>> Hello, I'm having a problem with a FormComponent I'm implementing, I'm
>>>> manually calling FormComponent#validate(), FormComponent#valid() and
>>>> FormComponent#updateModel() inside MyBehavior#onRequest() since the object
>>>> is not attached to a Form, I'm using a custom Behavior (MyBehavior, which
>>>> extends AbstractAjaxBehavior, I don't need any of the functionality
>>>> provided by AjaxDefaultAbstractBehavior), the model changes for this
>>>> request but every time a new request is handled I see the component still
>>>> uses the old model that was supposed to be replaced in the previous request.
>>>>
>>>> By debugging the application I can see that everytime a new request is
>>>> handled, the FormComponent will look for the model in the Component#data
>>>> attribute array, which holds the initially set IModel and is never
>>>> changed... I don't have a clue on how to change this, I bet this is the key
>>>> to solve this, does anyone have a clue on how to do this?
>>>>
>>>>
>>>> Thanks in advance,
>>>> Edgar Merino.
>>>>
>>>
>>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Custom FormComponent and model update

Posted by Edgar Merino <do...@gmail.com>.
I'm completely lost here, I've been debugging AjaxCheckBox just to see 
how it manages to not make the page dirty, but something strange happens 
when calling Component#dirty(boolean) on Component#modelChanging(), I 
set a breakpoint in the beginning of the Component#dirty(boolean) method 
but it never gets there... although it is being called by 
Component#dirty(). However, when using my custom FormComponent, it will 
always mark the page as dirty (it will enter the method) making my 
changes to be visible only on the next version of the page, which is not 
what I want, any idea how to solve this?



On 29/08/13 23:05, Edgar Merino wrote:
> Found the problem, it has to do with versioning of pages... my 
> callback is not changing the version number in the URL so everytime I 
> refresh the web page I'm retrieving the older version of the page. I'm 
> gonna have to work with AjaxRequestTarget in order to avoid this I guess.
>
>
> On 29/08/13 22:52, Edgar Merino wrote:
>> I have track this down to the Component#modelChanging() method, it 
>> seems that the actual modified page is not being stored in the 
>> session (perhaps it has something to do with dirty pages?). I'm a bit 
>> lost here, any clue would be appreciated.
>>
>> Thank you.
>>
>> On 29/08/13 14:33, Edgar Merino wrote:
>>> Hello, I'm having a problem with a FormComponent I'm implementing, 
>>> I'm manually calling FormComponent#validate(), FormComponent#valid() 
>>> and FormComponent#updateModel() inside MyBehavior#onRequest() since 
>>> the object is not attached to a Form, I'm using a custom Behavior 
>>> (MyBehavior, which extends AbstractAjaxBehavior, I don't need any of 
>>> the functionality provided by AjaxDefaultAbstractBehavior), the 
>>> model changes for this request but every time a new request is 
>>> handled I see the component still uses the old model that was 
>>> supposed to be replaced in the previous request.
>>>
>>> By debugging the application I can see that everytime a new request 
>>> is handled, the FormComponent will look for the model in the 
>>> Component#data attribute array, which holds the initially set IModel 
>>> and is never changed... I don't have a clue on how to change this, I 
>>> bet this is the key to solve this, does anyone have a clue on how to 
>>> do this?
>>>
>>>
>>> Thanks in advance,
>>> Edgar Merino.
>>
>


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


Re: Custom FormComponent and model update

Posted by Edgar Merino <do...@gmail.com>.
Found the problem, it has to do with versioning of pages... my callback 
is not changing the version number in the URL so everytime I refresh the 
web page I'm retrieving the older version of the page. I'm gonna have to 
work with AjaxRequestTarget in order to avoid this I guess.


On 29/08/13 22:52, Edgar Merino wrote:
> I have track this down to the Component#modelChanging() method, it 
> seems that the actual modified page is not being stored in the session 
> (perhaps it has something to do with dirty pages?). I'm a bit lost 
> here, any clue would be appreciated.
>
> Thank you.
>
> On 29/08/13 14:33, Edgar Merino wrote:
>> Hello, I'm having a problem with a FormComponent I'm implementing, 
>> I'm manually calling FormComponent#validate(), FormComponent#valid() 
>> and FormComponent#updateModel() inside MyBehavior#onRequest() since 
>> the object is not attached to a Form, I'm using a custom Behavior 
>> (MyBehavior, which extends AbstractAjaxBehavior, I don't need any of 
>> the functionality provided by AjaxDefaultAbstractBehavior), the model 
>> changes for this request but every time a new request is handled I 
>> see the component still uses the old model that was supposed to be 
>> replaced in the previous request.
>>
>> By debugging the application I can see that everytime a new request 
>> is handled, the FormComponent will look for the model in the 
>> Component#data attribute array, which holds the initially set IModel 
>> and is never changed... I don't have a clue on how to change this, I 
>> bet this is the key to solve this, does anyone have a clue on how to 
>> do this?
>>
>>
>> Thanks in advance,
>> Edgar Merino.
>


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


Re: Custom FormComponent and model update

Posted by Edgar Merino <do...@gmail.com>.
I have track this down to the Component#modelChanging() method, it seems 
that the actual modified page is not being stored in the session 
(perhaps it has something to do with dirty pages?). I'm a bit lost here, 
any clue would be appreciated.

Thank you.

On 29/08/13 14:33, Edgar Merino wrote:
> Hello, I'm having a problem with a FormComponent I'm implementing, I'm 
> manually calling FormComponent#validate(), FormComponent#valid() and 
> FormComponent#updateModel() inside MyBehavior#onRequest() since the 
> object is not attached to a Form, I'm using a custom Behavior 
> (MyBehavior, which extends AbstractAjaxBehavior, I don't need any of 
> the functionality provided by AjaxDefaultAbstractBehavior), the model 
> changes for this request but every time a new request is handled I see 
> the component still uses the old model that was supposed to be 
> replaced in the previous request.
>
> By debugging the application I can see that everytime a new request is 
> handled, the FormComponent will look for the model in the 
> Component#data attribute array, which holds the initially set IModel 
> and is never changed... I don't have a clue on how to change this, I 
> bet this is the key to solve this, does anyone have a clue on how to 
> do this?
>
>
> Thanks in advance,
> Edgar Merino.


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