You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by nivs <sh...@gmail.com> on 2010/08/13 09:30:45 UTC

DropDownChoice does not push value into Model

Hi All,

http://apache-wicket.1842946.n4.nabble.com/file/n2323809/Code.txt 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
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: DropDownChoice does not push value into Model

Posted by Nivedan Nadaraj <sh...@gmail.com>.
Hi James

protected void doLookup(AjaxRequestTarget target, Study studyReference);

I really do not need this studyReference. That was just a test I wanted to
do. It is the study reference that is used to populate the dropdown. I
wanted to see if it gets changed with each submit. I noticed that it does
not change.

I do get the ModelObject -
   StudyContainer studyContainer  =  (StudyContainer)this.getModelObject();

So yeah it works with this change, using PropertyModel. Wanted to get your
feedback if I have used it correctly.
Cheers
Niv



On Tue, Aug 17, 2010 at 7:48 PM, James Carman <ja...@carmanconsulting.com>wrote:

> In your onSubmit() method, you're referring to the local variable
> "studyReference."  Why not try getting the model value while inside
> the method?
>
> On Tue, Aug 17, 2010 at 6:04 AM, nivs <sh...@gmail.com> wrote:
> >
> > Hi James
> >
> > Point(s) noted. I have got something going here and it is working but is
> > this what you meant? Please see attached code and do bear with my
> questions.
> >
> > The variable studyReference which is the one that is wrapped within a
> > PropertyModel, remains or maintains the same reference even if the object
> > model is changed. So that is the key I suppose not to change the study
> > reference bound to the DDC any time and we wrap this in a property model.
> >
> > Still have to get to grips with Models.
> >
> > Thanks for the help
> > Cheers
> > Niv
> >
> > /* Form that contains the dropdown other form fields*/
> > public class LookupForm extends Form{
> >
> >        private TextField<String> studyName;
> >        private TextField<String> chiefName;
> >        private AjaxButton lookupButton;
> >        private DropDownChoice<StudyStatus> studyStatusDpChoices;
> >
> >
> >
> >        public LookupForm(String id,Model<StudyContainer> model){
> >                super(id,model);
> >        }
> >        public void initForm(){
> >
> >                Model<StudyContainer> studyContainerModel =
> (Model)getModel();
> >
> >                //Create a propertyModel to bind the components of this
> form, the root which is StudyContainer
> >                PropertyModel<Study> pm = new
> PropertyModel<Study>(studyContainerModel,"study");
> >
> >                //Just to know what the initial study reference is
> >                final Study studyReference  = pm.getObject();
> >
> >                studyName = new TextField("studyName",new
> PropertyModel<String>(pm,"studyName"));//Create another new PropertyModel of
> type Study
> >                chiefName = new TextField("chiefName", new
> PropertyModel<String>(pm,"chiefName"));
> >
> >                lookupButton = new AjaxButton("search"){
> >                        @Override
> >                        protected void onSubmit(AjaxRequestTarget target,
> Form<?> form) {
> >                                Model<StudyContainer> iModel  =
> (Model)getModel();
> >                                doLookup(target,studyReference);
> >                        }
> >                };
> >
> >
> >                ChoiceRenderer defaultChoiceRenderer = new
> ChoiceRenderer("name", "studyStatusKey");
> >
> >                //Another PropertyModel for rendering the DropDowns and
> pass in the Property Model instance of type Study
> >                PropertyModel<Study> pmStudyStatus = new
> PropertyModel<Study>(pm,"studyStatus");
> >
> >                //Static list
> >                List<StudyStatus> studyStatusList = new
> ArrayList<StudyStatus>();
> >                StudyStatus ss = new StudyStatus();
> >                ss.setName("Active");
> >                ss.setStudyStatusKey(new Long("1"));
> >                studyStatusList.add(ss);
> >                ss = new StudyStatus();
> >                ss.setName("Inactive");
> >                ss.setStudyStatusKey(new Long("2"));
> >                studyStatusList.add(ss);
> >
> >                studyStatusDpChoices = new
> DropDownChoice("studyStatusDDC",pmStudyStatus,studyStatusList,defaultChoiceRenderer);
> >
> >                add(studyName);
> >                add(chiefName);
> >                add(studyStatusDpChoices);
> >                add(lookupButton);
> >        }
> >
> >        protected void doLookup(AjaxRequestTarget target, Study study){}
> >
> > }
> >
> >
> >
> > public class Lookup extends Panel{
> >
> >        Model<StudyContainer> studyContainerModel;
> >        public Lookup(String id) {
> >                super(id);
> >        }
> >        public void initialise(){
> >
> >                studyContainerModel = new Model<StudyContainer>( new
> StudyContainer());
> >
> >                LookupForm lookupForm = new LookupForm("lookupForm",
> studyContainerModel){
> >
> >                        protected void doLookup(AjaxRequestTarget target,
> Study studyReference){
> >
> >
> >                                StudyContainer studyContainer  =
>  (StudyContainer)this.getModelObject();
> >
> >                                //Get the currently populates study info
> >                                Study currentStudy =
> studyContainer.getStudy();
> >
> >
>  System.out.println(currentStudy.getChiefName());
> >
> >                                StudyStatus status =
> currentStudy.getStudyStatus();
> >                                System.out.println(status.getName());
> >
> >                                //Simulate a user's select operation and
> reset the study
> >                                StudyContainer newOne = new
> StudyContainer();
> >                                Study selectedStudy = new Study();
> >                                selectedStudy.setChiefName("Testing");
> >                                selectedStudy.setStudyName("Testing");
> >                                newOne.setStudy(selectedStudy);
> >                                this.setModelObject(newOne);//Set it with
> the new model object with the study that was selected
> >
> >                                //The studyReference instance always
> refers to the original study that was used to populate the drop down never
> changes
> >                                String studyRefDetails =
> studyReference.getStudyName() + " " +
> studyReference.getStudyStatus().getName();
> >
> >                                System.out.println("\n: 2:"+
> studyRefDetails);
> >                        }
> >
> >                };
> >                lookupForm.initForm();
> >                add(lookupForm);
> >        }
> >
> >
> > }
> >
> > public class StudyContainer implements Serializable{
> >
> >        private Study study;
> >        private List<Study> studyList;
> >
> >        /**
> >         * Constructor
> >         */
> >        public StudyContainer(){
> >                study = new Study();
> >                studyList = new ArrayList<Study>();
> >        }
> >
> >        //Accessor for study
> >        public Study getStudy() {
> >                return study;
> >        }
> >        public void setStudy(Study study) {
> >                this.study = study;
> >        }
> >
> >        //Accessor for study List
> >        public List<Study> getStudyList() {
> >                return studyList;
> >        }
> >        public void setStudyList(List<Study> studyList) {
> >                this.studyList = studyList;
> >        }
> >
> > }
> >
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2328046.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: DropDownChoice does not push value into Model

