Hi,
i have deployed a portlet that supports the VIEW, EDIT and HELP mode. When
applying the EDIT operation i am redirected to the default page of the portal.
This causes that i can't see the result's of the EDIT operation. How can I
force JBP2 to stay on the same page.
A second question: Why do i have to reference a portltet instance in
*-pages.xml with this cryptic string
<instance-ref>advancedportlet.AdvancedPortlet.AdvancedPortletInstance</instance-ref>
instead of <instance-ref>AdvancedPortletInstance</instance-ref> as defined in
the portlet-instances.xml?
Here is the portlet code. It is the modified example from the portal book
chapter 2.
| 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.");
| }
| }
|
| 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);
| }
| }
| }
|
Here is portlet.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
| version="1.0"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
| <portlet>
| <description>Advanced Portlet Description</description>
| <portlet-name>AdvancedPortlet</portlet-name>
| <display-name>Advanced Portlet</display-name>
|
<portlet-class>com.portalbook.portlets.AdvancedPortlet</portlet-class>
| <expiration-cache>-1</expiration-cache>
| <supports>
| <mime-type>text/html</mime-type>
| <portlet-mode>VIEW</portlet-mode>
| <portlet-mode>EDIT</portlet-mode>
| <portlet-mode>HELP</portlet-mode>
| </supports>
| <supported-locale>en</supported-locale>
| <portlet-info>
| <title>Advanced Portlet</title>
| <short-title>Adv. Portlet</short-title>
| <keywords>Advanced</keywords>
| </portlet-info>
| </portlet>
| </portlet-app>
|
Here is advanced-pages.xml
| <pages>
| <portal-name>default</portal-name>
| <page>
| <page-name>advancedportlet</page-name>
| <window>
| <window-name>AdvancedPortletWindow</window-name>
<instance-ref>advancedportlet.AdvancedPortlet.AdvancedPortletInstance</instance-ref>
| <default>true</default>
| <region>center</region>
| <height>0</height>
| </window>
| </page>
| </pages>
|
Last but not least portlet-instances.xml
| <?xml version="1.0" standalone="yes"?>
| <instances>
| <instance>
| <instance-name>AdvancedPortletInstance</instance-name>
| <component-ref>AdvancedPortlet</component-ref>
| </instance>
| </instances>
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884697#3884697
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884697
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user