2010-11-19 46 views
0

我的Java EE應用程序我有文章管理。文章的意思是文章的ID,有http://localhost:8080/articles/detail.xhtml?article=70這樣的URL。此頁面顯示文章評論等,這不重要。但有按鈕編輯,我想在頁面edit.xhtml重定向,但用戶仍應該看到http://localhost:8080/articles/detail.xhtml?article=70,因爲我不希望編輯頁面可以收藏。帶參數的JSF 2.0重定向

你能幫我設置faces-config來改變頁面但不是url嗎?我認爲如果我不寫<redirect />那麼url會保持不變,但我錯了。網址從detail.xhtml?article=70更改爲detail.xhtml

感謝您的任何建議。

回答

2

我會建議引入一些ajaxical權力,以便不會觸發同步請求。

<h:panelGroup id="article" layout="block"> 
    <h:panelGroup rendered="#{!bean.editmode}"> 
     View article (can if necessary be an ui:include) 
     <h:form> 
      <h:commandButton value="Edit" action="#{bean.edit}"> 
       <f:ajax render=":article" /> 
      </h:commandButton> 
     </h:form> 
    </h:panelGroup> 
    <h:panelGroup rendered="#{bean.editmode}"> 
     Edit article (can if necessary be an ui:include) 
     <h:form> 
      <h:commandButton value="Save" action="#{bean.save}"> 
       <f:ajax render=":article" /> 
      </h:commandButton> 
     </h:form> 
    </h:panelGroup> 
</h:panelGroup> 

豆:

private boolean editmode; 

public void edit() { 
    this.editmode = true; 
} 

public void save() { 
    this.editmode = false; 
} 

public boolean isEditmode() { 
    return editmode; 
} 
+0

如果可能的話,看看http://stackoverflow.com/questions/4231206 – 2010-11-20 04:25:12