public CriterionEditPanel(String id) {
super(id);
Form criterionEditForm = new Form("criterionEditForm");
criterionEditForm.add(new Label("criterionNameLabel", new ResourceModel("criterion.name")));
criterionEditForm.add(new Label("criterionValueLabel", new ResourceModel("criterion.value")));
criterionEditForm.add(new Label("criterionResolverTypeLabel", new ResourceModel("criterion.resolver")));
criterionEditForm.add(new Label("criterionFallbackLabel", new ResourceModel("criterion.fallback.type")));
criterionEditForm.add(new Label("criterionOrderLabel", new ResourceModel("criterion.fallback.order")));
TextField criterionNameField = new TextField("criterionNameField", new PropertyModel(RuleEditPanel.this, "criterion.name"));
criterionNameField.setRequired(true);
TextField criterionValueField = new TextField("criterionValueField", new PropertyModel(RuleEditPanel.this, "criterion.value"));
DropDownChoice criterionResolverTypeField = new DropDownChoice("criterionResolverTypeField", resolvers);
criterionResolverTypeField.setModel(new PropertyModel(RuleEditPanel.this, "criterion.type"));
criterionResolverTypeField.setRequired(true);
DropDownChoice criterionFallbackField = new DropDownChoice("criterionFallbackField", fallbackTypes, new FallbackTypeChoiceRenderer());
criterionFallbackField.setModel(new PropertyModel(RuleEditPanel.this, "criterion.fallbackType"));
criterionFallbackField.setRequired(true);
TextField criterionOrderField = new TextField("criterionOrderField", new PropertyModel(RuleEditPanel.this, "criterion.fallbackOrder"));
criterionOrderField.setRequired(true);
criterionEditForm.add(criterionNameField);
criterionEditForm.add(criterionValueField);
criterionEditForm.add(criterionResolverTypeField);
criterionEditForm.add(criterionFallbackField);
criterionEditForm.add(criterionOrderField);
Button saveCriterionButton = new Button("saveCriterionButton",new ResourceModel("profiler.rule.save")) {
@Override
public void onSubmit() {
if (criterion.getValue() != null)
{
String value = criterion.getValue();
value = value.trim();
if (value.equals(""))
{
criterion.setValue(null);
}
}
if (!profilingRule.getRuleCriteria().contains(criterion)) {
profilingRule.getRuleCriteria().add(criterion);
}
try {
Profiler profiler = getServiceLocator().getProfiler();
profiler.storeProfilingRule(profilingRule);
}
catch (ProfilerException e) {
logger.error("Could not save rule criterion {}: {}", criterion.getName(), e.getMessage());
}
}
};
Button removeCriterionButton = new Button("removeCriterionButton",new ResourceModel("criteria.remove")) {
@Override
public void onSubmit() {
if (profilingRule.getRuleCriteria().contains(criterion)) {
profilingRule.getRuleCriteria().remove(criterion);