diff --git a/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java b/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java index 597a9e9..673e90a 100644 --- a/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java +++ b/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java @@ -26,9 +26,9 @@ public class RuleController { @PathVariable(value = "ruleId") Integer id, Model model) { model.addAttribute("projectId", projectId); model.addAttribute("fuzzyRuleForm", - new FuzzyRuleForm(id, (id != null && id != 0) - ? ruleService.getById(id).getProject().getId() - : projectId)); + (id != null && id != 0) + ? new FuzzyRuleForm(id, ruleService.getById(id)) + : new FuzzyRuleForm(id, projectId)); return "rule/edit"; } diff --git a/src/main/java/ru/ulstu/fc/rule/controller/VariableController.java b/src/main/java/ru/ulstu/fc/rule/controller/VariableController.java index 2d53c76..8fdb9b9 100644 --- a/src/main/java/ru/ulstu/fc/rule/controller/VariableController.java +++ b/src/main/java/ru/ulstu/fc/rule/controller/VariableController.java @@ -4,7 +4,6 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/src/main/java/ru/ulstu/fc/rule/model/FuzzyRuleForm.java b/src/main/java/ru/ulstu/fc/rule/model/FuzzyRuleForm.java index 43c5f69..5ae6d32 100644 --- a/src/main/java/ru/ulstu/fc/rule/model/FuzzyRuleForm.java +++ b/src/main/java/ru/ulstu/fc/rule/model/FuzzyRuleForm.java @@ -19,6 +19,12 @@ public class FuzzyRuleForm { this.projectId = projectId; } + public FuzzyRuleForm(Integer id, FuzzyRule fuzzyRule) { + this.id = fuzzyRule.getId(); + this.projectId = fuzzyRule.getProject().getId(); + this.content = fuzzyRule.getContent(); + } + public Integer getProjectId() { return projectId; } diff --git a/src/main/resources/templates/project/edit.html b/src/main/resources/templates/project/edit.html index 79ec99b..1a23237 100644 --- a/src/main/resources/templates/project/edit.html +++ b/src/main/resources/templates/project/edit.html @@ -33,7 +33,9 @@