This discussion is archived
2 Replies Latest reply: Jul 18, 2013 4:24 PM by GopinathRamasamy RSS

Store Session scoped variable in RequestScoped FormHandler?

VISHNU_95 Newbie
Currently Being Moderated

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 Journeyer
    Currently Being Moderated

    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?
    GopinathRamasamy Journeyer
    Currently Being Moderated

    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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points