Announcement Announcement Module
Collapse
No announcement yet.
Data entered is not visible on another screen Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Data entered is not visible on another screen

    Hi,

    I have 2 flows in my sample application. (1) Login (2) Adhoc. Login Flow is shown below. On login we redirect the flow to another flow “adhoc”. Now from adhoc screen, I want to display the entered user name. But user name is shown as “blank”. Please suggest how to display the user name.

    Also, buttons are not visible on screen. Any clue will be greatly appreciated.

    Code:
    Login-flow.xml
    
    <?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">
    	
    	<var name="user" class="za.coclient.UserBean"/>
    	<view-state id="LoginMain" model="user" view="login.xhtml">
    		<transition on="login" to="complete" />
    	</view-state>
    	
    	<end-state id="complete" view="flowRedirect:adhoc" />
    	
    </flow>
    Code:
    Login.xhtml
    
    <!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:c="http://java.sun.com/jstl/core"
    				xmlns:sf="http://www.springframework.org/tags/faces"
    				template="/WEB-INF/layouts/standard.xhtml">
    
    <ui:define name="content">
    
    <h1>Login Required</h1>
    
    <div class="section">
    	<h:form id="loginform">
    		<fieldset>
    			<div class="field">
    				<div class="label"><h:outputLabel>GCN:</h:outputLabel></div>
    				<h:inputText id="username" value="#{user.username}"></h:inputText>
    			</div>
    		
    			<div class="buttonGroup">
    				<sf:commandButton id="logon" value="Login" processIds="*" action="login" />
    			</div>
    		</fieldset>
    	</h:form>
    </div>
    
    </ui:define>
    </ui:composition>
    Code:
    Adhoc-flow.xml
    
    
    	<var name="adhoc" class="za.co.payment.adhoc.AdHocPaymentManagedBean"/>
    	
    	<view-state id="AdhocMain" model="adhoc" view="adhocPayment.xhtml">
    		<transition on="submit" to="confirm" />
    	</view-state>
    	
    	<view-state id="confirm" model="adhoc" view="adhocPaymentConfirm.xhtml">
    		<transition on="confirm" to="finish" />
    	</view-state>
    		
    	<end-state id="finish" />
    
    </flow>
    Code:
    adhocPayment.xhtml
    
    <!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:c="http://java.sun.com/jstl/core"
    				xmlns:h="http://java.sun.com/jsf/html"
    				xmlns:f="http://java.sun.com/jsf/core"
    				xmlns:sf="http://www.springframework.org/tags/faces"
    				xmlns:rich="http://richfaces.org/rich"
    				template="/WEB-INF/layouts/standard.xhtml">
    
    <ui:define name="content">
    	<h:form id="AdhocMain">
    	
    		<fieldset>		
    			<div class="label">
    				Welcome #{user.username}
    			</div>
    			<div class="field">
    				<div class="label"><h:outputLabel>From Account No:</h:outputLabel></div>
    				<h:inputText id="fromaccountno" value="#{adhoc.paymentFrom}"></h:inputText>
    			</div>
    		
    			<div class="buttonGroup">
    				<sf:commandButton id="logon" value="Continue" processIds="*" action="submit" />
    			</div>
    		</fieldset>		
    
    	</h:form>
    </ui:define>
    </ui:composition>
    Thanks in advance.

    Regards,

    ssroy

  • #2
    1) First part is still not sorted i.e., displaying the username on another screen. Any help will be greatly appreciated.

    2) Regarding second point - "commandbutton" is not displayed on the screen -What I have observed is that if I remove following DOCTYPE declaration from XHTML than button is displayed but if I add the declaration button is not displayed. Any clue will be greatly appreciated.

    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Comment


    • #3
      Unless I'm mistaken, when you're using JSF with SWF, you don't need to deal with the model attribute of the view-state. Just reference and bind your beans normally. If you need to validate your bean on transition, add an evaluate action inside the transition element to call your bean's evaluate method.

      Now, keep in mind that your username is stored in your "user" bean, which is in flow scope because of the location of your var element.

      When you issue a flow-redirect, it ENDS the current flow and conversation, wiping out attributes in these scopes, and starts a new conversation with a new top-level flow.

      If you want to preserve conversation or flow-scoped objects over a flow-redirect, you'll need to pass them in some way. My recommendation is, in your end-state, to place your objects in requestScope or sessionScope so you can retrieve them from your adhoc flow.

      Comment


      • #4
        Thank you very much. I will try the way you have suggested.

        Regarding display of commandbutton dependency on DOCTYPE declaration - Any clue will be really helpful. As I understand XHTML DOCTYPE declaration should be added in .XHTML file. But if I add, commandbutton is not visible.

        Thanks again - ssroy

        Comment

        Working...
        X