DataTable with dynamic columns

前端 未结 2 1842
遇见更好的自我
遇见更好的自我 2021-02-19 03:06

I am completely new to JSF, and just attempting a proof of concept to decide whether it will be useful for a project. My POC simply consists of a single page, with a table, cont

2条回答
  •  梦谈多话
    2021-02-19 03:57

    JSTL and JSF doesn't run in sync as you'd expect from the coding. It's more so that JSTL first processes the entire page from top to bottom first and then hands over the result to JSF for further processing. The #{row} is unavailable at the time JSTL is busy, so your attempt indeed won't work.

    The linked topic indeed mentions deprecated methods, but the topic is also aged and discusses legacy JSF 1.0/1.1. If you explore the current Javadocs of the mentioned methods, you'll see that -as usual- the replacement methods are mentioned. For example, Application#createValueBinding() mentions the following:

    Deprecated. This has been replaced by calling getExpressionFactory() then ExpressionFactory.createValueExpression(javax.el.ELContext, java.lang.String, java.lang.Class).

    You can find some concrete examples of dynamically populating a datatable this way in this article.

    As to 3rd party component libraries, RichFaces has a rich:columns component which is designed for exactly this purpose.

提交回复
热议问题