I am new to Portlet development and I am running into an annoying issue with Liferay.
I have played around a bit and created the following portlet (.jsp) page based on the "edit.jsp" from the "My-Greeting" tutorial:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ page import="javax.portlet.PortletPreferences" %>
<portlet:defineObjects />
<%
PortletPreferences prefs = renderRequest.getPreferences();
String Temperature = (String)prefs.getValue("Temperature","Temperature");
PortletPreferences prefs2 = renderRequest.getPreferences();
String FromUnit = (String)prefs2.getValue("FromUnit", "FromUnit");
PortletPreferences prefs3 = renderRequest.getPreferences();
String ToUnit = (String)prefs3.getValue("ToUnit","ToUnit");
%>
<portlet:renderURL var="editGreetingURL">
<portlet:param name="jspPage" value="/edit.jsp" />
</portlet:renderURL>
<aui:form action="http://www.webservicex.net/ConvertTemperature.asmx/ConvertTemp" method="post">
<aui:input label="Temperature" name="Temperature" type="text" value="<%= Temperature %>" />
<aui:input label="FromUnit" name="FromUnit" type="text" value="<%= FromUnit %>" />
<aui:input label="ToUnit" name="ToUnit" type="text" value="<%= ToUnit %>" />
<aui:button label="submit" type="submit" value="Submit" />
</aui:form>
<portlet:renderURL var="viewGreetingURL">
<portlet:param name="jspPage" value="/view.jsp" />
</portlet:renderURL>
<p><a href="<%= viewGreetingURL %>">Back</a></p>
</body>
</html>
This portlet is supposed to take 3 input parameters: Temperature, FromUnit and ToUnit and then pass them on to a public WebService which converts Temperatures for example from Fahrenheit to Celcius (see http://www.webservicex.net/ConvertTemperature.asmx?WSDL) .
The portlet renders the input fields correctly and when I click the submit button it also tries to execute the Webservice but it doesn't actually pass on the parameters it seems because I get the following error response from the WebService itself:
System.InvalidOperationException: Missing parameter: Temperature. at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
So even though my portlet has the input field Temperature it doesn't seem to actually pass it on and attach it to the action URL in the post ...
ne more thing, I replaced the "post" with a "get" and the URL string looks like this:
What am I doing wrong here? Clearly it seems to be passing on the wrong parameters...