2015-10-09 58 views
0

我嘗試了幾種不同的方法來實現這一點,但都沒有成功。我試過jruby,activiti的其餘api(這不會更新UI,因此不適合我的目的)和機械化寶石。機械化的寶石沒有工作,因爲Activiti Explorer附帶的VAADIN UI或我認爲的。我目前在我的Rails應用程序的iframe中託管了activiti,並試圖找到兩者之間進行通信的方式。我用這樣的寶石:將Activiti Explorer與Ruby on Rails項目集成

agent= Mechanize.new 
agent.redirection_limit= 10 
//page is used three times to illustrate different routes taken. 
page= agent.get('http://127.0.0.1:8080/activiti-webapp-explorer2-5.18.0/) 

page= agent.post('http://127.0.0.1:8080/activiti-webapp-explorer2-5.18.0/ui/APP/2/login',{'username'=>'kermit', 'password'=>'kermit'}) 

page=agent.put('http://127.0.0.1:8080/activiti-webapp-explorer2-5.18.0/ui/1/loginHandler',{'username'=>'kermit', 'password'=>'kermit'}) 

這裏是Activiti的探險家樣本反應時使用機械化:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
<style type="text/css">html, body {height:100%;margin:0;}</style><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti/favicon.ico" /><link rel="icon" type="image/vnd.microsoft.icon" href="/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti/favicon.ico" /><title>Activiti&#32;Explorer</title> 
</head> 
<body scroll="auto" class="v-generated-body"> 
<script type="text/javascript"> 
//<![CDATA[ 
if(!vaadin || !vaadin.vaadinConfigurations) { 
if(!vaadin) { var vaadin = {}} 
vaadin.vaadinConfigurations = {}; 
if (!vaadin.themesLoaded) { vaadin.themesLoaded = {}; } 
} 
vaadin.vaadinConfigurations["activitiwebappexplorer25180ui-1091631569"] = {appUri:'/activiti-webapp-explorer2-5.18.0/ui', standalone: true, themeUri:"/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti", versionInfo : {vaadinVersion:"6.8.8",applicationVersion:"NONVERSIONED"},"comErrMsg": {"caption":"Communication problem","message" : "Take note of any unsaved data, and <u>click here<\/u> to continue.","url" : null},"authErrMsg": {"caption":"Authentication problem","message" : "Take note of any unsaved data, and <u>click here<\/u> to continue.","url" : null}}; 
//]]> 
</script> 
<iframe tabIndex='-1' id='__gwt_historyFrame' style='position:absolute;width:0;height:0;border:0;overflow:hidden;' src='javascript:false'></iframe> 
<script language='javascript' src='/activiti-webapp-explorer2-5.18.0/VAADIN/widgetsets/org.activiti.explorer.CustomWidgetset/org.activiti.explorer.CustomWidgetset.nocache.js?1444407987049'></script> 
<script type="text/javascript"> 
//<![CDATA[ 
if(!vaadin.themesLoaded['activiti']) { 
var stylesheet = document.createElement('link'); 
stylesheet.setAttribute('rel', 'stylesheet'); 
stylesheet.setAttribute('type', 'text/css'); 
stylesheet.setAttribute('href', '/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti/styles.css'); 
document.getElementsByTagName('head')[0].appendChild(stylesheet); 
vaadin.themesLoaded['activiti'] = true; 
} 
//]]> 
</script> 
<script type="text/javascript"> 
//<![CDATA[ 
setTimeout('if (typeof org_activiti_explorer_CustomWidgetset == "undefined") {alert("Failed to load the widgetset: /activiti-webapp-explorer2-5.18.0/VAADIN/widgetsets/org.activiti.explorer.CustomWidgetset/org.activiti.explorer.CustomWidgetset.nocache.js?1444407987049")};',15000); 
//]]> 
</script> 
<div id="activitiwebappexplorer25180ui-1091631569" class="v-app v-theme-activiti v-app-ExplorerApp" ><div class="v-app-loading"></div></div> 
<noscript>You have to enable javascript in your browser to use an application built with Vaadin.</noscript></body> 
    </html> 

我已經嘗試了所有可能的網址,我可以在UI上看到的,但他們都沒有工作。我嘗試了所有的帖子,得到,並與這三個網址中的每一個都放在一起。我通過查看加載的頁面發現了這些URL,並注意到它們是嵌套的iframe。任何幫助看到機械化寶石的可行性都會很好,就好像這可以很容易地解決我的問題。作爲一個方面說明,我已經改變了tomcat屬性以允許CORS請求。另外,從rails到activiti explorer的http請求也不起作用,所以這種通信形式也沒有了。

另外,如果您熟悉activiti-我已經編輯了默認登錄處理程序中的authenticate方法,嘗試解析http請求以獲取用戶名和密碼以自動登錄。然而,這返回與上面打印的相同的html代碼。任何幫助將不勝感激。這裏是我從rails製作的http請求的示例:

auth = {:userid=> "kermit", :password => "kermit"} 
puts HTTParty.get("http://activiti.testing.com:8080/activiti-webapp-explorer2-5.18.0/", :content_type => "application/json", 
:basic_auth => auth) 
+0

我已成功將Activiti REST與PHP Web前端集成,因此與RoR應用程序的集成應該沒有多大區別。你能用這種方法詳細說明你遇到的問題嗎? –

+0

我使用activiti REST沒有問題,因爲那是由寶石處理的。問題在於UI與REST沒有任何關係,UI是集成中最重要的部分。 – user1892714

+0

好的,但你的用戶界面將顯示關於進程的信息,並允許最終用戶以某種方式與它們交互,對吧?針對給定業務流程創建定製收件箱或完成協作任務(需要多個審覈/批准步驟,實例)的典型場景。 在這些情況下,我所做的就是使用某些SPA框架(Angular/Ember /等)創建自定義UI,並通過REST調用直接向Activiti使用所有後端信息,而無需直接後端集成。 –

回答

0

我認爲將Activiti Explorer集成到iframe中並不是一個好主意。由於您的用戶名和密碼是暴露的!前端的要求各不相同。

我最初喜歡Activiti Explorer,Modeler真的是awesone!但是我使用Rails,後來很難定製和集成Activiti Explorer。我嘗試與Activiti REST集成,但我更喜歡Activiti Java API,原因如下:

  1. Activiti REST是Activiti Java API的子集。例如:SetProcessDefinitionVersionCmd在Activiti REST中不可用。
  2. 性能問題。我開發了一個任務網頁,但它需要超過10個http請求。
  3. 我喜歡Acitivi Modeler和圖表查看器。我需要Activiti Explorer運行並使它們一起工作。

因此,我開發了一個名爲jruby_activiti的gem,它集成了Activiti Engine,Modeler和Diagram Viewer。所有這些都可以在JRuby on Rails中獲得!希望我的經歷可以幫助你。