Results 1 to 4 of 4

Thread: How to store an enum in scope?

  1. #1
    Join Date
    Oct 2009
    Posts
    23

    Default How to store an enum in scope?

    Some of my use cases rely on certain records being created or updated when the session is started or ended. Some output documents will also be generated here.

    This code is in a FlowExecutionListener, and here I rely on the flow storing an enum in flowScope.

    I know how to create and use enums in Spring, but I don't know about webflow and what I've tried isn't working.

    I'm hoping to avoid having to define a bean for each enum value, can I assign an enum value to a variable either using "var" or with "evaluate expression"?

    Or any other ideas?
    I'm using the enum value to determine which use case specific bean to return to the listener. This bean will have access to all sorts of DAO type services that will not be serializable so I cannot store the bean itself in scope.

  2. #2
    Join Date
    Oct 2009
    Posts
    23

    Default

    What I've done for now is to have a constants class define the Integer values, this class is the defined as a spring bean.
    Then a helper class takes in the Integer and stores the enum in scope.
    Of course, I could just store the Integer, and later get the enum for the Integer. 6 of one and half a dozen of the other.

  3. #3

    Default

    Personally, I think "evaluate expression" is a better choice. It provides a lot of more flexibility. In my code, I always avoid expose real data to the flow definitions.

    The below code should work.
    Code:
    public class Flag implements Serializable{
      private EnumType enumValue;
    
     // getters and setters
    }
    
    public class YourAction{
    
      public Flag setFlag(){
       // you logic for creating or setting flags.
       // and whatever you want to do
      }
    }
    
    <evaluate expression="yourAction.setFlag()" result="flowScope.flag"/>
    Quote Originally Posted by Taariq View Post
    Some of my use cases rely on certain records being created or updated when the session is started or ended. Some output documents will also be generated here.

    This code is in a FlowExecutionListener, and here I rely on the flow storing an enum in flowScope.

    I know how to create and use enums in Spring, but I don't know about webflow and what I've tried isn't working.

    I'm hoping to avoid having to define a bean for each enum value, can I assign an enum value to a variable either using "var" or with "evaluate expression"?

    Or any other ideas?
    I'm using the enum value to determine which use case specific bean to return to the listener. This bean will have access to all sorts of DAO type services that will not be serializable so I cannot store the bean itself in scope.

  4. #4
    Join Date
    Oct 2009
    Posts
    23

    Default

    That's what I meant I did, thanks.
    Code:
    <evaluate expression="txanWebFlowHelper.storeTransactionType(
    flowRequestContext, auditConstants.LT_TXAN_TYPE_CD_VEHICLE_LICENSING)"/>

Posting Permissions

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