2010-09-14 66 views
2

在我的JSF網站上,我有幾個要用於導航到我們的舊經典ASP站點的元素(沒有數據需要存活,只是簡單的導航) 。什麼是最好的方法來做到這一點?通過按鈕在JSF網站外部導航的選項

到目前爲止的想法: - 使用結果/導航規則意味着你要呆在同一個站點內。它可以用來在外面導航嗎?

回答

3

您無法爲此使用導航案例。使用h:outputLink和直接網址。

<h:outputLink value="http://google.com">Click</h:outputLink> 

或者只是普通的香草HTML。

<a href="http://google.com">Click</a> 

更新

一個<h:commandButton>也是可行的,但你必須添加一個bean的操作方法,其確實ExternalContext#redirect()到所需的URL。

public void submit() { 
    FacesContext.getCurrentInstance().getExternalContext().redirect("http://google.com"); 
} 

另一種方法確實是讓鏈接的樣式看起來像一個按鈕。這裏有一個開球例如:

a.button { 
    display: inline-block; 
    background: lightgray; 
    border: 2px outset lightgray; 
    cursor: default; 
} 
a.button:active { 
    border-style: inset; 
} 

使用它作爲<h:outputLink styleClass="button"><a class="button">

+1

有沒有辦法用按鈕來做到這一點?或者有沒有辦法讓元素看起來像一個按鈕?用戶設計要求是一個按鈕...: -/ – 2010-09-14 15:44:54

+0

與bean完美匹配!謝謝! – 2010-09-14 16:11:00

+0

不客氣。 – BalusC 2010-09-14 16:29:02