Posted by James Carman <ja...@carmanconsulting.com>.
In your onSubmit() method, you're referring to the local variable
"studyReference."  Why not try getting the model value while inside
the method?

On Tue, Aug 17, 2010 at 6:04 AM, nivs <sh...@gmail.com> wrote:
>
> Hi James
>
> Point(s) noted. I have got something going here and it is working but is
> this what you meant? Please see attached code and do bear with my questions.
>
> The variable studyReference which is the one that is wrapped within a
> PropertyModel, remains or maintains the same reference even if the object
> model is changed. So that is the key I suppose not to change the study
> reference bound to the DDC any time and we wrap this in a property model.
>
> Still have to get to grips with Models.
>
> Thanks for the help
> Cheers
> Niv
>
> /* Form that contains the dropdown other form fields*/
> public class LookupForm extends Form{
>
>        private TextField<String> studyName;
>        private TextField<String> chiefName;
>        private AjaxButton lookupButton;
>        private DropDownChoice<StudyStatus> studyStatusDpChoices;
>
>
>
>        public LookupForm(String id,Model<StudyContainer> model){
>                super(id,model);
>        }
>        public void initForm(){
>
>                Model<StudyContainer> studyContainerModel = (Model)getModel();
>
>                //Create a propertyModel to bind the components of this form, the root which is StudyContainer
>                PropertyModel<Study> pm = new PropertyModel<Study>(studyContainerModel,"study");
>
>                //Just to know what the initial study reference is
>                final Study studyReference  = pm.getObject();
>
>                studyName = new TextField("studyName",new PropertyModel<String>(pm,"studyName"));//Create another new PropertyModel of type Study
>                chiefName = new TextField("chiefName", new PropertyModel<String>(pm,"chiefName"));
>
>                lookupButton = new AjaxButton("search"){
>                        @Override
>                        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>                                Model<StudyContainer> iModel  = (Model)getModel();
>                                doLookup(target,studyReference);
>                        }
>                };
>
>
>                ChoiceRenderer defaultChoiceRenderer = new ChoiceRenderer("name", "studyStatusKey");
>
>                //Another PropertyModel for rendering the DropDowns and pass in the Property Model instance of type Study
>                PropertyModel<Study> pmStudyStatus = new PropertyModel<Study>(pm,"studyStatus");
>
>                //Static list
>                List<StudyStatus> studyStatusList = new ArrayList<StudyStatus>();
>                StudyStatus ss = new StudyStatus();
>                ss.setName("Active");
>                ss.setStudyStatusKey(new Long("1"));
>                studyStatusList.add(ss);
>                ss = new StudyStatus();
>                ss.setName("Inactive");
>                ss.setStudyStatusKey(new Long("2"));
>                studyStatusList.add(ss);
>
>                studyStatusDpChoices = new DropDownChoice("studyStatusDDC",pmStudyStatus,studyStatusList,defaultChoiceRenderer);
>
>                add(studyName);
>                add(chiefName);
>                add(studyStatusDpChoices);
>                add(lookupButton);
>        }
>
>        protected void doLookup(AjaxRequestTarget target, Study study){}
>
> }
>
>
>
> public class Lookup extends Panel{
>
>        Model<StudyContainer> studyContainerModel;
>        public Lookup(String id) {
>                super(id);
>        }
>        public void initialise(){
>
>                studyContainerModel = new Model<StudyContainer>( new StudyContainer());
>
>                LookupForm lookupForm = new LookupForm("lookupForm", studyContainerModel){
>
>                        protected void doLookup(AjaxRequestTarget target, Study studyReference){
>
>
>                                StudyContainer studyContainer  =  (StudyContainer)this.getModelObject();
>
>                                //Get the currently populates study info
>                                Study currentStudy = studyContainer.getStudy();
>
>                                System.out.println(currentStudy.getChiefName());
>
>                                StudyStatus status = currentStudy.getStudyStatus();
>                                System.out.println(status.getName());
>
>                                //Simulate a user's select operation and reset the study
>                                StudyContainer newOne = new StudyContainer();
>                                Study selectedStudy = new Study();
>                                selectedStudy.setChiefName("Testing");
>                                selectedStudy.setStudyName("Testing");
>                                newOne.setStudy(selectedStudy);
>                                this.setModelObject(newOne);//Set it with the new model object with the study that was selected
>
>                                //The studyReference instance always refers to the original study that was used to populate the drop down never changes
>                                String studyRefDetails = studyReference.getStudyName() + " " + studyReference.getStudyStatus().getName();
>
>                                System.out.println("\n: 2:"+ studyRefDetails);
>                        }
>
>                };
>                lookupForm.initForm();
>                add(lookupForm);
>        }
>
>
> }
>
> public class StudyContainer implements Serializable{
>
>        private Study study;
>        private List<Study> studyList;
>
>        /**
>         * Constructor
>         */
>        public StudyContainer(){
>                study = new Study();
>                studyList = new ArrayList<Study>();
>        }
>
>        //Accessor for study
>        public Study getStudy() {
>                return study;
>        }
>        public void setStudy(Study study) {
>                this.study = study;
>        }
>
>        //Accessor for study List
>        public List<Study> getStudyList() {
>                return studyList;
>        }
>        public void setStudyList(List<Study> studyList) {
>                this.studyList = studyList;
>        }
>
> }
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2328046.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: DropDownChoice does not push value into Model

