Uploaded image for project: 'Spring Web Flow'
  1. Spring Web Flow
  2. SWF-1512

Accessing a local variable in a JSF view resolves to flowScope variable instead.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Works as Designed
    • Affects Version/s: 2.3.0
    • Fix Version/s: None
    • Component/s: JSF

      Description

      I was developing an application which manages a list of subjects, the main entry point flow renders a list of subjects and the user is able to view and edit subjects.

      The JSF contained the following fragment:-

      <p:dataTable var="subject" value="#{subjects}">
          <f:facet name="header">
              Subjects
          </f:facet>
          ...
      </p:dataTable>
      

      The flow definitions are follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <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">
      	
      	<!-- the main entry state for the subject flow -->
      	<view-state id="index">
      		<on-render>
      			<set name="flowScope.subjects" value="subjectBean.findAll()" />
      		</on-render>
      
      		<!-- view a subject -->
      		<transition on="view" to="view">
      			<set name="flowScope.subject" value="subjectBean.find(requestParameters.id)" />
      		</transition>
      
      		<!-- create a subject -->
      		<transition on="create" to="edit">
      			<set name="flowScope.subject" value="subjectBean.create()" />
      		</transition>
      
      		<!-- edit a subject -->
      		<transition on="edit" to="edit">
      			<set name="flowScope.subject" value="subjectBean.find(requestParameters.id)" />
      		</transition>
      
      	</view-state>
      
      	<!-- view subject state -->
      	<view-state id="view" />
      
      	<!-- edit subject state -->
      	<view-state id="edit" />
      
      	<end-state id="finish" />
      
      </flow>
      

      When I enter the flow a list of subjects is correctly populated on the screen. However, if I select a particular subject and then hit the back button, the list contains the name of the selected subject. This is occurring because my flow is using the flowScope variable "subject" and my view is also using a variable called "subject" (the dataGrid var attribute), the resolver is oddly resolving the value to the flowScope variable in the page and not local var variable which dataGrid should have created.

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            arshadm Arshad Mahmood
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: