数据库驱动的表单控件
如何做数据库驱动jsp页面,
假设我有5个文本字段,如果用户想将其中一个表单字段作为选择框。如果它在数据库中定义为选择框,JSp应该识别并返回选择框。
我不知道如何实现这一点,任何人都可以建议这个。
问候, 拉朱·科马图里
How to do databse driveen jsp page,
Suppose i have 5 text fields,if user wants to put one of the form field as select box.JSp should identify and return the select box if it define in db as select box.
I dont know how to achieve this,can anyone suggest this.
Regards,
Raju komaturi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想完全完成此操作,则有多个任务。整个世界并没有走这条路,因此没有太多工具(如果有的话)。但基本上这里是主要想法。
1)你需要一个“数据字典”,一个元数据的集合,告诉你每列的类型和大小是什么,以及主键和外键是什么。
2)对于“知道”字段应该是下拉列表的示例,这几乎总是意味着列值是另一个表的外键。您的代码检测到这一点并根据父表中的值构建一个列表框。
3) 您甚至可以为简单的表格创建一个完整的表单生成器,其中生成所有 HTML,但您始终需要一种方法来覆盖更复杂的表单。如果这样做,您的数据字典还应该有列描述或标题。
还有更多的想法,但这是您所描述的起点。
There are multiple tasks if you want to do this completely. The world at large has not gone this way and so there are not many tools (if any) for this. But basically here are the main ideas.
1) You want a "data dictionary", a collection of meta-data that tells you what the types and sizes of each column are, and the primary and foreign keys are.
2) For your example of "knowing" that a field should be a drop-down, this almost always means that column value is a foreign key to another table. Your code detects this and builds a listbox out of the values in the parent table.
3) You can go so far as to create a complete form generator for simple tables, where all of the HTML is generated, but you always need a way to override this for the more complex forms. If you do this, your data dictionary should also have column descriptions or captions.
There are many many more ideas, but this is the starting point for what you describe.