Expand my Community achievements bar.

How to access the request attributes ?

Avatar

Level 1
I´m including an swf (the compiled version of my mxml
page) in a jsp which is part of my Struts application, like this:



<embed pluginspage='
http://www.macromedia.com/go/getflashplayer'

width='750'

height='200'

src='
http://pc8251e:7001/samples/pruebasAle/chooser.swf'/>



This is the chooser.mxml



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"

layout="absolute"

creationComplete="{myClientillo.getList()}">





<mx:RemoteObject id="myClientillo"
destination="chooserProvider"

showBusyCursor="true" />



<mx:DataGrid height="200" width="750"
dataProvider="{myClientillo.getList.lastResult}" >

<mx:columns>

<mx:Array>

<mx:DataGridColumn dataField="id" headerText="Id"/>

<mx:DataGridColumn dataField="campo1"
headerText="Nombre"/>

<mx:DataGridColumn dataField="campo2"
headerText="Apellido"/>

</mx:Array>

</mx:columns>

</mx:DataGrid>



</mx:Application>



I' ve configured in the remoting-config.xml the Remote Object
chooserProvider like this:



<destination id="chooserProvider" >

<properties>

<source>samples.providers.ChooserProvider</source>

<scope>application</scope>

</properties>

</destination>



In the samples.providers.ChooserProvider.java, I want to
acces the attributes that are setted in the HTTP request. I tried
using the FlexContext.getHttpRequest() and the
FlexContext.getFlexSession(), but the attributes doesn´t
exist. Here is the code of the ChooserProvider.java



public Object[] getList()

{



System.out.println("OTRA VEZ EN ChooserProvider.getList()");



HttpServletRequest req = FlexContext.getHttpRequest();



FlexSession flxSession = FlexContext.getFlexSession();



System.out.println("FlexContext.getHttpRequest(): "+req);

System.out.println("FlexContext.getFlexSession() :
"+flxSession);



Enumeration enum = req.getAttributeNames();

while (enum.hasMoreElements()) {

String element = (String) enum.nextElement();

System.out.println(element+" <>
"+req.getAttribute(element));

}



Enumeration en = flxSession.getAttributeNames();

while (en.hasMoreElements()) {

String element = (String) en.nextElement();

System.out.println(element+" -->
"+flxSession.getAttribute(element));

}



ArrayList list=new ArrayList();

return list.toArray();



}



but this is the output in the console



OTRA VEZ EN ChooserProvider.getList()

FlexContext.getHttpRequest(): Http Request:
/samples/messagebroker/amf

FlexContext.getFlexSession() :
flex.messaging.HttpFlexSession@1a0d111

weblogic.servlet.network_channel.port <> 7001

__flexSession --> flex.messaging.HttpFlexSession@1a0d111



Where are the attributes that i have setted in the request in
the previous page? How can I access them ?

I'm using weblogic 8.1 and Flex 2 with Flex Data Services

2 Replies

Avatar

Level 3
Are you talking about getting to session parameters set in a
JSP page from a RemoteObject source class? This should be possible
so long as your SWF and RemoteObject destination are in the same
web application.



As for getting to request parameters... where did you set
them? They'd have to be set on the URL for the channel endpoint in
order for them to be available in the RemoteObject class... the URL
used to load the SWF is not the URL used to contact the channel
endpoint to send data to and from a RemoteObject
destination.

Avatar

Level 3
You have to get them from the request.
req.getParameter("myParam"); Your output is correct, you are just
not asking the right question.