tags:

views:

270

answers:

2

Hi I am sending userID through urlRequest like below code, var urlStr:String = "http://[server]/main.jsp";
var urlReqest:URLRequest= new URLRequest(urlStr); var variables:URLVariables = new URLVariables(); variables.userID = 12;
urlReqest.method = URLRequestMethod.POST; urlReqest.data = variables;
navigateToURL(urlReqest,"_blank");
now when new window is opening in that new swf is opening(new project) that is also in flex only.there i need to retrive userID when initailizing only how can i retrive? if any one can help it would be help full. Thanks in advance.

+2  A: 

In Flex 4 you can use

if (FlexGlobals.topLevelApplication.parameters.hasOwnProperty("userID"))
{
    userID = FlexGlobals.topLevelApplication.parameters.userID;
}

In Flex 3 you can use

if (mx.core.Application.application.parameters.hasOwnProperty("userID"))
{
    userID = mx.core.Application.application.parameters.userID;
}
Jason W
This is part of the solution. You won't be able to read the POST headers from Flex.
adamcodes
HI Jason W,thanks for your information and when i am posting userID to jsp with out navigating,i am sending through urlRequest i am using request.getparameter("Userid"); like this i am retriving but in jsp its getting null value.which method i need to use in jsp? please suggest me.
praveen
ok i got it and how can i give the width and height a navigateToURL(urlReqest,"_blank"); to opening a window.it is opening full window but i need to open widh=999 and height=608.Thanks in Advance.
praveen
praveen, I'm glad you've got the variables passing through from JSP into Flex. Here is a way you can set the popup dimensions...var js:String = "window.open(urlStr,'win','height=608,width=999');"; var url:URLRequest = new URLRequest("javascript:" + js + " void(0);"); hope that helps
Jason W
Thanks its help full,and How can i disable or do not show the url in browser?in flex iam loading window like window.open( and there i need to open window but no one can see the url and copy the url? is it possible in flex? please help me.
praveen
put location=no next to the height/width. Note: this will not work in some browsers such as Firefox, which has a setting for disabling url hiding --> dom.disable_window_open_feature.location
adamcodes
Hi in my project when i am loading main.jsp(converted .html to .jsp) i am passing flash vars like this <param name="FlashVars" value="userNid=<%=session.getAttribute("userNid")=%> />here session is maintaining,i am retriving in flex like 'Alert.show(mx.core.Application.application.parameters.userNid)' i give it in creationcomplete method i am getting like 'undefined' and not getting userNid.i am help less in this please suggest me how can i retrive?
praveen
+2  A: 

You would have to rewrite the JSP page to write the POST values to the flashVars parameter. The POST variables are not accessible to the Flex app.

Once they are passed in through flashVars on the page, you would use Jason W's method for reading them:

if (mx.core.Application.application.parameters.hasOwnProperty("userID"))
{
    userID = mx.core.Application.application.parameters.userID;
}
adamcodes
Hi Adam,i need to post the variable to JSP.but when i am posting through var urlStr:String = "http://[server]/main.jsp";var urlReqest:URLRequest= new URLRequest(urlStr); var variables:URLVariables = new URLVariables(); variables.userID = 12;urlReqest.method = URLRequestMethod.POST; urlReqest.data = variables; like this JSP side when i retrive request.getParameter("UserId");null value is showing.how can i retrive user id in JSP?please help me in this Thanks in advance.
praveen
I haven't done much with JSP, but request.getParameter seems correct. In your comment you are mixing case on the userID. Is your code consistent? ie are you sending and retrieving userID without case variation?
adamcodes