Announcement Announcement Module
Collapse
No announcement yet.
how to redirect to two differents page after button clic Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to redirect to two differents page after button clic

    Hello,

    I'm new developper in Spring Webflow and i want to redirect my page in same page or another page after button clic.

    The webflow code for this state is :

    Code:
    <view-state id="editEntity" model="entity">
    
    <!-- Action button -->
    <transition on="save" validate="false">
    	<evaluate expression="entityController.saveEntity(flowScope.entity)"/>
    	</transition>
    </view-state>
    How to add in this code this decision :

    Code:
    If saveEntity return 'true' , i'll redirect in other page 'moreDetail'.
    else leave at 'editEntity'
    Thank's for your help

  • #2
    You will have 2 transitions, based on the button click. Here is some sample flow code:

    <view-state id="step1" view="test-flow/step1">
    <transition on="save" to="save"/>
    <transition on="cancel" to="cancel"/> </view-state>

    The save and cancel are states in your flow. No need for code for this logic.

    If it's more of a "after enter date, if successfully saved, go to the save page, else, go back to the edit page", I would transition to an action state, and in there, based on the result, have those same two transitions.

    Hope this helps.
    Last edited by daveb1040; Oct 22nd, 2012, 11:17 PM.

    Comment


    • #3
      I've do this transition and i've this error :

      No transition found on occurence of event 'save' in state 'cloneChoice' of flow 'entitymngt/newEntity/cloneEntity'

      Code:
      <view-state id="editEntity" model="entity">
           <transition on="save" to="moreAnswersNeeded" />
      </view-state>
      
      <decision-state id="moreAnswersNeeded">
      		<if test="entityController.saveEntity(flowScope.entity)" then="answerClone"
      			else="saved" />		
      	</decision-state>
      
      
      <subflow-state id="answerClone" subflow="entitymngt/newEntity/cloneEntity">
      		<!-- <input name="entityClone" value="flowScope.entity" /> -->
      		<input name="entityClone" value="entityController.entityToSaved" />
      		<input name="clone" value="flowScope.clone"/>
      		<input name="nbTransaction" value="entityController.nbTransactionCloned"/>
      		<input name="nbDocument" value="entityController.nbDocumentCloned"/>
      		<transition on="clone" to="cloned" />
      		<transition on="quit" to="editEntity" /> 
      		<transition on="saved" to="editEntity" />
      	</subflow-state>
      code of subflow

      Code:
      <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">
      
      	<persistence-context />
      	
      	<input name="projectEdit" type="com.plasticomnium.optidoc.domain.model.entity.Project" />
      	<input name="create" type="boolean" />
      	
      	<decision-state id="editionChoice">
      		<if test="create" then="setUpForm" else="editForm" />
      	</decision-state>
      	
      	<!-- Setting up for creating a new project -->
      	<action-state id="setUpForm">
      		<evaluate expression="projectController.createProject()" result="flowScope.project" />
      		<transition on="success" to="projectEditForm" />
      	</action-state>
      	
      	<!-- Setting up for editing an existing project -->
      	<action-state id="editForm">
      		<set name="flowScope.project" value="projectEdit" />
      		<transition to="projectEditForm" />
      	</action-state>
      	
      	<!-- =========== -->
      	<!-- COMMON-EDIT -->
      	<!-- =========== -->
      	<view-state id="projectEditForm">
      	
      		<transition on="save" to="saved" validate="false" >
      			<evaluate expression="projectController.saveProject(flowScope.project)" />
      		</transition>
      		
      		<transition on="quit" to="quit" validate="false" />
      	</view-state>
      
      
          <!-- ========== -->
          <!-- END STATE  -->
          <!-- ========== -->
      	<end-state id="quit"/>
      	<end-state id="saved"/>
      	
      </flow>

      Comment

      Working...
      X