Bad Mix: Form addField +setVisibleItemProperties

When I use the Form addField method followed by setVisibleItemProperties, no field is diaplayed on the screen, but remove setVisibleItemProperties and there they all are.

The question is: is addField and setVisibleItemProperties compatible?

Thanks and here are some codes for your perusal:


	dataProfileForm = new Form();
	dataProfileForm.setDebugId("dataProfileFormId");
	dataProfileForm.setCaption("Data Profile");
	dataProfileForm.addField("dataVisibility", getDataVisibilityTextField());
	dataProfileForm.addField("updatedBy", getUpdatedByTextField());
	dataProfileForm.addField("dateLastUpdated", getDateLastUpdatedPopupDateField());
	dataProfileForm.addField("hits", getHitsTextField());
	dataProfileForm.addField("dataStatus", getDataStatusTextField());
	dataProfileForm.addField("createdBy", getCreatedByTextField());
	dataProfileForm.addField("notes", getNotesTextArea());
	dataProfileForm.addField("ownerId", getOwnerIdTextField());
	dataProfileForm.addField("version", getVersionTextField());
	dataProfileForm.addField("dateCreated", getDateCreatedPopupDateField());

	// Determines which properties are shown, and in what order:
	dataProfileForm.setVisibleItemProperties(SortedVisibleProperties.getDataProfileProperties());

class SortedVisibleProperties{

	public static final Collection<String> getDataProfileProperties() {

		if (dataProfileProperties == null) {
			dataProfileProperties = new ArrayList<String>();
			dataProfileProperties.add("id");
			dataProfileProperties.add("ownerId");
			dataProfileProperties.add("dateCreated");
			dataProfileProperties.add("dateLastUpdated");
			dataProfileProperties.add("createdBy");
			dataProfileProperties.add("updatedBy");
			dataProfileProperties.add("dataStatus");
			dataProfileProperties.add("dataVisibility");
			dataProfileProperties.add("version");
			dataProfileProperties.add("hits");
			dataProfileProperties.add("notes");
		}
		return dataProfileProperties;
	}

Hi,

You are right, it’s a bad mix, they are not compatible.

You can use Form in two basic ways:

[list]

[]
Not bound to a data model: use addField() to add fields
[
]
Bound to a data model (an Item): fields are created automatically from the item properties using a FormFieldFactory

[/list]The setVisibleItemProperties() works with the latter mode. What happens is that it empties the form and recreates the fields from the listed properties, which in your case do not exist so it will just empty the form.

Marko Grönroos,

Just back to say thank you.