0
我需要你的幫助! 我有一個jsf應用程序,現在有2個版本 - 一個用於移動設備,一個用於桌面瀏覽器。桌面頁面位於文件夾/ html,移動設備 -/html/mobile。我想要一個結果決定要顯示的頁面 - 從/ html還是從/ html/mobile。
我創建會話屬性isMobileBrowser - 這表明我有什麼瀏覽器。jsf從一個結果導航到diff viewId
Boolean isMobileBrowser = (Boolean) session.getAttribute("isMobileBrowser");
if (isMobileBrowser == null) {
Enumeration e = req.getHeaders("user-agent");
while(e.hasMoreElements()) {
String str = e.nextElement().toString().toLowerCase();
if (str.indexOf("mobile") != -1) {
isMobileBrowser = new Boolean(true);
System.out.println("MOBILE BROWSER");
} else {
isMobileBrowser = new Boolean(false);
System.out.println("STANDARD BROWSER");
}
session.setAttribute("isMobileBrowser", isMobileBrowser);
}
}
,現在我想事端這樣的:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>clientadmin</from-outcome>
// if mobile
<to-view-id>/html/mobile/clientadmin.jsf</to-view-id>
// if desktop
<to-view-id>/html/clientadmin.jsf</to-view-id>
</navigation-case>
</navigation-rule>
如何我可以做的更好。我找出了NavigationHandler,但不明白它是如何工作的。我也嘗試在XML中的條件 - 但我不認爲他們的工作(我使用jsf 2.0)。
任何幫助將是greate!謝謝!