You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@carlsoncentral.com> on 2009/05/12 02:48:37 UTC
TextField in ListView
I have a ListView that contains a TextField and Checkbox. The model is
properly populating the components in populateItem(), however
onSubmit() in not seeing changes. Do I have to do anything special to
make changes to FormComponents in a ListView make it back into the Model?
add(new ListView("emails", new PropertyModel(model,
"personalContactInfo.email")) {
protected void populateItem(ListItem item) {
Email email = (Email) item.getModel().getObject();
item.add(new TextField("email", new PropertyModel(email, "address")));
item.add(new CheckBox("primary", new PropertyModel(email,
"isPrimary")));
}
});
model is LoadableDetachableModel.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: TextField in ListView
Posted by Oblivian <ch...@carlsoncentral.com>.
Also do you have any idea why my "language" ListMultipleChoice is not
defaulting to the selected values.
languages is List<Language>
basicDemographicInfo.language is also List<Language>
Thanks again.
igor.vaynberg wrote:
>
> you need to chan your models
>
> IModel email = item.getModel();
> item.add(new TextField("email", new PropertyModel(email, "address")));
> item.add(new CheckBox("primary", new PropertyModel(email,
> "isPrimary")));
>
> also if you use an LDM for the list you are most likely better off
> using dataview
>
> -igor
>
> On Mon, May 11, 2009 at 5:48 PM, Chris <ch...@carlsoncentral.com> wrote:
>> I have a ListView that contains a TextField and Checkbox. The model is
>> properly populating the components in populateItem(), however onSubmit()
>> in
>> not seeing changes. Do I have to do anything special to make changes to
>> FormComponents in a ListView make it back into the Model?
>>
>> add(new ListView("emails", new PropertyModel(model,
>> "personalContactInfo.email")) {
>> protected void populateItem(ListItem item) {
>> Email email = (Email) item.getModel().getObject();
>> item.add(new TextField("email", new PropertyModel(email, "address")));
>> item.add(new CheckBox("primary", new PropertyModel(email,
>> "isPrimary")));
>> }
>> });
>> model is LoadableDetachableModel.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
--
View this message in context: http://www.nabble.com/TextField-in-ListView-tp23494369p23494845.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: TextField in ListView
Posted by Oblivian <ch...@carlsoncentral.com>.
Such a simple fix. Thanks, it works!
igor.vaynberg wrote:
>
> you need to chan your models
>
> IModel email = item.getModel();
> item.add(new TextField("email", new PropertyModel(email, "address")));
> item.add(new CheckBox("primary", new PropertyModel(email,
> "isPrimary")));
>
> also if you use an LDM for the list you are most likely better off
> using dataview
>
> -igor
>
> On Mon, May 11, 2009 at 5:48 PM, Chris <ch...@carlsoncentral.com> wrote:
>> I have a ListView that contains a TextField and Checkbox. The model is
>> properly populating the components in populateItem(), however onSubmit()
>> in
>> not seeing changes. Do I have to do anything special to make changes to
>> FormComponents in a ListView make it back into the Model?
>>
>> add(new ListView("emails", new PropertyModel(model,
>> "personalContactInfo.email")) {
>> protected void populateItem(ListItem item) {
>> Email email = (Email) item.getModel().getObject();
>> item.add(new TextField("email", new PropertyModel(email, "address")));
>> item.add(new CheckBox("primary", new PropertyModel(email,
>> "isPrimary")));
>> }
>> });
>> model is LoadableDetachableModel.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
--
View this message in context: http://www.nabble.com/TextField-in-ListView-tp23494369p23494788.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: TextField in ListView
Posted by Igor Vaynberg <ig...@gmail.com>.
you need to chan your models
IModel<Email> email = item.getModel();
item.add(new TextField("email", new PropertyModel(email, "address")));
item.add(new CheckBox("primary", new PropertyModel(email, "isPrimary")));
also if you use an LDM for the list you are most likely better off
using dataview
-igor
On Mon, May 11, 2009 at 5:48 PM, Chris <ch...@carlsoncentral.com> wrote:
> I have a ListView that contains a TextField and Checkbox. The model is
> properly populating the components in populateItem(), however onSubmit() in
> not seeing changes. Do I have to do anything special to make changes to
> FormComponents in a ListView make it back into the Model?
>
> add(new ListView("emails", new PropertyModel(model,
> "personalContactInfo.email")) {
> protected void populateItem(ListItem item) {
> Email email = (Email) item.getModel().getObject();
> item.add(new TextField("email", new PropertyModel(email, "address")));
> item.add(new CheckBox("primary", new PropertyModel(email, "isPrimary")));
> }
> });
> model is LoadableDetachableModel.
>
>
>
>
> ---------------------------------------------------------------------
> 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
Re: TextField in ListView
Posted by Oblivian <ch...@carlsoncentral.com>.
public class BasicInfoForm extends Form {
private static final Log log = LogFactory.getLog(BasicInfoForm.class);
@SpringBean(name = "spinnDao")
private ISpinnDao spinnDao;
@SpringBean(name = "phrInfoDao")
private IPhrInfoDao phrInfoDao;
private LinkedHashMap<String, String> genders;
private LinkedHashMap<String, String> countries;
private static List<String> titles = Arrays.asList(new String[] { "Mr.",
"Mrs", "Ms." });
public BasicInfoForm(String id, IModel model) {
super(id, model);
/* Maps for DropDownChoice Lookup */
try {
countries = spinnDao.getCountries();
} catch (DaoException e) {
log.error(e, e.getCause());
error("Error Retreiving Countries.");
}
try {
genders = spinnDao.getGenders();
} catch (DaoException e) {
log.error(e, e.getCause());
error("Error Retreiving Genders.");
}
/* Models for DropDownChoice */
IModel bloodtypes = new LoadableDetachableModel() {
public Object load() {
List<String> model = new ArrayList();
try {
model = spinnDao.getBloodtypes();
} catch (DaoException e) {
log.error(e, e.getCause());
error("Error Retreiving Blood Types.");
}
return model;
}
};
IModel states = new LoadableDetachableModel() {
public Object load() {
List<String> model = new ArrayList();
try {
model = spinnDao.getStates();
} catch (DaoException e) {
log.error(e, e.getCause());
error("Error Retreiving States.");
}
return model;
}
};
IModel religions = new LoadableDetachableModel() {
public Object load() {
List<String> model = new ArrayList();
try {
model = spinnDao.getReligions();
} catch (DaoException e) {
log.error(e, e.getCause());
error("Error Retreiving Religions.");
}
return model;
}
};
IModel languages = new LoadableDetachableModel() {
public Object load() {
List<Language> model = new ArrayList<Language>();
try {
model = spinnDao.getSpokenLanguages();
} catch (DaoException e) {
log.error(e, e.getCause());
error("Error Retreiving Ethnicitiess.");
}
return model;
}
};
IModel ethnicities = new LoadableDetachableModel() {
public Object load() {
List<String> model = new ArrayList();
try {
model = spinnDao.getEthnicities();
} catch (DaoException e) {
log.error(e, e.getCause());
error("Error Retreiving Ethnicitiess.");
}
return model;
}
};
IModel countryChoices = new LoadableDetachableModel() {
public Object load() {
List<String> countryKeys = new ArrayList();
Set<String> keys = countries.keySet();
for (String key : keys) {
countryKeys.add(key);
}
return countryKeys;
}
};
IModel genderChoices = new LoadableDetachableModel() {
public Object load() {
List<String> genderKeys = new ArrayList();
Set<String> keys = genders.keySet();
for (String key : keys) {
genderKeys.add(key);
}
return genderKeys;
}
};
add(new DropDownChoice("title", new PropertyModel(model,
"personalDemographicInfo.title"), titles));
add(new TextField("suffix", new PropertyModel(model,
"personalDemographicInfo.suffix")));
add(new TextField("firstname", new PropertyModel(model,
"personalDemographicInfo.firstName")));
add(new TextField("lastname", new PropertyModel(model,
"personalDemographicInfo.lastName")));
add(new DropDownChoice("ethnicity", new PropertyModel(model,
"personalDemographicInfo.ethnicityAsString"), ethnicities));
add(new TextField("organdonor", new PropertyModel(model,
"personalDemographicInfo.organDonor")));
add(new TextField("ssn", new PropertyModel(model,
"personalDemographicInfo.ssn")));
add(new TextField("middlename", new PropertyModel(model,
"personalDemographicInfo.middleName")));
add(new TextField("birthdate", new PropertyModel(model,
"personalDemographicInfo.birthdateAsString")).add(new DatePicker()));
add(new DropDownChoice("religion", new PropertyModel(model,
"personalDemographicInfo.religionAsString"), religions));
add(new DropDownChoice("bloodtype", new PropertyModel(model,
"personalDemographicInfo.bloodTypeAsString"), bloodtypes));
add(new TextField("city", new PropertyModel(model,
"basicDemographicInfo.city")));
add(new DropDownChoice("state", new PropertyModel(model,
"basicDemographicInfo.state"), states));
add(new TextField("postcode", new PropertyModel(model,
"basicDemographicInfo.postcode")));
add(new TextField("newEmail", new PropertyModel(model, "newEmail")));
add(new CheckBox("newEmailPrimary", new PropertyModel(model,
"newEmailPrimary")));
add(new TextField("newPhone", new PropertyModel(model, "newPhone")));
add(new CheckBox("newPhonePrimary", new PropertyModel(model,
"newPhonePrimary")));
add(new ListMultipleChoice("language", new PropertyModel(model,
"basicDemographicInfo.language"), languages, new ChoiceRenderer() {
public String getDisplayValue(Object value) {
return (String) ((Language)value).getLanguage().getText();
}
}
));
add(new DropDownChoice("country", new PropertyModel(model,
"basicDemographicInfo.country"), countryChoices, new ChoiceRenderer() {
public String getDisplayValue(Object value) {
return (String) countries.get(value);
}
}
));
add(new DropDownChoice("gender", new PropertyModel(model,
"basicDemographicInfo.gender"), genderChoices, new ChoiceRenderer() {
public String getDisplayValue(Object value) {
return (String) genders.get(value);
}
}
));
add(new Button("addButton"));
add(new FeedbackPanel("feedback"));
// Phone's
add(new ListView("phones", new PropertyModel(model,
"personalContactInfo.phone")) {
protected void populateItem(ListItem item) {
Phone phone = (Phone) item.getModelObject();
item.add(new TextField("phone", new PropertyModel(phone, "number")));
item.add(new CheckBox("primary", new PropertyModel(phone,
"isPrimary")));
}
});
// Emails
add(new ListView("emails", new PropertyModel(model,
"personalContactInfo.email")) {
protected void populateItem(ListItem item) {
Email email = (Email) item.getModel().getObject();
item.add(new TextField("email", new PropertyModel(email, "address")));
item.add(new CheckBox("primary", new PropertyModel(email,
"isPrimary")));
}
});
}
// Handle Form Submit
protected void onSubmit() {
BasicInfoModel basicInfoModel = (BasicInfoModel) getModelObject();
PersonalDemographicInfo personalDemographicInfo =
basicInfoModel.getPersonalDemographicInfo();
BasicDemographicInfo basicDemographicInfo =
basicInfoModel.getBasicDemographicInfo();
ContactInfo personalContactInfo =
basicInfoModel.getPersonalContactInfo();
// Trying to figure out why the form changes are to shown here
List emails = personalContactInfo.getEmail();
for (Email email : emails) {
log.info(email.getAddress() + " - " + email.isIsPrimary());
}
// Add a new email to the list.
if (basicInfoModel.getNewEmail() != null &&
basicInfoModel.getNewEmail().length() > 0) {
Email newEmail = new Email();
newEmail.setAddress(basicInfoModel.getNewEmail());
newEmail.setIsPrimary(basicInfoModel.getNewEmailPrimary());
personalContactInfo.getEmail().add(newEmail);
}
try {
phrInfoDao.putThing(((HVSession) this.getSession()).getUserSession(),
personalDemographicInfo);
phrInfoDao.putThing(((HVSession) this.getSession()).getUserSession(),
basicDemographicInfo);
//phrInfoDao.putThing(((HVSession) this.getSession()).getUserSession(),
personalContactInfo);
} catch (Exception e) {
e.printStackTrace();
error("Internal Error saving Personal Info");
return;
}
UserSession userSession = ((HVSession)
this.getSession()).getUserSession();
Record selectedRecord = userSession.getSelectedRecord();
setResponsePage(BasicInfo.class, new PageParameters("id=" +
selectedRecord.getId()));
}
Clint Popetz-2 wrote:
>
> Can you post the full code, including the submit button and the form?
>
> -Clint
>
> On Mon, May 11, 2009 at 7:48 PM, Chris <ch...@carlsoncentral.com> wrote:
>> I have a ListView that contains a TextField and Checkbox. The model is
>> properly populating the components in populateItem(), however onSubmit()
>> in
>> not seeing changes. Do I have to do anything special to make changes to
>> FormComponents in a ListView make it back into the Model?
>>
>> add(new ListView("emails", new PropertyModel(model,
>> "personalContactInfo.email")) {
>> protected void populateItem(ListItem item) {
>> Email email = (Email) item.getModel().getObject();
>> item.add(new TextField("email", new PropertyModel(email, "address")));
>> item.add(new CheckBox("primary", new PropertyModel(email,
>> "isPrimary")));
>> }
>> });
>> model is LoadableDetachableModel.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> --
> Clint Popetz
> http://42lines.net
> Scalable Web Application Development
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/TextField-in-ListView-tp23494369p23494565.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: TextField in ListView
Posted by Clint Popetz <cl...@42lines.net>.
Can you post the full code, including the submit button and the form?
-Clint
On Mon, May 11, 2009 at 7:48 PM, Chris <ch...@carlsoncentral.com> wrote:
> I have a ListView that contains a TextField and Checkbox. The model is
> properly populating the components in populateItem(), however onSubmit() in
> not seeing changes. Do I have to do anything special to make changes to
> FormComponents in a ListView make it back into the Model?
>
> add(new ListView("emails", new PropertyModel(model,
> "personalContactInfo.email")) {
> protected void populateItem(ListItem item) {
> Email email = (Email) item.getModel().getObject();
> item.add(new TextField("email", new PropertyModel(email, "address")));
> item.add(new CheckBox("primary", new PropertyModel(email, "isPrimary")));
> }
> });
> model is LoadableDetachableModel.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Clint Popetz
http://42lines.net
Scalable Web Application Development
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org