Question

I am new to SWF and I unexpectedly inherited the maintenance of a SWF application.

The users have a horizontal menu at the top of the screen, in which 5 options appears. When one of them is clicked, a portlet is loaded in the screen.

Two days ago, I received a task: whenever a user clicks in one of these options, the portlet must disregard its previous state and start again.

Example: one of the portlets is called 'SEARCH' and the other 'REPORTS'. Today, if a user clicks 'SEARCH', the appl shows a little form and a 'GO' button. After clicking 'GO', the appl shows a list of results, each one with an edit button. After clicking to edit one of them, the appl shows the details of the result selected. So far, so good.

Proceeding the example, suppose the user now clicks in the 'REPORTS' option in the menu. The appl will show the report portlet, with its own contents. Again, so far, so good.

However, if the user now clicks again in 'SEARCH', the portlet will display its last state, that is, the edition of a previous searched item.

I was asked to alter this behavior, so each time a user clicks in 'SEARCH', it will open empty, that is, the portlet's webflow will start from the beginning again.

How can I do this? Could someone please help me?

I searched the documentation of SMF and also studied the spring-webflow-config-2.0.xsd file, looking for some specific configuration for this case, but to no avail.

Thanks,

FQL

Was it helpful?

Solution

Try this approach:

Create a new flow definition xml file where you should place a set of end-states that would redirect to a flow, and a set of global-transitions that would transition to an end-state. So you should add one end state and one global transition per menu item.

<end-state id="searchMenuItem" view="flowRedirect:searchFlowName" />

<end-state id="reportsMenuItem" view="flowRedirect:reportsFlowName" />    

<global-transitions>    
    <transition on="searchMenuItem" to="searchMenuItem" />      
    <transition on="reportsMenuItem" to="reportsMenuItem" />        
</global-transitions>

Add this flow definition to the flow registry and to all flows as parent. So that, all flows should have that end-states and global-transitions visible.

Edit menu links to use a global transition:

<a href="${flowExecutionUrl}&_eventId=searchMenuItem">Search</a>   
<a href="${flowExecutionUrl}&_eventId=reportsMenuItem">Reports</a>

This causes that when user clicks on a menu item, its global transition will fire causing a transition to an end-estate and a flow redirect to the desired flow.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top