2つの別々のプロジェクト(おそらく異なるサーバー)に2つのJSF/JSFページと関連付けられたマネージドBean PageA.jspとPageB.jspにBackingBeanA.javaとBackingBeanB.java別プロジェクト)別のプロジェクトでのJSFページ間のデータ転送
欲求は、以下を試みたPageB.jspにPageA.jspからリダイレクトとオブジェクト(FilterData)
を通過することである。
BackingBeanA.java
public String startPageB() {
try {
FilterData filterData = ...
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)
facesContext.getExternalContext().getRequest();
request.setAttribute("FILTERDATA",filterData);
ExternalContext externalContext = facesContext.getExternalContext();
externalContext.setRequest(request);
externalContext.redirect("http://localhost:8080/PageB/");
}
catch (IOException e) {
e.printStackTrace();
System.out.println(e);
}
return "redirectedData";
}
BackingBeanB.java(別のプロジェクトでは、別のサーバーすることができる)
public String getBeanAData() {
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)
facesContext.getExternalContext().getRequest();
FilterData newFilterData = (FilterData)
request.getAttribute("FILTERDATA");
... do stuff
return null;
}
結果:getBeanADataが呼び出され 、しかし: filterDataはBackingBeanAでnullではありませんでしたが、BackingBeanBにヌルだった - データがありませんでした転送されます。
このデータの受け渡しを正しく行う方法はありますか?
私は元の質問に含まれている必要があります: のTomcat 6.0.28は、(実行する必要がある
のJava 1.6.0_22-B03 JSF 1.2 JSTL 1.2 のEclipse 3.6.0(ヘリオス)また、WebLogic) IE 7.0.5730.13 Firefoxの上:3.6.12
試みは、純粋なJSF可能ならば、ノーHTTP所望の(しかし可能)、なしのJavaScript(期間)になることです。これは素晴らしい作品ということ
...
String ownerName = (String) FacesContext.getCurrentInstance().
getExternalContext().getRequestParameterMap().get("ValueB");
String itemId = (String) FacesContext.getCurrentInstance().
getExternalContext().getRequestParameterMap().get("ValueA");
...
結果は - リダイレクト先のWebページから
...
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
String initialUrl = externalContext.getInitParameter("RedirectUrl");
String requestDataA = "?ValueA=" + activity.getID();
String requestDataB = "&ValueB=" + activity.getName();
redirectUrl = initialUrl + requestDataA + requestDataB;
externalContext.redirect(redirectUrl);
...
- 親のWebページから
:私は(今のところ十分)問題を解決した方法
- 文字列の場合。これは今でもOKです。
可能であれば私は後でたいもの:
The same thing, but passing an object.
I know I cannot do that on the request line, but I thought there was a way
similar to a standard HTTP setup where a request attribute is set and the
destination page gets it with a doPost method (do I have this wrong?).
The BalusC answer indicates this is not possible.
So is it really not possible to have a JSF page redirect (starup or whatever)
to an external page, and pass it an object without going to shared storage?
おかげで、 ジョン
(ノート、私はあなたの代わりに
faces-config.xml
で<managed-property>
を必要とJSF 1.xのために、JSF 2.0を想定しています)あなたは、このように実際には "別のWebアプリケーションのコンテキストを" 意味ですか? – BalusC