Results 1 to 5 of 5

Thread: Accesing ActionForm from flow

  1. #1

    Unhappy Accesing ActionForm from flow

    Hi all, I've just started using WebFlow and I can't access my ActionForm.

    I made an ActionForm and want to use one of the properties of it in another method (from a POJO Class). I'm trying using this code in my flow.xml file

    Code:
    <view-state id="addClient" view="/addClient.jsp">
              <entry-actions>
                  <action bean="userForm" method="setupForm"/>
              </entry-actions>
              <transition on="submit" to="makeDeposit">
              </transition>
       </view-state>
    	
    	<action-state id="makeDeposit">
    		<entry-actions>
            	<action bean="userForm" method="bind"/>
    		</entry-actions>
    		<action bean="service" method="deposit(${client.id}, ${client.amount})" />
    		<transition on="sucess" to="depositMade"></transition>
    		<transition on="error" to="authorizationNeeded"></transition>
    	</action-state>
    But ${client.id} is not a set property (I get a ognl Exception). I've also tried with flowScope.client and flowScope.id. I tried calling the exposeFormObject after the setupForm but it's the same.

    The ActionForm has Client.class as FormObjectClass and "client" as FormObjectName.

    This is the UserForm class


    Code:
    import org.springframework.webflow.action.FormAction;
    
    public class UserForm extends FormAction {
        public UserForm(){
            super.setFormObjectName("client");
            super.setFormObjectClass(Client.class);
        }
    }
    and the Client class

    Code:
    public class Client {
        String id;
        String amount;
    
        public String getAmount(){
            return amount;
        }
    
        public void setAmount(String amount){
            this.amount = amount;
        }
    
        public String getId() {
            return id;
        }
    
        public void setId(String id){
            this.id = id;
        }
    }
    Can anyone help me get access to my ActionForm from the flow?

  2. #2
    Join Date
    Aug 2004
    Location
    Duesseldorf, Germany
    Posts
    1,210

    Default

    Hi,

    If you expose your Client in FlowScope (which is default with the current cvs head of SWF) you should try:

    Code:
    ${flowScope.client.id}
    Cheers
    Christian
    Christian Dupuis
    SpringSource, a division of VMware
    Lead, SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/cdupuis

  3. #3

    Default

    Thanks. I didn't try that because I followed the javadoc comment which said that it was the default scope for RC1. I read this post today and found out that the Javadoc was wrong.

    I'll try it tomorrow morning and let you know.
    Last edited by Carlos Henriquez; May 21st, 2006 at 04:59 PM.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Quote Originally Posted by Carlos Henriquez
    Thanks. I didn't try that because I followed the javadoc comment which said that it was the default scope for RC1. I read this post today and found out that the Javadoc was wrong.

    I'll try it tomorrow morning and let you know.
    I think cdupuis is saying that you need to explicitly state where to retrieve the client object from; flowScope, conversationScope, requestScope, or probably more useful; model.

  5. #5

    Default

    I just tried it and it worked perfect. Thanks cdupuis. fallofrome was right. It is not the default scope so it has to be set manually despite of the javadoc comment

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •