如何在 JSF/Richfaces 中生成和处理动态布局和符号?
我的目标是根据某些输入配置(如 XML 文件)生成图形布局(由 Richfaces 组件组成)并将其显示在我的 Web 应用程序中。布局由代表系统中各种实体的图形符号组成:每个符号应映射到系统中的实体,以便显示其状态。 XML 配置文件用于定义布局中的符号连接和位置,以及它们到实体的映射规则。我怎样才能实现这个目标?
我正在考虑使用 SVG 等技术创建一个符号库,您可以在其中定义方面和行为,然后简单地将每个 SVG 符号“包装”在动态创建的 richfaces 组件中,这将允许我处理用户交互和符号中定义的映射规则。不幸的是,JSF/Richfaces 不支持 SVG 图像,因此我必须使用没有 Richfaces 功能的纯 HTML。
实现这一目标的另一种方法是在 XML 文件中简单地定义通用符号,每个符号都具有指定相关图像、映射规则等的属性,然后从 Web 应用程序中生成相应的 richfaces 组件。通过这样做,我是否能够在正确的位置显示所有符号,从而生成完整的动态布局?
你能建议一个更好的方法吗?非常感谢。
My objective is to generate a graphic layout (made of Richfaces components) based on some input configuration (like an XML file) and display it in my web app. The layout is composed of graphic symbols representing various entities in the system: each symbol should be mapped to an entity in the system, in order to display its state. The XML configuration file is used to define the symbol connections and positions within the layout, and their mapping rules to an entity. How can I achieve this?
I was thinking to create a symbol library in a technology such as SVG, where you can define both the aspect and the behaviour, and then simply "wrap" each SVG symbol in a dynamically created richfaces component, which would allow me to handle both the user interactions and the mapping rules defined in the symbol. Unfortunately JSF/Richfaces don't support SVG images, therefore I would have to use plain HTML without Richfaces features.
Another way to achieve that would be to simply define generic symbols in the XML file, each one of them with an attribute specifying the related image, the mapping rule, etc., and then generate the corresponding richfaces component from within the web-app. By doing so, would I be able to then display all the symbols in the right position and therefore generate the complete dynamic layout?
Could you suggest a better approach? Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信 HTML5 直接支持 SVG 图像,但它毕竟仍然是常规 HTML 中的嵌入对象。这也是我一直在等待的东西,但我不相信任何当前的 JSF2 组件库都提供了这方面的服务。
以下是对可能的解决方法的一个很好的解释:
开始使用 JSF 2.0 页面中的 SVG 图形对象
您是否可以利用此解决方法构建自定义 Facelet 组件?
但我的想法是,当你唯一的工具是锤子时,一切看起来都像钉子。我会尝试利用更适合显示和操作矢量图形的 RIA(富互联网应用程序)技术,例如 HTML5、Flash+Flex、Silverlight 等。
I believe that HTML5 has direct support for SVG images, however it is still an embedded object in regular HTML after all. This too is something I have been waiting for however I don't believe any of the current JSF2 component libraries have an offerring for this yet.
Here is a good explanation of a possible workaround:
Getting started with SVG graphics objects in JSF 2.0 pages
Potentially you could build a custom facelet component utilizing this workaround?
My thought though is that when your only tool is a hammer, everything looks like a nail. I would try to utilize an RIA (Rich Internet Application) technology better suited for display and manipulation of vector graphics like HTML5, Flash+Flex, Silverlight, etc..