Getting Edit or Help mode markup from the Flex portlet

I made changes in the How to make action or render request from the Adobe Flex so that it makes request to get the markup for Edit and Help mode from the Flex. These are the changes in the source code


public class SPRInFlexPortlet extends javax.portlet.GenericPortlet {
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
// Set the MIME type for the render response
response.setContentType(request.getResponseContentType());
System.out.println("Entering SPRInFlexPortlet.doView()");
if(request.getParameter("caller") == null){
System.out.println("Request from portal, not flex");
SPRUtil sprUtil = new SPRUtil();
String editModeUrl = sprUtil.getPortletEditModeUrl(request, response);
String helpModeUrl = sprUtil.getPortletHelpModeUrl(request, response);
request.setAttribute("editModeUrl", editModeUrl);
request.setAttribute("helpModeUrl", helpModeUrl);

getPortletContext().getRequestDispatcher("/sprinflex.jsp").include(request, response);
return;
}
PrintWriter out = response.getWriter();
out.println("Listing out parameters in the SPRFlexPortlet.doView()");
Enumeration paramNames = request.getParameterNames();
while(paramNames.hasMoreElements()){
String paramName = paramNames.nextElement();
System.out.println(paramName +" " + request.getParameter(paramName));
out.println(paramName +" " + request.getParameter(paramName)+" ");
}
System.out.println("Got request for the first time");
}
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, java.io.IOException {
System.out.println("Entering SPRInFlexPortlet.processAction");
Enumeration paramNames = request.getParameterNames();
while(paramNames.hasMoreElements()){
String paramName = paramNames.nextElement();
System.out.println(paramName +" " + request.getParameter(paramName));
response.setRenderParameter(paramName, request.getParameter(paramName));
}
response.setRenderParameter("requestType", "action");
System.out.println("Exiting SPRInFlexPortlet.processAction");
}
protected void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering SPRInFlexPortlet.doEdit");
response.setContentType(request.getResponseContentType());
response.getWriter().println("Returning response from SPRInFlexPortlet.doEdit()");
System.out.println("Exiting SPRInFlexPortlet.doEdit");
}
protected void doHelp(RenderRequest request, RenderResponse response)

throws PortletException, IOException {
System.out.println("Entering SPRInFlexPortlet.doHelp");
response.setContentType(request.getResponseContentType());
response.getWriter().println("Returning response from SPRInFlexPortlet.doHelp()");
System.out.println("Exiting SPRInFlexPortlet.doHelp");
}

}



<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" session="false"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portletx"%>
<portlet:defineObjects />
<script type="text/javascript">
function getEditModeUrl(){
console.log("Returning renderUrl");
return "<%=renderRequest.getAttribute("editModeUrl")%>";
}
function getHelpModeUrl(){
console.log("Returning processActionUrl");
return "<%=renderRequest.getAttribute("helpModeUrl")%>";
}

</script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
width="750" height="500" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie"
value='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/HelloWorld.swf") %>' />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/HelloFlex.swf") %>"
quality="high" bgcolor="#869ca7"
width="750" height="500" name="HelloWorld" align="middle" play="true"
loop="false" quality="high" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%" >
<mx:Panel id="pnlMain" layout="absolute" title="Serve Resource Example">
<mx:Button label="Edit Mode request" y= "11" id="resourceUrl"
click="makeEditModeCall()" x="351"/>
<mx:Button label="Help Mode request" y= "54" id="resourceUrl0"
click="makeHelpModeCall()" x="351"/>
<mx:TextArea x="7" y="135" width="493" height="198" id="displayText"/>
<mx:TextInput x="142" y="10" id="httpMethod" text="GET"/>
<mx:Label x="10" y="12" text="Http Method" width="124"/>
<mx:Label x="10" y="54" text="Parameters"/>
<mx:TextInput x="142" y="54" id="httpParam"/>
<mx:Label x="10" y="106" text="Portlet Response"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import flash.external.*;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
//Event handler for handling button click
public function makeHelpModeCall():void
{
if (ExternalInterface.available) {
var portletUrl:String = ExternalInterface.call("getHelpModeUrl");
useHttpService(portletUrl);
} else
displayText.text = "Unable to call JavaScript";
}
public function makeEditModeCall():void
{
if (ExternalInterface.available) {
var portletUrl:String = ExternalInterface.call("getEditModeUrl");
useHttpService(portletUrl);
} else
displayText.text = "Unable to call JavaScript";
}

//This method is used for making a URL call
private var service:HTTPService
public function useHttpService(url:String):void {
service = new HTTPService();
service.url = url;
service.resultFormat = HTTPService.RESULT_FORMAT_TEXT;
service.method = httpMethod.text;
service.addEventListener("result", httpResult);
service.addEventListener("fault", httpFault);
service.send(parameters);
}
//This callback gets called in case if the http response is returned
public function httpResult(event:ResultEvent):void {
var result:Object = event.result;
displayText.text = event.result.toString();
}
//This call back gets called in case of error in http request
public function httpFault(event:FaultEvent):void {
var faultstring:String = event.fault.faultString;
displayText.text = event.fault.faultDetail;
Alert.show(faultstring + event.fault.faultDetail + event.fault.rootCause);
}
]]>
</mx:Script>
</mx:Application>