target.add(intAttrNames.getField());
}
});
item.add(entitiesPanel);
final FieldPanel extAttrNames = new AjaxTextFieldPanel("extAttrName",
new ResourceModel("extAttrNames", "extAttrNames").getObject(),
new PropertyModel<String>(mapItem, "extAttrName"));
((AjaxTextFieldPanel) extAttrNames).setChoices(schemaNames);
boolean required = false;
boolean accountIdOrPassword = mapItem.isAccountid() || mapItem.isPassword();
if (accountIdOrPassword) {
((AjaxTextFieldPanel) extAttrNames).setModelObject(null);
} else if (!schemaNames.isEmpty()) {
required = true;
}
extAttrNames.setRequired(required);
extAttrNames.setEnabled(required);
extAttrNames.setStyleSheet(FIELD_STYLE);
item.add(extAttrNames);
final AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel("mandatoryCondition",
new ResourceModel("mandatoryCondition", "mandatoryCondition").getObject(),
new PropertyModel<String>(mapItem, "mandatoryCondition"));
mandatory.setChoices(Arrays.asList(new String[] {"true", "false"}));
mandatory.setStyleSheet(SHORT_FIELD_STYLE);
item.add(mandatory);
final AjaxCheckBoxPanel accountId = new AjaxCheckBoxPanel("accountId",
new ResourceModel("accountId", "accountId").getObject(),
new PropertyModel<Boolean>(mapItem, "accountid"));
accountId.getField().add(new AjaxFormComponentUpdatingBehavior(ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
extAttrNames.setEnabled(!accountId.getModelObject() && !mapItem.isPassword());
extAttrNames.setModelObject(null);
extAttrNames.setRequired(!accountId.getModelObject());
target.add(extAttrNames);
if (accountId.getModelObject()) {
mapItem.setMandatoryCondition("true");
mandatory.setEnabled(false);
} else {
mapItem.setMandatoryCondition("false");
mandatory.setEnabled(true);
}
target.add(mandatory);
}
});
item.add(accountId);
final AjaxCheckBoxPanel password = new AjaxCheckBoxPanel("password",
new ResourceModel("password", "password").getObject(),
new PropertyModel<Boolean>(mapItem, "password"));
password.getField().add(new AjaxFormComponentUpdatingBehavior(ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
extAttrNames.setEnabled(!mapItem.isAccountid() && !password.getModelObject());
extAttrNames.setModelObject(null);
extAttrNames.setRequired(!password.getModelObject());
target.add(extAttrNames);
setAccountId(intMappingTypes.getModelObject(), accountId, password);
target.add(accountId);
}