2 Replies Latest reply: Jul 18, 2013 6:24 PM by Gopinath Ramasamy RSS

    Store Session scoped variable in RequestScoped FormHandler?

    VISHNU_95

      Hi All,

       

       

      I need to store a value into session scoped variable in formHandler. Is it possible? For Example, i need to no.of times handleApplyShippingGroups is being called by a User (Session scoped) and write a condition based on that value whose effect is to that User only? But, ShippingGroupFormHandler's scope is "Request"? How to get through this?

       

       

      Thanks,

      VishnuVardhan

        • 1. Re: Store Session scoped variable in RequestScoped FormHandler?
          Praveer.Rai

          Hi ,

           

          There is no issue in that , request scoped components can refer session scoped components.

           

          Just create a new session scoped component , or add a property to existing session scoped component like profile , simply update this value whenever handleApplyShippingGroups is invoked , and in your formhandler inject this value.

           

          ```

          Praveer

          • 2. Re: Store Session scoped variable in RequestScoped FormHandler?
            Gopinath Ramasamy

            Hi,

             

            You can use the below logic.

             

            In ShippingGroupFormHandler.properties

            $class = your.custom.Shippinggroup.fomhandler

            profile=/path/to/your/profile/component

             

            In YourShippingGroupFormHandler.java

             

            Inside handleApplyShippingGroups(),

            //increment the value

            getProfile.setApplySgCallCount(getApplySgCallCount()++);

             

            Before that, add the property - applySgCallCount -  to your profile with getter and setters.

             

            Hope this helps.

            Please keep posting the issues / updates.

             

            Thanks,

            Gopinath Ramasamy