一千萬個為什麽

搜索

如何使用ICEFaces進行導航並傳遞參數

我正在使用JSF/ICEFaces。我有一個表有很多行的值,我有另一個頁面顯示圖表。我想在每一行都有一個圖標來繪制特定的組合圖。我知道通過返回一個字符串導航規則來與JSF進行常規導航。但是,我不確定如何將參數從與該行對應的bean傳遞到執行制圖的bean。你知道我可以解決這個問題嗎?

謝謝,

最佳答案

So you have Page A with the table of stuff and Page B with charts of individual stuffs. Flow being: Navigate to Page A -> Look through the table -> Click something on Page A to look at charts -> Navigate to Page B -> Read Charts.

你可以在這裏做幾件不同的事情。我會建議三個。

One, you can make the chart page RESTful and pass in the ID of the stuff you're going to chart. IE, a column on your page would have:

Review Chart

然後在圖表頁面的支持bean中,可以使用JAX-RS傳遞頁面參數,也可以對請求對象進行挖掘,即:

(<�碼> FacesContext.getCurrentInstance()。getExternalContext()。getRequestParameterMap()。得到(“stuffID)</代碼>

您可以使用它來獲取StuffID並構建圖表。這實現了一個很好的問題分離,讓您的圖表頁面只需繪制圖表,而不必擔心將從哪個bean獲取圖表。這是親自做這件事的方式。

Two, you can simply make your bean session scoped (or, conversation scoped if you're using Seam or similar) so that the two pages simply share the one bean. This is probably the simplest but you will need to ensure that the bean is cleaned up when you no longer need it and thus, somewhat dangerous.

Three, you can use a regular HTTP form and POST to the charting page, using the same kind of RequestParameterMap dredging that you did for number one. This works the same way as number one but isn't quite as clean as you will need a similar form everywhere you want to do this and it cannot be a normal hyperlink.

這三個人會完成你所需要的,再一次,我的建議將是第一。能夠通過一個普通的超鏈接鏈接到圖表頁面可能會非常方便。

轉載註明原文: 如何使用ICEFaces進行導航並傳遞參數