I have an JSF application that uses Spring Web Flow for navigation. Each time the user navigates to the accounts view from another view a piece of code should be executed. For the accounts view I have a managed bean called accountsBean. I thought of calling a initView method from the bean on flow entry. It throws a PropertyNotFoundException because accountsBean is not recognized by Spring.
WEB-INF/flows/accounts-flow/flow.xml
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<view-state id="accounts" view="accounts.xhtml">
<on-entry>
<evaluate expression="accountsBean.initView()"></evaluate>
</on-entry>
</view-state>
</flow>
EDIT1:
A part of my application manages accounts and groups. The user navigates between different parts of the application using a menu. Spring Web Flow is used to link the navigation from a menu item to a certain view. The accounts view contains a datatable, some buttons for CRUD operation and a select box for choosing the type of accounts. Different accounts are displayed depending on their type. The datatable columns are dynamic. The user can activate or deactivate a certain type. Now the user has to logout to see the account types modification. I need to make it work without the need of a logout.
EDIT2: I have changed the flow definition to:
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="accountsFlow" class="com.acme.accounts.AccountsFlow" />
<view-state id="accounts" view="accounts.xhtml">
<on-entry>
<evaluate expression="accountsFlow.initView()"></evaluate>
</on-entry>
</view-state>
</flow>
AccountsFlow is annotated with org.springframework.stereotype.Component
. Inside initView method some code from accountsBean
is executed. This works for SessionScoped
beans, but the solution proposed by BalusC is better.