Ok, now I undestand better. So if the model of your page is complex, just put
the complex data in a custom model object and then use page.setModel(new
Model(complexObject)). Just move the get/set of your variable into the model
object.

In the form on submit then do

getPage().getModel().getObject().setCurrentRecommendation(selectedValue).

And the panel would be 

new CustomPanel("customPanel", new PropertyModel(getPage().getModel(),
"currentRecommendation");

As for refreshing, just replace 

setResponsePage(getPage())

with 

ajaxRequestTarget.addComponent(customPanel);

or whatever you'd like to be updated.

The thing is: it's always better to rely on wicket for state handling and
variable updating. So if two components refer to the same thing, make sure
your model object is the same for both (or a property of the model object).
This keeps your data where it belongs (to the model of MVC) and frees you
from the hassle to deal with update events.

As a last resort, you could put the currentRecommendation to the session,
the brutal php approach ;)

Another thought... The form works until the first time validation failes.
Check if subsequents submits go through onSubmit(). 

bw,
Martin


Fabio Fioretti wrote:
> 
> On 10/3/07, Martin-2 <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
> 
> Hi, thanks for the quick reply.
> 
>> if I understand correctly, the page variable and the panel model should
>> always point to the same thing.
> 
> Right.
> 
>> I suggest you give your page a model with
>> currentRecommendation as model object. Then construct your panel with the
>> same model instance as the page (or wrap it with an IChainingModel) and
>> get
>> rid of the page wide variable.
> 
> I can't do that because my page is rather complex and it deals with at
> least two different kinds of objects. That's why I choose to have the
> currentRecommendation page variable instead, and a panel inside the
> related form that deals with the variable through the
> CompoundPropertyModel.
> 
>> The form's onSubmit() would be like:
>>
>> selectedValue = obtainSelectedValue();
>> getPage().getModel().setObject(selectedValue);
>> setResponsePage(getPage());
>>
>> so setting the page's model object to the choice the user selected, and
>> only
>> setting it if validation succeeds.
> 
> I don't think this could solve my problem because:
> 1) I don't want the whole page to be refreshed or reloaded but only
> the panel that deals with currentRecommendation;
> 2) more important, I don't want the panel to be refreshed only if
> validation succeeds; I want it to always reflect user's selection from
> the ListChoice, i.e. the currentRecommendation which is the model
> object of the panel.
> 
> The problem here is that, when form validation fails, the panel (which
> is contained in the form) stops responding to user's selections on the
> ListChoice as if its model loses the pointer to currentRecommendation.
> 
> I hope I've been clear enough, 'cause it's not so easy to explain...
> 
> 
> Thanks a lot for your help!
> 
> Fabio Fioretti - WindoM
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-stops-working-when-form-validation-fails.-tf4562483.html#a13023833
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to