使用Springboot进行表单管理-当用户选择预先输入时自动填充表单

时间:2018-10-19 12:13:21

标签: spring-boot model-view-controller bootstrap-typeahead

我有一个Spring Boot MVC Web应用程序表格。 用户可以在字段中键入和对象名称。此字段会获得一个已存在对象的自举式提前动态列表。

当用户在预先输入列表中选择一个已知对象时,我想用几个对象属性自动填充表单的杂项字段。

我的问题是,在springboot中正确实施MVC时,应该怎么做?如何告诉我的控制器“嘿,用户选择了-foo-对象,现在填写其他字段!” ? 应该是表单的POST吗? 可以在控制器中放入一种@heyFillTheForm吗?

谢谢

1 个答案:

答案 0 :(得分:0)

从设计的角度来看,我确实希望使用XHR来发布或放置表单的那些部分。

但是,我认为会创建两个单独的MVC控制器方法:

  1. 一个名为select a.result_id, //product result id in table a, b a.wc_code, a.order_no_d, //product order # in table a = c c.item_code, d.item_name, a.prod_date, a.lot_no, a.item_no, a.plt_no, a.grade, b.rework_seq + 1, //this is only in rework_seq table b.diposition_code, b.defect_code, //defect codes are A through Z and each rework attempt has different defect code b.defect_code2, b.defect_code3, a.insp_work_date as Inspection_Date, //getting inspection date from prod_result table because this will be final inspection date when reworked products get A grade. a.insp_work_id as Inspector_ID from prod_result a, rework_history b, prod_order_detail c, item d where a.result_id = b.result_id and a.order_no = c.order_no and c.item_code = d.item_code and a.plant_code = 'T337' and b.rework_seq = //this is the part.. I can't tell what max # rework_seq is a.grade = 'A' and a.result_id in (select result_id from rework_history) //This part sort out first pass A grade from A grade achieved through rework. and b.enrl_date between to_date('2018-06-01 07:00:00', 'yyyy-mm-dd hh24:mi:ss') //enrl_date is reworked date and this date doesn't exist in prod_result table. So in order to get all rework date on all rework, this data should come from rework_history table. and to_date('2018-07-01 07:00:00', 'yyyy-mm-dd hh24:mi:ss') " + order by Inspection_Date asc; 的对象,返回带有预填充值的JSON对象。有人可能会说这应该是retrieveAutofillValues
  2. 一个称为PUT的POST,返回提交结果