从JMS监听器类编程更新某些视图(Updating certain view programmati

2019-07-05 17:49发布

I was able to integrate ActiveMQ and create a JMS consumer into my OpenXava application. Now, I need to update certain transient view with the data received in the message, which it have several issues to consider, by example... how to go from a JMS listener java class and push the changes to the current view? ... and supposing the specific view is the current!!!, but the current view could be any one of the several possibles views in the whole application!!! ... so? so?... then I did think, I will persist the JMS messages into some entity (as a temporal storage in DB) even that will incur in a low performance, but then after that... how I will push the recent changes if some user is looking the transient view.

I was used to build my webapps using some JSF implementation with ajax enabled, and then I could receive the message in the JMS listener and then get a jsf managed bean reference and use Ajax push to refresh all the sessions that could be opened by one or several users looking into the app, so this always produced a kind of real time application, which update the any opened view (if the view is the one that the user is watching).

So, is there a way to accomplish that with a JMS listener class into my OX app??

Thanks in advance,

Answer 1:

一个选项可以使用JavaScript调用定期知道,如果一个新的记录表或任何添加,如果它是区分耳目一新。

如果你的Liferay,你可以创建与JavaScript代码页的Portlet。 此代码可以做到使用DWR的电话,如果有新的数据,则可以直接打电话到“CRUD.refresh”行动。

事情是这样的:

refreshData = function() {
   openxava.executeAction('YourApplication', 'YourModule', '', false, 'CRUD.refresh')
   setTimeout('refreshData()', 5000);
}
setTimeout('refreshData()', 5000);

我没有测试此代码,所以它肯定不会是就是工作。 把它作为一种思想。

真的,这是一个肮脏的把戏。 理想的做法是OpenXava中将会对彗星的直接支持,你可以做到这一点只是打电话到服务器的方法。 你认为对OX值得加入彗星的支持?



文章来源: Updating certain view programmatically from a JMS listener class