2011-10-26 75 views
1

我在視圖範圍內有一個支持bean Authority,我有兩個頁面viewRoleseditRole映射到此支持bean。在從一個頁面導航到另一個頁面(View Scope)的情況下設置backing bean中的屬性

viewRoles頁面有一個鏈接轉到editRole頁:

<h:form> 
    <h:commandLink value="#{au.displayName}" action="pretty:editRole"> 
    <f:setPropertyActionListener target="#{authority.authorityId}" value="#{au.id}"/>     
    </h:commandLink> 
</h:form> 

它導航到另一個頁面,但物業是沒有得到設置,即使bean是視圖範圍和這兩個頁面都映射到相同的支持bean。它僅在將視圖範圍更改爲會話範圍時才起作用。

注意:我的bean是由Spring管理的,這個視圖範圍不是JSF默認的@ViewScoped,這是我在http://cagataycivici.wordpress.com/2010/02/17/port-jsf-2-0s-viewscope-to-spring-3-0/上找到的一個自定義的。另外我使用PrettyFaces來管理我的導航。

問題是,上述情況應該與真正的JSF2 @ViewScoped@ManagedBean一起使用還是與Spring或其他問題有關的問題? 請指教。

+0

同樣的問題張貼在http://ocpsoft.com/support/topic/setting-property-in-backing-bean-同時,導航,從一個頁面到另一個 – Arjan

回答

5

沒有,這也將不與JSF2 @ViewScoped豆工作。你基本上是導航到不同的看法。當你正在與相同視圖通過返回的操作方法nullvoid交互的@ViewScoped豆的生活,只要。在結合<f:viewParam>目標視圖中的命令鏈接使用<f:param>應該這樣做。

E.g.在命令鏈接:

<h:form> 
    <h:commandLink value="#{au.displayName}" action="pretty:editRole"> 
    <f:param name="authorityId" value="#{au.id}"/>     
    </h:commandLink> 
</h:form> 

,並在目標視圖:

<f:metadata> 
    <f:viewParam name="authorityId" value="#{authority.authorityId}" 
     required="true" requiredMessage="Invalid page access. Please use a link from within the system." 
    /> 
</f:metadata> 
相關問題