I wrote two pages publisher-view.jsp and listener-view.jsp, in publisher-view.jsp I used portlet tags to generate the actionURL, exactly like we have below:
| <%@ page contentType="text/html"%> | <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> | <portlet:defineObjects /> | <portlet:actionURL var="submitUrl" portletMode="view" /> | <div> | <br /> | <br /> | <center> | <form action="<%=submitUrl%>" method="post"> | <label for="input">Type your text:</label> | <input type="text" id="input" name="input" value="" /> | <input type="submit" value="Send" /> | </form> | </center> | </div> | When the submit button is clicked the processAction on PublisherPortlet must be invoked and then the event is set: | package br.eti.faces.portlet.publisher; | | import java.io.IOException; | | import javax.portlet.ActionRequest; | import javax.portlet.ActionResponse; | import javax.portlet.GenericPortlet; | import javax.portlet.PortletContext; | import javax.portlet.PortletException; | import javax.portlet.PortletRequestDispatcher; | import javax.portlet.RenderRequest; | import javax.portlet.RenderResponse; | | import br.eti.faces.portlet.events.Literal; | | public class PublisherPortlet extends GenericPortlet { | | @Override | protected void doView(RenderRequest renderRequest, | RenderResponse renderResponse) throws PortletException, IOException { | | renderResponse.setContentType("text/html"); | | PortletContext ctx = getPortletContext(); | PortletRequestDispatcher dispatcher = ctx | .getRequestDispatcher("/publisher-view.jsp"); | | dispatcher.include(renderRequest, renderResponse); | } | | @Override | public void processAction(ActionRequest actionRequest, | ActionResponse actionResponse) throws PortletException, IOException { | String value = actionRequest.getParameter("input"); | actionResponse.setEvent(Literal.QNAME, new Literal(value)); | } | | } | I defined this class as my event class: | package br.eti.faces.portlet.events; | | import java.io.Serializable; | | import javax.xml.bind.annotation.XmlRootElement; | import javax.xml.namespace.QName; | | @XmlRootElement | public class Literal implements Serializable { | | public static final QName QNAME = new QName("urn:jboss:portal:samples:event" , "Literal"); | | private String data; | | public Literal(String data) { | this.data = data; | } | | public String getData() { | return data; | } | | public void setData(String data) { | this.data = data; | } | } | Finally, I registered both (porlet and event) on portlet.xml: | <?xml version="1.0" encoding="UTF-8"?> | <portlet-app | xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" | id="portlet-event" version="2.0"> | | <event-definition> | <qname xmlns:jbp="urn:jboss:portal:samples:event">jbp:Literal</qname> | <value-type>br.eti.faces.portlet.events.Literal</value-type> | </event-definition> | | <portlet id="publisher"> | <init-param> | <name>default-view</name> | <value>/publisher-view.jsp</value> | </init-param> | <init-param> | <name>ViewPage</name> | <value>/publisher-view.jsp</value> | </init-param> | <description>Event Publisher JSP Portlet</description> | <portlet-name>publisher</portlet-name> | <display-name>Event Publisher JSP Portlet</display-name> | <portlet-class> | br.eti.faces.portlet.publisher.PublisherPortlet | </portlet-class> | <supports> | <mime-type>text/html</mime-type> | <portlet-mode>VIEW</portlet-mode> | </supports> | <portlet-info> | <title>Event Publisher JSP Portlet</title> | <short-title>Event Publisher JSP Portlet</short-title> | </portlet-info> | | <supported-publishing-event> | <qname xmlns:jbp="urn:jboss:portal:samples:event">jbp:Literal</qname> | </supported-publishing-event> | </portlet> | | <portlet id="listener"> | <init-param> | <name>default-view</name> | <value>/listener-view.jsp</value> | </init-param> | <init-param> | <name>ViewPage</name> | <value>/listener-view.jsp</value> | </init-param> | <description>Event Listener JSP Portlet</description> | <portlet-name>listener</portlet-name> | <display-name>Event Listener JSP Portlet</display-name> | <portlet-class> | br.eti.faces.portlet.listener.ListenerPortlet | </portlet-class> | <supports> | <mime-type>text/html</mime-type> | <portlet-mode>VIEW</portlet-mode> | </supports> | <portlet-info> | <title>Event Listener JSP Portlet</title> | <short-title>Event Listener JSP Portlet</short-title> | </portlet-info> | | <supported-processing-event> | <qname xmlns:jbp="urn:jboss:portal:samples:event">jbp:Literal</qname> | </supported-processing-event> | </portlet> | </portlet-app> | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134002#4134002 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134002 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user