2009-07-22 57 views
2

我想弄清楚如何在生命週期表單中創建一個超鏈接,該超鏈接指向將在表單呈現的不同日期更改的URL。例如在某一天我可能想的超級鏈接指向:Livecycle Form中的動態超鏈接

mywebsite /我的空間選項= XXX

,並在另一天我希望它指向:

mywebsite /我的空間?option = YYY

XXX和YYY可以很容易地作爲XML傳遞到表單的數據中,但我不知道如何製作它,以便超鏈接被更改爲與此相對應。

有什麼建議嗎?

回答

3

這可以用LiveCycle Designer中的JavaScript來完成。放置在表單的docReady事件中的以下腳本將允許您動態更改文本對象的URL。

form1::docReady - (JavaScript, client) 
// If this code is running on the server, you don't want it to run any code 
// that might force a relayout, or you could get stuck in an infinite loop 
if (xfa.host.name != "XFAPresentationAgent") { 

    // You would load the URL that you want into this variable, based on 
    // whatever XML data is being passed into your form 
    var sURL = "www.stackoverflow.com"; // mywebsite/mypage?option=xxx 

    // URLs are encoded in XHTML. In order to change the URL, you need 
    // to create the right XHTML string and push it into the Text object's 
    // <value> node. This is a super simple XHTML shell for this purpose. 
    // You could add all sorts of markup to make your hyperlink look pretty 
    var sRichText = "<body><p><a href=\"" + sURL + "\">Foo</a></p></body>"; 

    // Assuming you have a text object called "Text1" on the form, this 
    // call will push the rich text into the node. Note that this call   
    // will force a re-layout of the form 
    this.resolveNode("Text1").value.exData.loadXML(sRichText, false, true); 
} 

有幾個注意事項:Acrobat中的URL只在Acrobat 9.0和更高版本中受支持。因此,如果使用舊版Acrobat的用戶打開表單,這些網址將無法使用。另外,從「if(xfa.host.name!= ...)」行中可以看到,如果在服務器上生成表單,此代碼將無法正常運行,因爲強制重新啓動在docReady期間對錶單進行佈局可能會導致LiveCycle服務器的某些舊版本出現問題。如果你確實需要在服務器上運行這個腳本,你應該選擇一個不同的事件,然後形成:: docReady。

0

使用第三方組件處理PDF的超鏈接......希望有更好的解決方案,因爲這個解決方案的成本大約爲1000美元。

1

我在WorkSpace中的用戶抱怨說,點擊鏈接在同一個標​​籤中打開了他們,所以他們失去了WorkSpace表單,並且沒有選擇在Designer 11中進行更改。我認爲我爲此提出的解決方案也會爲你工作。

我做的按鈕,沒有邊界,沒有背景,並在其click事件有這條線(在Javascript中,在客戶端上運行)

app.launchURL("http:/stackoverflow.com/", true);

它會很容易地添加一些邏輯來選擇基於當天的正確URL,並且不會導致任何表單重新呈現。

在超鏈接符合其他文本的某些位置,我將鏈接的文本留爲藍色並加下劃線,但沒有超鏈接,只需將按鈕(無背景,無邊框,無標題)放在其上。需要定位和不流動子表單才能工作,所以根據您的佈局,它可能會變得笨重。

哇,剛剛意識到我對晚會太晚了。那麼,對於任何使用ES4的人都面臨類似的問題。 。 。