Announcement Announcement Module
Collapse
No announcement yet.
How to store an enum in scope? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #3
      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"/>
      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.

      Comment


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

        Comment

        Working...
        X