如何在jsf中的数据表中进行列级渲染?
如何在不使用ajax的情况下在jsf中的数据表中进行列级渲染?
例如,第一列具有下拉菜单选项。根据选择,我需要启用第二列中的按钮。
任何人都可以帮我解决这个问题吗?
How to do a column level render in datatable in jsf without using ajax?
For example, First column having a Drop down menu selection. Based on the selection, I need to enable button in the second column.
Can any one help me on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果“列级渲染”的意思是“一种重新渲染表中单个列的方法”,那么答案是 - 你不能。浏览器不允许这样做。您需要分别重新渲染列中的每个 td。
如果您只是指“即时更改表格的某些部分”,那么:
如果“ajax”是指“javascript”,那么 - 你不能。您需要相当多的 JavaScript 来完成此操作。
如果“ajax”的意思是“连接到服务器”,那么 - 您可以编写自己的 Javascript 在客户端上完成这项工作。
诀窍是 - 一旦开始使用 javascript 启用和禁用按钮,您必须一路走下去:不仅在选择选项时下拉列表发生更改,而且在首次呈现表格时也发生更改。如果不这样做,您将不得不在 Java 中和 Javascript 中碰撞表示逻辑。
可应用于 JSF 输出的有效 Javascript 解决方案的示例如下:
当您从下拉列表中选择“B”时,相关按钮将被禁用。
在我看来,这是一个非常糟糕的解决方案。
您应该使用 JSF 及其提供的工具(如 ajax 标签),或者切换技术。混合技术会让它们变得更加困难,而混合你并不真正擅长的东西(因为你不得不问这个问题 - 你当然不擅长)会适得其反。
If by "column level render" you mean "a way to rerender a single column in table" then the answer is - you can't. Browsers do not allow this. You would need to rerender each td in a colimn separately.
If you just mean "change some parts of the table on the fly", then:
if by "ajax" you mean "javascript", then - you can't. You need quite some javascript to do this.
if by "ajax" you mean "connecting to the server", then - you can write your own Javascript to do the job on the client.
The trick is - once you start using the javascript to enable and disable buttons, you must go all the way: not only when an option is selected dropdown is changed, but also when the table is first rendered. If you don't, you will have to colliding pieces of presentation logic, on in Java, one in Javascript.
An example of a working Javascript solution that could be applied to JSF output would be:
When you select "B" from a dropdown, the relevant button gets disabled.
In my opinion this is a very bad solution.
You should either use JSF and the tools it provides (like the ajax tag), or switch technology. Mixing technologies makes them exponentially harder, and mixing things you are not really good at (and since you had to ask the question - you are certainly not) will backfire.