-
1. Re: RenderResponse.createActionUrl() does not work
mholzner Apr 3, 2006 1:52 PM (in response to gilboay)is your form using POST or GET ?
try <form method='POST' action='....> -
2. Re: RenderResponse.createActionUrl() does not work
gilboay Apr 4, 2006 5:43 AM (in response to gilboay)hi -
i've tried both GET and POST - the same behaviour happens for both of them.
Any ideas? -
3. Re: RenderResponse.createActionUrl() does not work
theute Apr 4, 2006 10:16 AM (in response to gilboay)What is <Generated URL> ?
-
4. Re: RenderResponse.createActionUrl() does not work
gilboay Apr 5, 2006 7:45 AM (in response to gilboay)<Generated URL> means the actual url returned by the RenderResponse.createActionURL() method.
-
5. Re: RenderResponse.createActionUrl() does not work
theute Apr 5, 2006 7:54 AM (in response to gilboay)Why not using the portlet tag <portlet:actionURL/> ?
And at least please show us exactly the code you write, since it seems that there is a problem with it.
Help us help you -
6. Re: RenderResponse.createActionUrl() does not work
gilboay Apr 6, 2006 9:18 AM (in response to gilboay)hi,
I'd rather not used JSP at this point.
I'm trying this with a sample code from the book "Building Portals with the Java Portlet API" (Apress), by Jeff Linwood & Dave Minter.
Here is the full listing of the portlet class:package com.portalbook.portlets; import java.io.IOException; import java.io.Writer; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.GenericPortlet; import javax.portlet.PortletException; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; public class AdvancedPortlet extends GenericPortlet { protected void doEdit( RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { renderResponse.setContentType("text/html"); Writer writer = renderResponse.getWriter(); //get the existing parameters to use as defaults. String title = renderRequest.getParameter("title"); String contents = renderRequest.getParameter("contents"); if (title == null) { title = ""; } if (contents == null) { contents = ""; } writer.write("<H1>Portlet Settings</H1>"); writer.write("<FORM ACTION="); writer.write(renderResponse.createActionURL().toString()); writer.write(">"); writer.write( "Title: <INPUT TYPE=text NAME=title VALUE='" + title + "' SIZE=25>"); writer.write( "Contents: <INPUT TYPE=text NAME=contents VALUE= '" + contents + "' SIZE=25>"); writer.write("<P>"); writer.write("<INPUT TYPE=submit>"); writer.write("</FORM>"); } protected void doHelp( RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { //return a helpful message renderResponse.setContentType("text/html"); Writer writer = renderResponse.getWriter(); writer.write( "This portlet allows you to change its content and title."); } protected void doView( RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { renderResponse.setContentType("text/html"); Writer writer = renderResponse.getWriter(); String contents = renderRequest.getParameter("contents"); if (contents != null) { writer.write(contents); } else { //return the default contents writer.write("This is the default portlet contents. To change "); writer.write("this message, edit the portlet's settings."); } writer.write("<p>"); writer.write( "<IMG SRC=" + renderResponse.encodeURL( renderRequest.getContextPath() + "/images/picture.jpg") + ">"); writer.write("<p>"); writer.write( "<IMG SRC=http://www.greenninja.com/images/teton1-small.jpg>"); } protected String getTitle(RenderRequest renderRequest) { String title = renderRequest.getParameter("title"); if (title != null) { return title; } //else return a default title, if we don't have one set yet. return "Advanced Portlet"; } public void processAction( ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { //check for parameters String title = actionRequest.getParameter("title"); if (title != null) { actionResponse.setRenderParameter("title", title); } String contents = actionRequest.getParameter("contents"); if (contents != null) { actionResponse.setRenderParameter("contents", contents); } } }
The doEdit() section works only if I apply the work-around described in the 1st event.
thanx :) -
7. Re: RenderResponse.createActionUrl() does not work
mholzner Apr 6, 2006 2:17 PM (in response to gilboay)I'm not sure if this is a forum problem, or if you forgot the quotes around all the attribute values that you write.
instead of:writer.write("<FORM ACTION="); writer.write(renderResponse.createActionURL().toString()); writer.write(">");
trywriter.write("<FORM ACTION=\""); writer.write(renderResponse.createActionURL().toString()); writer.write("\">");
...apply the same change for the other attributes. -
8. Re: RenderResponse.createActionUrl() does not work
gilboay Apr 9, 2006 5:15 AM (in response to gilboay)hi again -
This is not a markup problem. I've modified the code to generate valid HTML (enclosing all attributes with double quotes). The problem is with the actual value of the action attribute.