[PrimeFaces + WbFlow] transit between views problem

UI Components for JSF
Post Reply
AndreaNobili
Posts: 13
Joined: 13 Oct 2011, 20:36

13 Oct 2011, 20:40

Hello,
I am very very new in Spring Web Flow...this is my first experience with it

I have some problem trying to transition from one view to another view:

I have do the following things:

I have created this directory that manage a flow in my project: /MyWebApp/src/main/webapp/WEB-INF/flows/secured/sservizzi/

and in this directory I have put 3 files:

1) flow.xml that manage the flow: into this file I manage 2 steps: the first step show a view that is named view.xhtml and the second step have to show an other view named riassunto.xhtml

Code: Select all

<?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"
	parent="parent-flow">

	<!--
		Also see ../parent-flow.xml. 
	-->

	<!-- Dichiara una variabile utenteBean di tipo specificato dall'attributo class -->
	<var name="utenteBean" class="com.sogeit.fids.webfids.model.UtenteBean" />

	<view-state id="view">
		<transition on="suggest" to="riassunto">
			<evaluate expression="utenteBean.metodoTest(flowRequestContext)"
				result="viewScope.risultato" />
			
		</transition>
	</view-state>
	
	<view-state id="riassunto"></view-state>

</flow>
2) view.xhtml: that render a simple PrimeFaces form that takes as input 2 strings (name and surname). In this view there is also a command button that clicked have to transient to the second view named riassunto.xhtml (as specified in the file flow.xml)

Code: Select all

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
	  			xmlns:p="http://primefaces.prime.com.tr/ui"
				template="/WEB-INF/layouts/fids-template.xhtml">

<ui:define name="title">Ajax With PrimeFaces CommandButton</ui:define>

<ui:define name="notes">
	<h5>Files to review:</h5>
	<p>
	  	Flow definition and view.xhtml in <span class="alt">src/main/webapp/WEB-INF/flows/ajax-primefaces</span><br/>
	  	Java class <span class="alt">~/ajax/UserBean.java</span>
	</p>
	<hr/>
</ui:define>

<ui:define name="content">
	<h:form>
	
		<h:panelGrid columns="4" cellpadding="5">
			
			<h:outputLabel for="nome" value="Nome:" style="font-weight:bold"/> 
			<p:inputText id="nome" value="#{utenteBean.nome}" /> 
			
			<h:outputLabel for="cognome" value="Cognome:" style="font-weight:bold"/> 
			<p:inputText id="cognome" value="#{utenteBean.cognome}" /> 
			
			<p:commandButton value="Suggest" action="suggest" execute="@form" update="@form"/>
			 
		</h:panelGrid>
		
		<h:outputText value="Ciao #{utenteBean.nome} #{utenteBean.cognome}" id="display" />
		
	</h:form>
</ui:define>

</ui:composition>
3) The second view is riassunto.xml that at this time only has to show an output string:

Code: Select all

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
	  			xmlns:p="http://primefaces.prime.com.tr/ui"
				template="/WEB-INF/layouts/fids-template.xhtml">

<ui:define name="title">Ajax With PrimeFaces CommandButton</ui:define>

<ui:define name="notes">
	<h5>Files to review:</h5>
	<p>
	  	Flow definition and view.xhtml in <span class="alt">src/main/webapp/WEB-INF/flows/ajax-primefaces</span><br/>
	  	Java class <span class="alt">~/ajax/UserBean.java</span>
	</p>
	<hr/>
</ui:define>

<ui:define name="content">
	
	<p>OUTPUT TEST</p>
		
</ui:define>

</ui:composition>
So I would like to happen the next thing: the user insert the name and the surname in the first view and when click the command button the second view (riassunto.xhtml) is show instead of the first one...

The problem is that when I click the suggest command button does not transit on the second view and continues to be displayed first view

Why? What's wrong? how can I fix this?

Thanks
Andrea

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests