cancel
Showing results for 
Search instead for 
Did you mean: 

Followup question from thread 'Portal component iview quandry'

Former Member
0 Kudos

Hello again, Portal Experts!

I am trying to follow the sage advice posted on my previous thread <a href="https://forums.sdn.sap.com/thread.jspa?threadID=437437&tstart=150">Portal component iview quandry</a> advising me to modify my forms' HTTP method from 'GET' to 'POST' but I am not successful. My iview does not load at all. Is there some property I need to set in my portalapp.xml? Or perhaps I need to use a different class with a 'POST' action, other than the IPortalComponentRequest getParameter method?

To summarize, I am trying to prevent the display of the long URL string with query parameters when opening a custom portal component iview.

Your kind direction is, as always, greatly appreciated.

Signed, perplexed newbie

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

try using

httpservlet's request object to get the parameter.

insetad of using IPortalComponentRequest's object.

Regards,

Beevin.

Former Member
0 Kudos

Can I use both the HttpServlet's request object and the IPortalComponent's request object in the same method? I need to get the parameters from the POST action and separately I need to read in the personalization properties of the iView.

It looks something like this now (and works perfectly for HTTP GET method):

import java.io.Writer;
import java.net.URLEncoder;
import java.util.Enumeration;

import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentContext;
import com.sapportals.portal.prt.component.IPortalComponentProfile;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
import com.sapportals.portal.prt.logger.ILogger;
import com.sapportals.portal.prt.runtime.PortalRuntime;
import com.sapportals.portal.prt.util.StringUtils;


public class PageAnEmployee extends AbstractPortalComponent {
	public void doContent(
		IPortalComponentRequest request,
		IPortalComponentResponse response) {
		try {
			// Retrieve querystring parameters and cleanse to prevent xss
			String strLastName =
				StringUtils.escapeToURL(
					request.getParameter("lastname").trim(),
					64);

	... more code ...

			String strParam = "";

			// Formating QueryString Parameters
			if (strLastName != null) {
				strParam =
					strParam
						+ "&lastname="
						+ URLEncoder.encode(strLastName, "UTF-8");

	... more code ...

			}
			strParam = strParam.substring(1, strParam.length());

			//Retrieve component context
			IPortalComponentContext context = request.getComponentContext();
			//Retrieve component profile
			IPortalComponentProfile profile = context.getProfile();

			//Retrieve URIs for the source XML & XSL files
			String strEmployeeDetailsXml =
				profile.getProperty("XML Path") + "?" + strParam;

			//String strEmployeeDetailsXsl = profile.getProperty("XSLT Path");
			String strEmployeeDetailsXsl =
				request.getPrivateResourcePath() + "/xsl/pager_input.xsl";

			//Retrieve personalization data
			Enumeration properties = profile.getProperties();
			response.write("<script type='text/javascript'>");
			response.write("function writeTextMsgs() {");

	... more code ...
			response.write("}");
			response.write("</script>");

Former Member
0 Kudos

Closing thread, a solution is no longer required for this scenario.