Announcement Announcement Module
Collapse
No announcement yet.
Accesing ActionForm from flow Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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, 04:59 PM.

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment

          Working...
          X