Posted by nivs <sh...@gmail.com>.
Hi James

Point(s) noted. I have got something going here and it is working but is
this what you meant? Please see attached code and do bear with my questions.

The variable studyReference which is the one that is wrapped within a
PropertyModel, remains or maintains the same reference even if the object
model is changed. So that is the key I suppose not to change the study
reference bound to the DDC any time and we wrap this in a property model.

Still have to get to grips with Models.

Thanks for the help
Cheers
Niv

/* Form that contains the dropdown other form fields*/
public class LookupForm extends Form{

	private TextField<String> studyName;
	private TextField<String> chiefName;
	private AjaxButton lookupButton;
	private DropDownChoice<StudyStatus> studyStatusDpChoices;
	

	
	public LookupForm(String id,Model<StudyContainer> model){
		super(id,model);
	}
	public void initForm(){
		
		Model<StudyContainer> studyContainerModel = (Model)getModel();
		
		//Create a propertyModel to bind the components of this form, the root which is StudyContainer
		PropertyModel<Study> pm = new PropertyModel<Study>(studyContainerModel,"study");
		
		//Just to know what the initial study reference is
		final Study studyReference  = pm.getObject();
		
		studyName = new TextField("studyName",new PropertyModel<String>(pm,"studyName"));//Create another new PropertyModel of type Study
		chiefName = new TextField("chiefName", new PropertyModel<String>(pm,"chiefName"));

		lookupButton = new AjaxButton("search"){
			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
				Model<StudyContainer> iModel  = (Model)getModel();
				doLookup(target,studyReference);
			}
		};
		
		
		ChoiceRenderer defaultChoiceRenderer = new ChoiceRenderer("name", "studyStatusKey");
		
