Hi,

if I understand correctly, the page variable and the panel model should
always point to the same thing. 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. 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. This is what we do in a similar case, we
got one listChoice that controls the whole page and so a lot of components.

hope that helps,
Martin


Fabio Fioretti wrote:
> 
> Hi all,
> 
> thanks for your time and for keeping up this precious users' list.
> 
> I have a page with a page-global "currentRecommendation" variable. The
> instance of this variable is updated by selecting one of the entries
> of a ListChoice; basically, the ListChoice deals with a list of
> "recommendations" instances and sets "currentRecommendation" to the
> one selected by the user.
> 
> When a recommendation is selected, its data are loaded and displayed
> in a "recommendationForm" (contained in the same page) defined like
> this:
> 
> recommendationForm = new Form("recommendationForm");
> 
> The form contains a custom recommendationPanel which is linked to the
> "currentRecommendation" instance by a CompoundPropertyModel built on
> an AbstractReadOnlyModel, just like this:
> 
> IModel recommendationModel = new AbstractReadOnlyModel() {
>     @Override
>     public Object getObject(Component component) {
>         return currentRecommendation;
>     }
> };
> 
> recommendationPanel = new CustomPanel("recommendationPanel", new
> CompoundPropertyModel(recommendationModel));
> 
> The problem is that when the form is submitted and validation *fails*,
> the CompoundPropertyModel of the "recommendationPanel" seems to
> disconnect from the "currentRecommendation" instance, because clicking
> on a different entry of the ListChoice mentioned above still refreshes
> the form but doesn't update the data contained in it anymore.
> In other words, the underlying "currentRecommendation" instance keeps
> changing correctly on ListChoice selection change (and the
> AbstractReadOnlyModel correctly picks up the selected instance), but
> the form (i.e. the panel contained in it) keeps displaying the
> instance that failed validation and doesn't show the newly selected
> recommendation instance anymore.
> The whole thing happens only when form validation fails.
> 
> What am I missing?
> 
> 
> 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#a13021884
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