如何设计几个外观几乎相似的表格?
我用 UIBinder 设计了大约 6 个表单,它们看起来几乎相同,区别在于两三个字段。我正在考虑构建一种包含所有可能字段的表单,并根据情况隐藏或显示字段。
你觉得这个方法怎么样?
I have about 6 forms to design with UIBinder that look almost the same, the difference is two or three fields. I was thinking about building one form with all the possible fields and hide or show fields depending on the case.
What do you think about this method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它可以很好地工作。您可以使用实现
HasWidgets
的 UiBinder 定义一个BaseForm
类,然后使用类似的内容定义 SpecificForm1.ui.xml以及使用类似的内容定义 SpecificForm2.ui.xml ,
效果非常好!
It can work well. You can define a
BaseForm
class with UiBinder that implementsHasWidgets
, and then define SpecificForm1.ui.xml with something likeand SpecificForm2.ui.xml with something like
it works great!
我尝试过类似的方法,构建一种隐藏/显示适当字段的表单是最简单的解决方案。另一个想法是创建一个工厂,然后根据您的需要构建您的表单。
因此,您基本上创建了表单组成的组件,工厂通过构造函数依赖注入将它们连接在一起。对我来说效果很好,而且还有一个额外的好处,那就是很容易扩展你的形式。
(稍后我会添加一个例子)。
I've tried something similar, and building one form where I hid/show the appropriate fields was the most simple solution. Another idea would be create a factory, which then builds your form according to your needs.
So, you basically create the components your form is composed of, and the factory wires them together via constructor dependency injection. Worked very well for me, and also has the added benefit that it is very easy to extend your form.
(I'll add an example later).