*/
public TextFieldPanel(final ModelContext modelContext,
final ViewContext viewContext) {
super(viewContext.getWicketId());
try {
IEntity entity;
String action = modelContext.getAction();
if (action != null && action.equals("update")) {
entity = modelContext.getUpdateEntity();
} else {
entity = modelContext.getEntity();
}
PropertyConfig propertyConfig = modelContext.getPropertyConfig();
String propertyCode = propertyConfig.getCode();
Class propertyClass = propertyConfig.getPropertyClassObject();
if (propertyConfig.isReference()) {
String neighborCode = propertyConfig.getReferenceNeighbor();
NeighborConfig neighborConfig = entity.getConceptConfig()
.getNeighborsConfig().getNeighborConfig(neighborCode);
String neighborConceptCode = neighborConfig.getDestination();
App app = (App) getApplication();
IPersistentEntities persistentEntities = app.getDbContext()
.getPersistentModel().getPersistentEntry(
neighborConceptCode);
IOrderedEntities neighborEntities = null;
if (persistentEntities != null) {
neighborEntities = (IOrderedEntities) persistentEntities
.getEntities();
}
if (neighborEntities != null) {
Long referenceOid = (Long) entity.getProperty(propertyCode);
Oid neighborParentOid = new Oid(referenceOid);
IEntity neighborParent = neighborEntities
.retrieveByOid(neighborParentOid);
if (neighborParent != null) {
PropertyConfig firstEssentialPropertyConfig = neighborParent
.getConceptConfig().getPropertiesConfig()
.getFirstEssentialPropertyConfig();
if (firstEssentialPropertyConfig != null) {
String firstEssentialPropertyCode = firstEssentialPropertyConfig
.getCode();