		//Another PropertyModel for rendering the DropDowns and pass in the Property Model instance of type Study
		PropertyModel<Study> pmStudyStatus = new PropertyModel<Study>(pm,"studyStatus");
		
		//Static list
		List<StudyStatus> studyStatusList = new ArrayList<StudyStatus>();
		StudyStatus ss = new StudyStatus();
		ss.setName("Active");
		ss.setStudyStatusKey(new Long("1"));
		studyStatusList.add(ss);
		ss = new StudyStatus();
		ss.setName("Inactive");
		ss.setStudyStatusKey(new Long("2"));
		studyStatusList.add(ss);
		
		studyStatusDpChoices = new DropDownChoice("studyStatusDDC",pmStudyStatus,studyStatusList,defaultChoiceRenderer);
		
		add(studyName);
		add(chiefName);
		add(studyStatusDpChoices);
		add(lookupButton);
	}
		
	protected void doLookup(AjaxRequestTarget target, Study study){}

}



public class Lookup extends Panel{

	Model<StudyContainer> studyContainerModel;
	public Lookup(String id) {
		super(id);
	}
	public void initialise(){
		
		studyContainerModel = new Model<StudyContainer>( new StudyContainer());
		
		LookupForm lookupForm = new LookupForm("lookupForm", studyContainerModel){
			
			protected void doLookup(AjaxRequestTarget target, Study studyReference){
				
				
				StudyContainer studyContainer  =  (StudyContainer)this.getModelObject();
				
				//Get the currently populates study info
				Study currentStudy = studyContainer.getStudy();
				
				System.out.println(currentStudy.getChiefName());
				
				StudyStatus status = currentStudy.getStudyStatus();
				System.out.println(status.getName());
				
				//Simulate a user's select operation and reset the study
				StudyContainer newOne = new StudyContainer();
				Study selectedStudy = new Study();
				selectedStudy.setChiefName("Testing");
				selectedStudy.setStudyName("Testing");
				newOne.setStudy(selectedStudy);
				this.setModelObject(newOne);//Set it with the new model object with the study that was selected
				
				//The studyReference instance always refers to the original study that was used to populate the drop down never changes
				String studyRefDetails = studyReference.getStudyName() + " " + studyReference.getStudyStatus().getName();
				
				System.out.println("\n: 2:"+ studyRefDetails);
			}
			
		};
		lookupForm.initForm();
		add(lookupForm);
	}
	
	
}

