Flex - Session like variable ?

hi all,
Is there a way to store a valriable in flex?( like a session in java/php).
I am doing flex& Java integration but i need to store variable(var username:String in login page) in flex application.
And I need to access user name in other pages also.And I need to get username from login to other components.I dont need to do cross cutting.that mean one component acess other component.but i need to do it in loosly couple manner..
Can Anyone have sugessions?Any respones are appreciated...
thnx

Finally myself found the solution...
and this is the solution,read it.
http://en.wikipedia.org/wiki/Singleton_pattern
http://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Singleton_UML_class_diagram.svg/2 50px-Singleton_UML_class_diagram.svg.png
Using a singleton class we can store value without crosscutting access and promoting component architechture.We can store any number of data fields in singleton class.
* note that: we cant create private constructors in flex
So the solution is singleton class

Similar Messages

  • Session member variable usage

    I want to keep client-specific information for each incoming connection, but i heard it cannot be done with session variable. i read in a book that session variables in a servlet (or scriptlet section of a jsp page) are shared among all incoming threads (therefore all clients) accessing the servlet.
    I guess a simple example of what i want to acheive is a shopping cart, but keeping the shopping cart order in a session-like variable specific to the original client machine/user who placed the order.
    I thought of doing something like:
    request.getSession().setAttribute("ShoppingCart", cart);
    inside my doGet() method in a servlet. And a book author says it won't work. He says ff I use a member to keep information about user1, sometimes the session variable may be overwritten by user2 if they are accessing the servlet at the same time.
    1) Can someone confirm whether session variables are shared among all incoming requests to the same servlet?
    2) If so, how can i easily keep track of incoming user/client mahcine-specific information, without using cookies or other client-side storage methods.
    3) If client side storage is necessary (to keep user info), what are the common techniques and the classes used?
    I am fairly new to j2ee so i would appriciate it if you can explain in layman's terms.

    Hi,
    Session scope is made to save the user specific information only. All class(servlet) level members(state) can be shared by all incoming thread. So its a bad practice, if we used class level session variable which stores the client specific info.
    I dont think session will overwritten if you used session var locally(inside any method).
    When any user logs in you should create a new session for that user.
    Means if you have LoginServlet.java file which have log in functionality, Here only you need to create new session.
    HttpSession session = request.getSession();
    Other than this file every where you need to use
    request.getSeission(false);
    In your case it would be
    request.getSession(false).setAttribute("ShoppingCart", cart);
    Hope This will help you.

  • Session-scope variable for JSP page used in a frame

    Hi,
    I don't know if there's a way to do this at the same time:
    (1)- assign session scope to a variable (in order to be able to retrieve recurrently the previous value each time the JSP is called);
    (2)- set its visibility in a way that it could be accessed only by the page that defines it. The JSP is used in a frameset along with an other JSP that can potentially define identical session-scoped variable (You understand why I want to keep them separate)
    session.setAttribute():
    seems not to be the thing I need
    pageContext.setAttribute():
    with SESSION_SCOPE, it behaves the same way as session.setAttribute(). with PAGE_SCOPE, condition (1) can't be satisfied.
    Does anybody have an idea ?
    Thanx in advance.

    I can see that you will not want to maintain two different files for every possible page on the site!
    It may be possible to do something like <frameset rows="*" cols="50%,*">
      <frame name="content1" src="file.jsp?frame=one" >
      <frame name="content2" src="file.jsp?frame=two" >
    </frameset>and then in the jsp<%
    String frame=request.getParameter("frame");
    session.setAttribute(frame+"AttributeName",attributeValue);
    %>This will set up two session attributes - "oneAttributeName" and "twoAttributeName". Depending on how many variables you have, this may prove just as difficult to maintain.
    You may end up having to simply pass url parameters between pages to maintain state within the individual frames, which is far from elegant also.
    I am interested in how you end up solving this one.

  • Flex Session implementation in Java

    Hi
    I am new to Flex. I have requirement like "store and retreiving a value in FlexSession instead of passing it to UI". The application in which I am working is an existing application where the value which I mentioned is generated from a service call and storinand reteiving it inside a DB. I neeed to modify it  so that it should be from Flex Session.
    I tried using FlexContext.getFlexSession().setAttribute("abc","value");
    But while retreiving through  FlexContext.getFlexSession().getAttribute("abc") it is returning null.
    Could somebody help in finding a solution for this. It is urgent.

    Thanks for your reply Claudiu. FlexContext comes from flex-messgaing-core.jar and I don't think it is a custom class. And my issue got solved . I think I missed the below entry in web.xml,
    <!-- Http Flex Session attribute and binding listener support -->
     <llstener>
    <listener-class>flex.messaging.HttpFlexSession</listener-class>
    </llstener>

  • Session scope variables and weird behaviour of AdfContext()

    Hello,
    what is the best method and correct API to create a session scope variable?
    I am currently using ADFContext().getCurrent().getSessionScope().get()/put(), but it looks like it has some problems: for some unkown reasons I loose the variable, that is get() returns null when called from a method of a (overridden)ViewRowImpl. Why does this happen?
    Thanks you in advance

    There are a couple of ways you can set values on a sessions scope but I would have to question if you really need a scope as high as session to accomplish what you want to do. At any rate, you should be able to store the value using the method you described but you could also try setting it using EL by using the setExpressionValue and resolveExpression methods in JSFUtils.java (you can find this in the latest fusion demo application). JSFUtils also has a getFromSession and storeOnSession that you could try.
    With all that said I don't think it is good practice to access scope variables from your model layer. You should write your method in the ViewRowImpl class to accept the value as a method parameter and then pass the value in through the binding layer or when invoking the method from your bean class.

  • [svn:bz-4.6.x] 23962: Bug#3200562: New Flex Session Id generated while disconnect with streaming amf channel

    Revision: 23962
    Revision: 23962
    Author:   [email protected]
    Date:     2012-06-15 04:57:45 -0700 (Fri, 15 Jun 2012)
    Log Message:
    Bug#3200562: New Flex Session Id generated while disconnect with streaming amf channel
    While invalidating session, make sure a new one does not get created.
    Modified Paths:
        blazeds/branches/4.6.x/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoin t.java

    I thought the same that those devices simply are too old. However I would like to know what causes this capabilities change. We want to get rid of the old H/W, but at the moment it looks as if we would need to revert back to the 4402 in order to get those things working again.
    I have not enough information, but those devices are some kind of handhelds. Their MAC OUI belongs to Newport Electronics.
    Regards,
    Patrick

  • Different ways to referencing Session State variables

    Hi,
    According to APEX documentation there's 4 different ways to reference session state variables: http://download-west.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32471/concept.htm#BEICHBBG
    In an inline PL/SQL statement, what's the difference when using the different methods? I remember reading something that the bind and static text have a size restrictions. What's the difference between the V() and NV() functions?
    Thank you.
    Martin

    Martin,
    In PL/SQL, the preferable method is to use bind variable notation, e.g., :P1_ITEM. In HTML contexts, you must use &ITEM. notation. In stored procedures, you can use v or nv, the latter function being identical to the former with the additional characteristic that it raises an exception if the retrieved value is non-numeric.
    Scott

  • Flex session replication among cluster Help needed!

    Hi,
    I'am using Flex 3, LiceCycle Data Service 2.5.1, JBoss 4.2.1 in a web application. Our JBoss servers are in a cluster. We want to replicate Flex session among cluster, but it doesn't work. Did someone face issue with Flex session replication among application servers?
    Thank you for your help
    Gerard

    Gerard,<br /><br />You will need to cluster the LCDS 2.5.1 instances the same way you clustered <br />JBoss.<br /><br />Check out the "Configuring Data Services" chapter in the Admin guide:<br />http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcds/services_config_4.html<b r /><br />--<br />Tom Jordahl<br />Adobe<br /><br /><br /><[email protected]> wrote<br />> Hi,<br />><br />> I'am using Flex 3, LiceCycle Data Service 2.5.1, JBoss 4.2.1 in a web <br />> application. Our JBoss servers are in a cluster. We want to replicate Flex <br />> session among cluster, but it doesn't work. Did someone face issue with <br />> Flex session replication among application servers?<br />> Thank you for your help<br />><br />> Gerard

  • Session state variables across multiple ApEx applications

    We have a suite of loosely integrate ApEx applications that all share a common authentication scheme. When you first log in we attempt to load a series of session state variables with temporary data to streamline various logging and authentication related activities for the life of the session.
    However, these session variables seem to disappear when you move from one application to another, so they are not truly tied to just the "session" which carries over across all applications, but the application from which the session state is set.
    What is the suggested way, keeping in mind that the data being held may have security related context, to preserve values during a session, but regardless of which ApEx application you are in.
    The method we are using to share the authentication is using a common "Cookie Name" from a common subscribed authentication scheme as suggested elsewhere on this site and seems to work very well outside of this specific issue.
    Thanks in advance,
    Barney

    Apologies for the delay getting back on this.
    My use of the word "disappear" was probably misleading. They were not visible from the second application. When setting "Session State" I was under the impression that it was setting it for the authenticated session, not for the specific application. (I am referring to the: apex_util.set/get_session_state).
    Your solution will work fine, as long as I know which application the user last authenticated against. However, it could be one of over 30 (and growing) different applications which would require me writing a program to go through every "p_flow" to try and find a valid value every time I need to reference the field.
    It would be really beneficial if you could store true Session variables which stay alive for the life of the authenticated session and is available to anything authenticated against that session id. This would streamline alot of cross-application program development.
    The "get/set_session_state" is a misleading as it is not a Session value, but an Application value. The Session exists across multiple applications, while this procedure does not.
    Thanks,
    Barney

  • Coldfusion session/client variables?

    We have multiple users using VPN to get to our intranet.  When the second user gets on they get the first person's session/client variables?
    I have tried looking for the session/client variables and where they are stored but I can't seem to find them.  I have tried searching out the cookies.
    I would appreciate any help.

    There are not too many people on this forum that have dabbled with ColdFusion. I used to, but that was more than one decade ago.
    Your best bet on getting assistance with your problem, is to go to the ColdFusion forum.

  • Jsf session scope variables

    Hi All,
    How to set a variable which should be available throughout the session, I dont want to use session scoped managed beans for this.
    Using the following method is not working
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("variableName","value");is there any other way to set session scoped variables ?

    Got it working
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("variableName","value");This will make the variable session scoped
    Regards,
    Sai Krishna

  • Store Session scoped variable in RequestScoped FormHandler?

    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

    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

  • Is Flex Session Tracking browser compatible?

    I have implemented Flex Session Tracking it works fine with
    Internet Explorwer browser but it does not work with Mozilla? Is it
    not browser compatible?

    Is it possible for you to send me your session tracking
    codes, bcoz im also doing session tracking.
    thanks

  • Flex session using blazeds?

    Hello,
    Need help on managing the Flex session using blazeds. If source is available, it would help a lot.

    Hi saisri2k2,
    Instead of making use of Server side session you can make a logic of your own at the client side itself by making use of the FlexEvent.IDLE and doing the appropriate action accordingly.
    You can google for the FlexEvent.IDLE  keyword. So if the user stays idle for a particular time you can register a check in the eventListener registerd for FlexEvent.IDLE and navigate or redirect user to another page.
    Thanks,
    Bhasker

  • [svn:bz-4.0.0_fixes] 23961: Bug#3200562: New Flex Session Id generated while disconnect with streaming amf channel

    Revision: 23961
    Revision: 23961
    Author:   [email protected]
    Date:     2012-06-15 04:42:44 -0700 (Fri, 15 Jun 2012)
    Log Message:
    Bug#3200562: New Flex Session Id generated while disconnect with streaming amf channel
    While invalidating session, make sure a new one does not get created.
    Modified Paths:
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPE ndpoint.java
    Property Changed:
        blazeds/branches/4.0.0_fixes/modules/

    You're trying to do this directly in ActionScript without using Flex, correct?
    The mxmlc compiler for Flex adds some registerClassAlias calls to map types between the client and the server. This will be missing if try to use the messaging code outside of a Flex app.
    Take a look at the mx.utils.RpcClassAliasInitializer class in rpc.swc. This has a static registerClassAliases method that will do the class registration for you. You should just need to call this before running your messaging code.
    -Alex

Maybe you are looking for