Reading query string inside the Flex Portlet

I made some changes in the Getting Query String of portal URL from inside the portlet code to use Flex on the client side. Now Flex is used for UI on the client side. You can download the sample code for portlet from here

The Portlet code remains the same, except one change, now i am forwarding control to query.jsp which is including Flex object on page using code like this

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="false"%>
<%@taglib uri="" prefix="portlet"%>
<portlet:defineObjects />
<script type="text/javascript">

function getQueryString(){
console.log("Returning getQueryString");
return "<%=renderRequest.getAttribute("queryString")%>";

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="HelloWorld" width="500px" height="500px"
<param name="movie"
+ "/FlashQueryString.swf")%>' />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="<%=renderResponse.encodeURL(renderRequest.getContextPath() + "/FlashQueryString.swf")%>"
quality="high" bgcolor="#869ca7" width="500px" height="500px"
name="HelloWorld" align="middle" play="true" loop="false"
quality="high" allowScriptAccess="sameDomain"
</embed> </object>

Also i have getQueryString function that returns the query string set by the Portlet code as request attribute.

My Flex code is very simple

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx=""
xmlns:mx="library://" minWidth="955"
minHeight="600" creationComplete="init()">
public function init():void{
var queryString ="getQueryString");
queryStringText.text = queryString;

<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:Panel x="5" y="10" width="284" height="172" title="Query String Demo">
<s:TextArea x="10" y="44" width="220" height="54" id="queryStringText" />
<s:Label x="10" y="10" text="Query String" width="167" height="30"/>

In the creationComplete() method of the Flex code i am calling getQueryString JavaScript method and setting value returned by it inside the text area for display


Anonymous said...

Very good example, it works fine, but one note, when the URL contains myportal, all the parameters vanish and become invisible for the request, do you faced this before ?

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

EG MEDI said... is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store