public class StudyContainer implements Serializable{
	
	private Study study;
	private List<Study> studyList;
	
	/**
	 * Constructor
	 */
	public StudyContainer(){
		study = new Study();
		studyList = new ArrayList<Study>();
	}
	
	//Accessor for study
	public Study getStudy() {
		return study;
	}
	public void setStudy(Study study) {
		this.study = study;
	}
	
	//Accessor for study List
	public List<Study> getStudyList() {
		return studyList;
	}
	public void setStudyList(List<Study> studyList) {
		this.studyList = studyList;
	}
	
}


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2328046.html
Sent from the Wicket - User mailing list archive at Nabble.com.

Re: DropDownChoice does not push value into Model

Posted by James Carman <ja...@carmanconsulting.com>.
On Mon, Aug 16, 2010 at 5:42 AM, nivs <sh...@gmail.com> wrote:
> 2. firstName = new TextField("studyName",new
> PropertyModel<Study>(pModel.getObject().getStudyName(),"studyName"));
>

It should be:

new PropertyModel<String>(pModel, "studyName").

The first argument to PropertyModel's constructor is the "root" for
the property expression.  If it's a model, Wicket knows to get the
model's object and apply the property expression to that.  What you're
doing is telling Wicket to set up a property model where a String is
the "root" and the propertyExpression is "studyName."  There is no
"studyName" property on the String class, so that won't work.  Also,
your expression and your model type (<Study>) don't match here.
You're telling it to traverse to the study name (which is a String I
assume) and you're saying the model is of type Study.  The property
navigation you're trying to do won't work either.  All that does is
traverse the property before the method is called and passes its value
in to the method as a parameter.  It's not "recording" anything.  I
would just go with the simplest solution for now to get you going.
Don't try to get too fancy too fast.  Walk before you run.

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


Re: DropDownChoice does not push value into Model

Posted by nivs <sh...@gmail.com>.
James

Could you please clarify this for me, I noticed is that with PropertyModel
usage in the above context.

I have to define one(PropertyModel instance) for each of the form component
explicitly,  like so

1. Model<StudyModel> studyModel = new Model<StudyModel>(new
StudyModel());/Top level Model

In the Form:
I associate the studyModel above in the constructor and 

Model<StudyModel> pModel = (Model)getModel();

2. firstName = new TextField("studyName",new
PropertyModel<Study>(pModel.getObject().getStudyName(),"studyName")); 

// I am manually telling it to navigate to a property ..thought it will be
nice if its automatic based on the expression

I am unable to create a single instance like 

PropertyModel<Study> propertyModel = new PropertyModel<Study>(studyModel,
"study"); 
And then use propertyModel instance for each component. 

Am I missing something here? 

Thanks again
Niv




-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2326600.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: DropDownChoice does not push value into Model

Posted by nivs <sh...@gmail.com>.
James,

Thanks for that. I am trying to implement what you have mentioned using
Model and PropertyModel. Let me get back to you after I have done this bit.
Appreciate your time and advice.

Thanks
Niv
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-does-not-push-value-into-Model-tp2323809p2326586.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: DropDownChoice does not push value into Model

Posted by James Carman <ja...@carmanconsulting.com>.
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 <sh...@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-32022@n4.nabble.com<ml...@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: DropDownChoice does not push value into Model

Posted by nivs <sh...@gmail.com>.
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-32022@n4.nabble.com<ml...@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.

Re: DropDownChoice does not push value into Model

Posted by James Carman <ja...@carmanconsulting.com>.
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 <sh...@gmail.com> wrote:
>
> Hi All,
>
> http://apache-wicket.1842946.n4.nabble.com/file/n2323809/Code.txt 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
> 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
>
>

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