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);
}
});
item.add(password);
if (AttributableType.USER != ResourceMappingPanel.this.attrType) {
password.setVisible(false);
}
final AjaxDropDownChoicePanel<MappingPurpose> purpose =
new AjaxDropDownChoicePanel<MappingPurpose>("purpose",
new ResourceModel("purpose", "purpose").getObject(),
new PropertyModel<MappingPurpose>(mapItem, "purpose"),
false);
purpose.setChoices(Arrays.asList(MappingPurpose.values()));
purpose.setStyleSheet(FIELD_STYLE);
purpose.setRequired(true);
purpose.getField().add(new AjaxFormComponentUpdatingBehavior(ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
}
});
item.add(purpose);
intMappingTypes.getField().add(new AjaxFormComponentUpdatingBehavior(ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
setAttrNames(intMappingTypes.getModelObject(), intAttrNames);
target.add(intAttrNames);
setAccountId(intMappingTypes.getModelObject(), accountId, password);
target.add(accountId);
}
});
setAttrNames(mapItem.getIntMappingType(), intAttrNames);
setAccountId(mapItem.getIntMappingType(), accountId, password);
}
};
mappings.setReuseItems(true);
mappingContainer.add(mappings);
addMappingBtn = new IndicatingAjaxButton("addMappingBtn", new ResourceModel("add")) {
private static final long serialVersionUID = -4804368561204623354L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
getMapping().getItems().add(new MappingItemTO());
target.add(ResourceMappingPanel.this);
}
};
addMappingBtn.setDefaultFormProcessing(false);
addMappingBtn.setEnabled(this.resourceTO.getConnectorId() != null && this.resourceTO.getConnectorId() > 0);
mappingContainer.add(addMappingBtn);
boolean accountLinkEnabled = false;
if (getMapping().getAccountLink() != null) {
accountLinkEnabled = true;
}
accountLinkCheckbox = new AjaxCheckBoxPanel("accountLinkCheckbox",
new ResourceModel("accountLinkCheckbox", "accountLinkCheckbox").getObject(),
new Model<Boolean>(Boolean.valueOf(accountLinkEnabled)));
accountLinkCheckbox.setEnabled(true);
accountLinkContainer.add(accountLinkCheckbox);