Skip navigation
sara_bz
Currently Being Moderated

FlexSession and states

Mar 30, 2009 5:28 AM

Hello

I am a new user, so first of all: I am Sara, I'm italian and new to flex and actionscript development :)

I am trying to build an LDAP browser using Flex 3 and JavaEE (Tomcat, Java6, BlazeDS).
My application is composed by two mx:states, a login state and an application state accessible only if the user authenticates against out LDAP server.

The authentication part looks good: I create a RemoteObject that performs the various lookups in LDAP. Since I need to store LDAP environment informations, I create also a FlexSession object in which this information is stored.
Through the Tomcat SessionManager I can verify that the LDAP environmnet data are stored correctly.

At this point, I need to "populate" my main state, the authState, if the user is authenticated.
I want to show to the user some data regarding his LDAP entry, for example the principal. Using the same FlexSession class, in the login phase I add to the session some other data such as the user's principal string. The Tomcat session manager shows me that the attribute "principal" is not null, but the flex client does not retrieve this string.
While debugging I notice that the method by which the client should retrieve the string is not called. The flex client correctly calls the login() method but not the getPrincipal() method. If I try to call it directly from actionscript, for example

[Bindable]
public var princ:String = "EMPTY";
public function doLogin():void
{
if (session.login(txUsername.text, txPassword.text)){
princ = session.getPrincipal().lastResult as String;
lbWelcome.text = "Welcome, " + princ;
}
}

the client throws an exception because session.getPrincipal() returns a null object, BUT the attribute "principal" is populated in the session.login() method (and exists in the tomcat session).

My doubt is: is FlexSession bound to a specific mx:state? Should I retrieve the existing session in an other RemoteObject, and then try to call attributes in the retrieved session? And how?


Thanks in advance
Sara
 
Replies
  • Currently Being Moderated
    Jan 31, 2012 10:12 PM   in reply to sara_bz

    You have to write these statements in result hanlder. Coz, here you have just sent a request to server and in the next statement you are checking the result. At that time you will not get any result, actually some time will be spent to comeback from server.

     

    princ = session.getPrincipal().lastResult as String;

    lbWelcome.text = "Welcome, " + princ;

     

     

    So handle everything in coll back.

     

    <mx:RemoteObject id="Server" destination="ServerDestination" fault="faultHandler(event)">
       
    <mx:method name="getPrincipal" result="getPrincipalHandler(event)"/>
    </mx:RemoteObject>

     

    private function getPrincipalHandler(event:ResultEvent):void
    {
        princ
    = event.result as String;
    }

     

    Try this, and let me know your results or concerns...


     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)