Client side code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="horizontal">

   <mx:TextInput id="iptUser" />

   <mx:RemoteObject id="setService" destination="setsession"
       result="handleSetResult(event)" fault="handleFault(event)">
   </mx:RemoteObject>

   <mx:RemoteObject id="getService" destination="getsession"
       result="handleGetResult(event)" fault="handleFault(event)">
   </mx:RemoteObject>

   <mx:Button label="Invoke setSession()">
       <mx:click>
        <![CDATA[
         setService.setUser(iptUser.text);
        ]]>
       </mx:click>
   </mx:Button>

   <mx:Button label="Invoke getSession()" click="getService.getUser()" />

   <mx:Script>
    <![CDATA[
     import mx.controls.Alert;
     import mx.collections.ArrayCollection;
     import mx.rpc.events.FaultEvent;
     import mx.rpc.events.ResultEvent;

     public function handleSetResult(event:ResultEvent):void{
        Alert.show(event.result.toString());
     }

     public function handleGetResult(event:ResultEvent):void{
        Alert.show(event.result.toString());
     }

     public function handleFault(event:FaultEvent):void{
      trace('handleFault()');
         trace(event.fault);
     }
    ]]>
   </mx:Script>
</mx:Application>
----------------------------------------------
Put this Remoting-config file in blazeds
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
    class="flex.messaging.services.RemotingService">
    <adapters>
        <adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true"/>
    </adapters>
    <default-channels>
        <channel ref="my-amf"/>
    </default-channels>


    <destination id="setsession">
       <properties>
          <source>remoting.SessionMgt</source>
       </properties>
    </destination>

    <destination id="getsession">
       <properties>
          <source>remoting.TestSession</source>
       </properties>
    </destination>

</service>
--------
ServerCode
--------------
package remoting;
import flex.messaging.FlexContext;
import flex.messaging.FlexSession;
public class TestSession {
   FlexSession session;

   public TestSession(){
    session = FlexContext.getFlexSession();
   }

   public String getUser(){
    System.out.println(session.getId());
    return (String)session.getAttribute("user");
   }

}
second file
-------------
package remoting;
import flex.messaging.FlexContext;
import flex.messaging.FlexSession;
public class SessionMgt {
    FlexSession session;

 public SessionMgt(){
  session = FlexContext.getFlexSession();
 }

 public String setUser(String username){
  session.setAttribute("user", username);
  System.out.println(session.getId());
  return "Written to Session";
 }
}

On Thu, Jul 29, 2010 at 6:53 AM, Abdul <[email protected]> wrote:

> Hi,
>
> This may help for you..
>
>
> http://www.solutionhacker.com/data-intelligence/data-visualization/flex-remoting-and-session-management/
>
>
>
>
> On 29 July 2010 13:03, Sarma <[email protected]> wrote:
>
>> Hi to all,
>>
>>
>>  How to maintain the flex session in flex application. If have any
>> examples please forward to me.
>>
>>
>> Thanks & Regards,
>> M R R Sarma
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Flex India Community" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<flex_india%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/flex_india?hl=en.
>>
>>
>
>
> --
> *With Regards*,
> *Nizar.*
> *Disturb @ (+91) 9790503327*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<flex_india%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to