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 <shravann...@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-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >