我想实现这一目标:
在我的数据表中的一个单元格中,我可以触发一个操作,通过单击 commandLink 可以刷新数据表本身。
但我经历的是:
触发操作后,一切都按预期进行,但只缺少一件事,那就是它不刷新数据表。
我的链接摘录如下(是的,我知道使用 @all 不是一个好主意,但这是出于测试目的):
<p:column>
<p:commandLink value="Undo"
process="@all"
action="#{tInputBean.undoRemoveRecord(rpbDetail)}"
update="@all"
rendered="#{tInputBean.isRemoveRecord(rpbDetail)}"
/>
</p:column>
我进一步测试了,在数据表的标头方面的内部放置了一个按钮,这只是刷新网格:
<p:commandButton value="Refresh Data" update="gridRPBDetails" />
所以步骤变成了:
- 单击链接后,网格不会自行刷新。
- 单击刷新按钮实际上会刷新网格,链接消失(由于呈现的属性),这意味着我的 JSF Bean 中的所有阶段和状态都已经正确。只有刷新视图阶段失败。
我想要实现的目标很简单:单击链接,链接本身刷新并消失(从呈现的属性)
在我看来,从我的测试来看,结论是:任何可以触发操作和刷新的记录包含该记录的网格将在刷新阶段失败。
有什么想法可以解决这个问题吗?
无论如何,我想在单击 firebug 中的“撤消”链接后分享响应:
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewState"><![CDATA[673421645734309925:-3805206326573204566]]></update></changes><extension primefacesCallbackParam="validationFailed">{"validationFailed":false}</extension></partial-response>
我使用 tomcat 7,这些是我的依赖项:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
更新:
我意识到这篇文章没有一个简单的示例,并且很难测试和解释因此,我做了一个简单的例子,我已发布在此处。
如果版主认为应该删除该帖子并执行此操作,那也没关系。
谢谢 !
I would like to achieve this :
Inside my datatable, in one of the cell, i can trigger an action that can refresh the datatable itself by clicking on the commandLink.
But what i experienced is :
After triggering the action, everything works as intended, but lacking only in one thing, which is, it doesnt refresh the datatable.
My excerpt goes like this for the link (yes, i know using @all is not a good idea, but this is for the testing purpose):
<p:column>
<p:commandLink value="Undo"
process="@all"
action="#{tInputBean.undoRemoveRecord(rpbDetail)}"
update="@all"
rendered="#{tInputBean.isRemoveRecord(rpbDetail)}"
/>
</p:column>
And i tested further, putting a button outside of the , inside the header facet of the datatable, that does nothing but only to refresh the grid :
<p:commandButton value="Refresh Data" update="gridRPBDetails" />
So the steps have become :
- After clicking on the link, the grid doesnt refresh itself.
- Clicking on the refresh button actually refreshes the grid, the link vanishes (because of the rendered attribute), which means, all the phases and the states in my JSF Bean is already correct. Only the refresh view phase fails.
What i would like to achieve is as simple as : clicking on the link, the link itself refreshes and disappears (from the rendered attribute)
It seems to me that from my tests, the conclusion is : any record that can trigger an action and refresh the grid that contains that record will fail in the refreshing phase.
Any ideas to solve this problem ?
Anyway, i want to share the response after clicking on the "Undo" link from firebug :
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewState"><![CDATA[673421645734309925:-3805206326573204566]]></update></changes><extension primefacesCallbackParam="validationFailed">{"validationFailed":false}</extension></partial-response>
Im using tomcat 7, and these are my dependencies :
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
UPDATE :
I realize this post dont have a simple example, and would be hard to test and explain, thus, i made a simple example that i have posted here.
It's ok if the moderator thinks this post should be removed and do that.
Thank you !
发布评论
评论(1)
你在哪里更新记录?仅通过输入过程和更新是不行的。除此之外不要使用@all。如果您的数据表已经在表单内,那么在这种情况下它不会更新。使用@this。
我很想帮助你,但我不知道你在后端想做什么。为了刷新数据表,您需要有一个操作侦听器或操作属性来处理刷新。那么另一个问题是你的bean的范围是什么?如果其会话范围,那么您需要将其更改为查看范围。
把你的代码放在这里,然后我可以更好地解释它。
Where are you updating the record? Just by typing process and update wont do. Other than that don't use @all. If your data table is already inside a form it wont update in that @all case. Use @this.
I would like to help you but I don't know what are you trying to do at the back end. In order to refresh the data table you need to have an action Listener or action attribute that would handle refresh. Then the other question what is the scope of your bean? If its session scoped then you need to change that to view scope.
Put your code in here and then i can explain it much better.