Why are you using CPMs and PropertyModels together?  I would go one
way or the other.  In your case, since you're just starting out it
seems, I'd just use a regular model for the main object and use
explicit property models to bind its properties to your components.
The CPM is just too "magicy" and it can get confusing for beginners.
So what you want is:

Model<StudyModel> studyModel = new Model<StudyModel>(new StudyModel());

PropertyModel<Study> propertyModel = new
PropertyModel<Study>(studyModel, "study");

See how I use the "studyModel" as the "root" of my PropertyModel
rather than the StudyModel object contained in the studyModel itself?
That's perfectly okay.  What you're telling the PropertyModel is "go
to this model and ask for its object and then ask for its 'study'
property."  So, when you change the object that the studyModel points
to, the propertyModel can still get to it.  Does that make sense?
With this approach, you can feel free to do setModelObject(new
StudyModel()) and it will work.

On Fri, Aug 13, 2010 at 9:14 AM, nivs <shravann...@gmail.com> wrote:
>
> James
>
> Thanks for pointing it out. Later in the code I have added, so the study
> object/instance in the initial model should be in synch right? Correct me if
> I am wrong.  Let me also think about this point u made. But yeah do let me
> know if i have made a mistake.
>
> cpm = (CompoundPropertyModel<StudyModel>)this.getModel();////reset the
> original one
> Cheers
>
>
>
> On Fri, Aug 13, 2010 at 7:49 PM, James Carman [via Apache Wicket] <
> ml-node+2324076-505065694-32...@n4.nabble.com<ml-node%2b2324076-505065694-32...@n4.nabble.com>
>> wrote:
>
>> Your DDC is bound to the original StudyModel's study with the lines:
>>
>> PropertyModel propertyModel = new
>> PropertyModel(studyModel.getStudy(),Constants.STUDY_STATUS);
>> studyStatusDpChoices = new
>> DropDownChoice(Constants.STUDY_DROP_DOWN_CHOICE,propertyModel,studyStatusList,defaultChoiceRenderer);
>>
>>
>> Then, you're replacing the StudyModel with this line:
>>
>> this.setModelObject(new StudyModel());
>>
>> Thus, they get out of synch.
>>
>> On Fri, Aug 13, 2010 at 3:30 AM, nivs <[hidden 
>> email]<http://user/SendEmail.jtp?type=node&node=2324076&i=0>>
>> wrote:
>>
>> >
>> > Hi All,
>> >
>> > http://apache-wicket.1842946.n4.nabble.com/file/n2323809/Code.txt<http://apache-wicket.1842946.n4.nabble.com/file/n2323809/Code.txt?by-user=t>
>> >  Code.txt
>>
>> >
>> > I have a drop down choice control on the search panel and its selected
>> > choices are pushed to the model only once or the first time.
>> >
>> > Please have a look at the attached code:
>> >
>> > As part of this code, I noticed that when I uncomment  the following
>> line,
>> > the drop down choice works every time.(as it is supposed to)
>> >
>> > public void initialise(String id){
>> > //cpm.getObject().setStudy(searchCriteria);///Set the search criteria
>> object
>> > back in order for status to be filled in the next submit/search
>> > }
>> > However, this will not resolve my issue, because if I refreshed the study
>> in
>> > the model when the details page is loaded, the problem re-occurs.
>> >
>> > Not sure why this is hapenning, I tried to debug as much as I can, all i
>> can
>> > get to is, when i re-set the model's study instance after the search
>> results
>> > have arrived , then it works. If I do not, then it fails to capture the
>> > value from DDC.
>> >
>> > Thank you again
>> >
>> > Cheers
>> > Niv
>> >
>> >
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2323809.html<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2323809.html?by-user=t>
>> > Sent from the Wicket - User mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden 
>> > email]<http://user/SendEmail.jtp?type=node&node=2324076&i=1>
>> > For additional commands, e-mail: [hidden 
>> > email]<http://user/SendEmail.jtp?type=node&node=2324076&i=2>
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden 
>> email]<http://user/SendEmail.jtp?type=node&node=2324076&i=3>
>> For additional commands, e-mail: [hidden 
>> email]<http://user/SendEmail.jtp?type=node&node=2324076&i=4>
>>
>>
>>
>> ------------------------------
>>  View message @
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2324076.html
>> To unsubscribe from DropDownChoice does not push value into Model, click
>> here<http://apache-wicket.1842946.n4.nabble.com/template/NodeServlet.jtp?tpl=unsubscribe_by_code&node=2323809&code=c2hyYXZhbm5pdmVAZ21haWwuY29tfDIzMjM4MDl8LTkwOTU2NzkzNA==>.
>>
>>
>>
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2324176.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>

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

Reply via email to