JSF2:在运行时构建 JSF2 视图(整个组件树)
目前我正在尝试 JSF 2.0,并且仍在学习更高级的功能。
当必须处理预定义视图(固定组件树)时,JSF2 很舒服,这些视图的小部件在编译时是完全已知的——当然,重复数据列表/表条目和轻微动态修改除外通过数据表“技巧”的表单(正如我在这里读到的,特别是在 JSF2 下,我可以动态添加 JSF 组件吗? 和 如何创建动态 JSF 1.2 表单字段)。
现在我想知道完全动态的 JSF2 组件树的实现,其中 Web 用户对于每个给定的内容类型(例如“Person”、“PersonList”以及“PersonalManagementPanel”)可以从内容列表中选择一个 -类型兼容的小部件(=JSF 自定义组件)。
因此,该用户将始终看到使用他/她喜欢的“PersonalManagerPanel”呈现的“个人管理器页面”,而“PersonalManagerPanel”又会使用用户喜欢的变体呈现其嵌套组件(“Person”、“PersonList”)。
显然,目标是在运行时获得选择性配置/可定制的 JSF 页面。
这个场景在 JSF2 中可以实现吗? -- 这是怎么做到的?
是否有更适合此要求的 Java 技术?
-- 我正在考虑的一种可能的替代方案是 XML 加 XSLT。
非常感谢您的帮助和建议。
最好的问候
马丁
Currently I'm trying JSF 2.0 and still learning the more advanced features.
JSF2 is comfortable when having to deal with pre-defined views (fixed component trees) whose widgets are completely known at compile time -- of course with the exception of repeating data list/table entries and light dynamic modification of forms via the DataTable "trick" (as I read here, especially under JSF2, can I add JSF components dynamically? and How to create dynamic JSF 1.2 form fields).
Now I'm wondering about the realization of completely dynamic JSF2 component trees, where a web user, for each given content type (e.g. 'Person', 'PersonList' but also 'PersonalManagementPanel'), can choose one from a list of content-type compatible widgets (=JSF custom components).
As result, this user will always see the "Personal Manager Page" rendered with his/her prefered "PersonalManagerPanel", which in turn also renders its nested components ('Person', 'PersonList') with the user's preferred variants.
Obviously, the goal is to get a selectively configurable/customizable JSF Page -- at runtime.
Is this scenario realizable in JSF2? -- How could this be done?
Are there more appropriate Java technologies for this requierement?
-- One possible alternative I'm thinking of is XML plus XSLT.
Thank you very much for your help and suggestions.
Best regards
Martin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以使用这样的东西:
或者如果你想要更复杂的组件,你应该看看 PreRenderViewEvent。
请注意,这两种解决方案都存在问题。
You can use something like this:
Or if you want more complicated components, you should take a look at the PreRenderViewEvent.
Note that there are issues with both solutions.