JBoss Portal SVN: r11409 - branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 12:51:47 -0400 (Thu, 10 Jul 2008)
New Revision: 11409
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
Log:
- JBPORTAL-2067: retrieve the HttpServletRequest properly.
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2008-07-10 12:57:52 UTC (rev 11408)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2008-07-10 16:51:47 UTC (rev 11409)
@@ -49,6 +49,7 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
+import org.jboss.portal.wsrp.servlet.ServletAccess;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -173,7 +174,7 @@
PortletUtils.SUFFIX,
WSRPRewritingConstants.WSRP_REWRITE_TOKEN);
- result = URLTools.replaceURLsBy(result, new AbsoluteURLReplacementGenerator(invocation.getDispatchedRequest()));
+ result = URLTools.replaceURLsBy(result, new AbsoluteURLReplacementGenerator(ServletAccess.getRequest()));
return result;
}
}
16 years, 3 months
JBoss Portal SVN: r11408 - branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-10 08:57:52 -0400 (Thu, 10 Jul 2008)
New Revision: 11408
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml
Log:
Fix test cases
Modified: branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml 2008-07-10 12:03:40 UTC (rev 11407)
+++ branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml 2008-07-10 12:57:52 UTC (rev 11408)
@@ -94,7 +94,7 @@
</bean>
<bean name="CoordinationService" class="org.jboss.portal.core.impl.model.portal.coordination.CoordinationService">
- <property name="container"><inject bean="PortalObjectContainer"/></property>
+ <property name="portalObjectContainer"><inject bean="PortalObjectContainer"/></property>
</bean>
<bean name="TestBean" class="org.jboss.portal.test.core.model.portal.coordination.CoordinationServiceTestCase">
16 years, 3 months
JBoss Portal SVN: r11407 - docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-10 08:03:40 -0400 (Thu, 10 Jul 2008)
New Revision: 11407
Modified:
docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/tutorials.xml
Log:
Sorry Murray, i use my version, it's just impossible to merge...
Modified: docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/tutorials.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/tutorials.xml 2008-07-10 11:59:26 UTC (rev 11406)
+++ docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/tutorials.xml 2008-07-10 12:03:40 UTC (rev 11407)
@@ -24,10 +24,10 @@
<ulink url="http://www.jcp.org/en/jsr/detail?id=286">
JSR-286 (Portlet 2.0)
</ulink>
- portlet container. Most Java EE portals include a portlet container, it is
- obvously the case for JBoss Portal which includes the JBoss Portlet container
- supporting the two versions. This chapter gives a brief overview of the Portlet
- Specifications. Portlet developers are strongly encouraged to read the
+ portlet container. Most Java EE portals include one, it is obviously the case for
+ JBoss Portal which includes the JBoss Portlet container supporting the two
+ versions. This chapter gives a brief overview of the Portlet Specifications but
+ portlet developers are strongly encouraged to read the
<ulink url="http://www.jcp.org/en/jsr/detail?id=286">
JSR-286 Portlet Specification
</ulink>
@@ -47,7 +47,8 @@
<para>
<mediaobject>
<imageobject>
- <imagedata fileref="images/tutorials/SpecPortalDef.png" scalefit="1" />
+ <imagedata fileref="images/tutorials/SpecPortalDef.png" format="PNG"
+ scalefit="1" />
</imageobject>
</mediaobject>
</para>
@@ -110,26 +111,17 @@
</itemizedlist>
</para>
</sect2>
- <sect2>
- <title>Section Status</title>
- <para>
- This overview of the JSR-168 Portlet Specification is a work in progress.
- Check back for more in-depth analsis of the specification. The sections
- following here after contain real-world cases for how to leverage the
- specification.
- </para>
- </sect2>
</sect1>
<sect1 id="tutorials_tutorials">
<title>Tutorials</title>
<para>
- The tutorials contained in this chapter are targetted toward portlet developers.
+ The tutorials contained in this chapter are targeted toward portlet developers.
Although they are a good starting and reference point, it is highly recommend
that portlet developers read and understand the
<ulink url="http://www.jcp.org/en/jsr/detail?id=286">
JSR-286 Portlet Specification
</ulink>
- . Use the
+ . Feel free to use the
<ulink url="http://jboss.org/index.html?module=bb&op=viewforum&f=215">
JBoss Portal User Forums
</ulink>
@@ -140,19 +132,58 @@
<sect3>
<title>Introduction</title>
<para>
- This section describes how to deploy a portlet in JBoss Portal. Before
- proceeding, download the
- <ulink
- url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/HelloWorl...">
- HelloWorldPortlet
- </ulink>
- from
- <ulink url="http://labs.jboss.com/portletswap/">JBoss PortletSwap</ulink>
+ This section describes how to deploy a portlet in JBoss Portal. You will
+ find the
+ <emphasis>SimplestHelloWorld</emphasis>
+ portlet in the
+ <literal>examples</literal>
+ directory at the root of your JBoss Portal binary package.
+ </para>
+ </sect3>
+ <sect3>
+ <title>Compiling</title>
+ <para>
+ This example is using Maven to compile and build the web archive. If you
+ don't have Maven already installed, you will find a version for your
+ operating system
+ <ulink url="http://maven.apache.org/download.html">here</ulink>
+ </para>
+ <para>
+ To compile and package the application, go to the SimplestHelloWorld
+ directory and type
+ <literal>mvn package</literal>
.
</para>
+ <para>
+ Once successfully packaged, the result should be available in:
+ <literal>SimplestHelloWorld/target/SimplestHelloWorld-0.0.1.war</literal>
+ . Simply copy that file into
+ <literal>JBOSS_HOME/server/default/deploy</literal>
+ , then start JBoss Application Server if it was not already started.
+ </para>
+ <para>
+ You should now see a new page called
+ <literal>SimplestHelloWorld</literal>
+ , with a window inside containing the portlet instance we have created, as
+ seen below.
+ </para>
+ <para>
+ <mediaobject>
+ <imageobject>
+ <objectinfo>
+ <title>SimplestHelloWorldPortlet deployed on a new page</title>
+ </objectinfo>
+ <imagedata fileref="images/tutorials/first_portlet/deployed.png" />
+ </imageobject>
+ </mediaobject>
+ </para>
</sect3>
<sect3>
<title>Package Structure</title>
+ <bridgehead>
+ Now that we have seen how to deploy an existing web application, let's have
+ a look inside.
+ </bridgehead>
<para>
Like other Java Platform, Enterprise Edition (Java EE) applications,
portlets are packaged in WAR files. A typical portlet WAR file can include
@@ -163,15 +194,15 @@
), and other static or dynamic files. The following is an example of the
directory structure of the HelloWorldPortlet portlet:
</para>
-<programlistingco>
- <areaspec>
- <area id="javaclass" coords='9' />
- <area id="defaultobject" coords='10' />
- <area id="portletinstances" coords='11' />
- <area id="portlet" coords='12' />
- <area id="web" coords='13' />
- </areaspec>
- <programlisting><![CDATA[|-- SimplestHelloWorld-0.0.1.war
+ <programlistingco>
+ <areaspec>
+ <area id="tutorials.simplest.javaclass" coords='9' />
+ <area id="tutorials.simplest.defaultobject" coords='10' />
+ <area id="tutorials.simplest.portletinstances" coords='11' />
+ <area id="tutorials.simplest.portlet" coords='12' />
+ <area id="tutorials.simplest.web" coords='13' />
+ </areaspec>
+ <programlisting><![CDATA[|-- SimplestHelloWorld-0.0.1.war
| `-- WEB-INF
| |-- classes
| | `-- org
@@ -184,54 +215,75 @@
| |-- portlet-instances.xml
| |-- portlet.xml
| `-- web.xml]]>
- </programlisting>
- <calloutlist>
- <callout arearefs="javaclass">
- <para>
- The compiled Java class implementing <emphasis>javax.portlet.Portlet</emphasis> (through <emphasis>javax.portlet.GenericPortlet</emphasis>)
- </para>
- </callout>
- <callout arearefs="defaultobject">
- <para>
- <emphasis>default-object.xml</emphasis> is an optional file, it is used to define the layout of the portal. It can be used to define the different portals, pages and windows.
- The same result can be obtained through the administration portal. Note that the definition of the layout is stored in database, this file is then used to populate the database
- during deployment which can be very useful during development.
- </para>
- </callout>
- <callout arearefs="portletinstances">
- <para>
- <emphasis>portlet-instances.xml</emphasis> is also optional, it allows to create a portlet instance from the SimpleHelloWorld portlet definition. Creating
- instances can also be done through the administration portal. Note that the definition of instances is stored in database, this file is then used to populate the database
- during deployment which can be very useful during development.
- </para>
- </callout>
- <callout arearefs="portlet">
- <para>This is the mandatory descriptor files for portlets. It is used during deployment..</para>
- </callout>
- <callout arearefs="web">
- <para>This is the mandatory descriptor for web applications.</para>
- </callout>
- </calloutlist>
- </programlistingco>
- </sect3>
+ </programlisting>
+ <calloutlist>
+ <callout arearefs="tutorials.simplest.javaclass">
+ <para>
+ The compiled Java class implementing
+ <emphasis>javax.portlet.Portlet</emphasis>
+ (through
+ <emphasis>javax.portlet.GenericPortlet</emphasis>
+ )
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.defaultobject">
+ <para>
+ <emphasis>default-object.xml</emphasis>
+ is an optional file, it is used to define the layout of the
+ portal. It can be used to define the different portals, pages and
+ windows. The same result can be obtained through the
+ administration portal. Note that the definition of the layout is
+ stored in database, this file is then used to populate the
+ database during deployment which can be very useful during
+ development.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.portletinstances">
+ <para>
+ <emphasis>portlet-instances.xml</emphasis>
+ is also optional, it allows to create a portlet instance from the
+ SimpleHelloWorld portlet definition. Creating instances can also
+ be done through the administration portal. Note that the
+ definition of instances is stored in database, this file is then
+ used to populate the database during deployment which can be very
+ useful during development. Having portlet-instances.xml and
+ default-object.xml included in this package ensures that the
+ portlet will appear directly on the portal by just deploying the
+ web application.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.portlet">
+ <para>
+ This is the mandatory descriptor files for portlets. It is used
+ during deployment..
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.web">
+ <para>This is the mandatory descriptor for web applications.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+ </sect3>
+
<sect3>
- <title>Portlet Classes</title>
+ <title>Portlet Class</title>
+ <bridgehead>Let's study the Java class in detail.</bridgehead>
<para>
- The following is the
+ The following file is the
<filename>
SimplestHelloWorldPortlet/src/main/java/org/jboss/portal/portlet/samples/SimplestHelloWorldPortlet.java
</filename>
- Java source file, which comes bundled with your JBoss Portal download:
+ Java source.
</para>
- <programlistingco>
- <areaspec>
- <area id="extends" coords='10' />
- <area id="doview" coords='13' />
- <area id="writer" coords='15' />
- <area id="write" coords='16' />
- <area id="close" coords='17' />
- </areaspec>
- <programlisting role="JAVA"><![CDATA[package org.jboss.portal.portlet.samples;
+ <programlistingco>
+ <areaspec>
+ <area id="tutorials.simplest.extends" coords='10' />
+ <area id="tutorials.simplest.doview" coords='13' />
+ <area id="tutorials.simplest.writer" coords='15' />
+ <area id="tutorials.simplest.write" coords='16' />
+ <area id="tutorials.simplest.close" coords='17' />
+ </areaspec>
+ <programlisting role="JAVA"><![CDATA[package org.jboss.portal.portlet.samples;
import java.io.IOException;
import java.io.PrintWriter;
@@ -250,61 +302,61 @@
writer.close();
}
}]]>
- </programlisting>
- <calloutlist>
- <callout arearefs="extends">
- <para>
- All portlets must implement the
- <literal>javax.portlet.Portlet</literal>
- interface. The portlet API provides a convenient implementation
- of this interface, in the form of the
- <literal>javax.portlet.GenericPortlet</literal>
- class, which among other things, implements the
- <literal>Portlet render</literal>
- method to dispatch to abstract mode-specific methods to make it
- easier to support the standard portlet modes. As well, it
- provides a default implementation for the
- <literal>processAction</literal>
- ,
- <literal>init</literal>
- and
- <literal>destroy</literal>
- methods. It is recommended to extend
- <literal>GenericPortlet</literal>
- for most cases.
- </para>
- </callout>
- <callout arearefs="doview">
- <para>
- As we extend from
- <literal>GenericPortlet</literal>
- , and are only interested in supporting the
- <literal>view</literal>
- mode, only the
- <literal>doView</literal>
- method needs to be implemented, and the
- <literal>GenericPortlet</literal>
- <literal>render</literal>
- implemention calls our implementation when the
- <literal>view</literal>
- mode is requested.
- </para>
- </callout>
- <callout arearefs="writer">
- <para>
- Use the
- <emphasis>RenderResponse</emphasis>
- to obtain a writer to be used to produce content.
- </para>
- </callout>
- <callout arearefs="write">
- <para>Write the markup to display.</para>
- </callout>
- <callout arearefs="close">
- <para>Closing the writer.</para>
- </callout>
- </calloutlist>
- </programlistingco>
+ </programlisting>
+ <calloutlist>
+ <callout arearefs="tutorials.simplest.extends">
+ <para>
+ All portlets must implement the
+ <literal>javax.portlet.Portlet</literal>
+ interface. The portlet API provides a convenient implementation of
+ this interface, in the form of the
+ <literal>javax.portlet.GenericPortlet</literal>
+ class, which among other things, implements the
+ <literal>Portlet render</literal>
+ method to dispatch to abstract mode-specific methods to make it
+ easier to support the standard portlet modes. As well, it provides
+ a default implementation for the
+ <literal>processAction</literal>
+ ,
+ <literal>init</literal>
+ and
+ <literal>destroy</literal>
+ methods. It is recommended to extend
+ <literal>GenericPortlet</literal>
+ for most cases.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.doview">
+ <para>
+ As we extend from
+ <literal>GenericPortlet</literal>
+ , and are only interested in supporting the
+ <literal>view</literal>
+ mode, only the
+ <literal>doView</literal>
+ method needs to be implemented, and the
+ <literal>GenericPortlet</literal>
+ <literal>render</literal>
+ implemention calls our implementation when the
+ <literal>view</literal>
+ mode is requested.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.writer">
+ <para>
+ Use the
+ <emphasis>RenderResponse</emphasis>
+ to obtain a writer to be used to produce content.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.write">
+ <para>Write the markup to display.</para>
+ </callout>
+ <callout arearefs="tutorials.simplest.close">
+ <para>Closing the writer.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
<para>
<note>
<title>Markup Fragments</title>
@@ -323,24 +375,24 @@
<title>Application Descriptors</title>
<para>
JBoss Portal requires certain descriptors to be included in a portlet WAR
- file. Some of these descriptors are defined by the Portlet
- Specification, and others are specific to JBoss Portal.
+ file. Some of these descriptors are defined by the Portlet Specification,
+ and others are specific to JBoss Portal.
</para>
- <para>
+ <para>
The following is an example of the
<filename>SimplestHelloWorldPortlet/WEB-INF/portlet.xml</filename>
file. This file must adhere to its definition in the JSR-286 Portlet
Specification. You may define more than one portlet application in this
file:
</para>
- <programlistingco>
- <areaspec>
- <area id="portletname" coords='8' />
- <area id="portletclass" coords='9' />
- <area id="supports" coords='12' />
- <area id="portletinfo" coords='15' />
- </areaspec>
- <programlisting><![CDATA[
+ <programlistingco>
+ <areaspec>
+ <area id="tutorials.simplest.portletname" coords='8' />
+ <area id="tutorials.simplest.portletclass" coords='9' />
+ <area id="tutorials.simplest.supports" coords='12' />
+ <area id="tutorials.simplest.portletinfo" coords='15' />
+ </areaspec>
+ <programlisting><![CDATA[
<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
@@ -361,58 +413,62 @@
</portlet-app>]]>
</programlisting>
<calloutlist>
- <callout arearefs="portletname">
- <para>Define the portlet name. It does not have to be the class name.</para>
- </callout>
- <callout arearefs="portletclass">
- <para>
- The Fully Qualified Name (FQN) of your portlet class must be
- declared here.
- </para>
- </callout>
- <callout arearefs="supports">
- <para>
- The
- <computeroutput><supports></computeroutput>
- element declares all of the markup types that a portlet
- supports in the
- <literal>render</literal>
- method. This is accomplished via the
- <computeroutput><mime-type></computeroutput>
- element, which is required for every portlet. The declared MIME
- types must match the capability of the portlet. As well, it
- allows you to pair which modes and window states are supported
- for each markup type. All portlets must support the
- <computeroutput>view</computeroutput>
- portlet mode, so this does not have to be declared. Use the
- <computeroutput><mime-type></computeroutput>
- element to define which markup type your portlet supports,
- which in this example, is
- <computeroutput>text/html</computeroutput>
- . This section tells the portal that it only outputs HTML.
- </para>
- </callout>
- <callout arearefs="portletinfo">
- <para>
- When rendered, the portlet's title is displayed as the header
- in the portlet window, unless it is overridden
- programmatically. In this example, the title would be
- <computeroutput>HelloWorld Portlet</computeroutput>
- .
- </para>
- </callout>
+ <callout arearefs="tutorials.simplest.portletname">
+ <para>
+ Define the portlet name. It does not have to be the class name.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.portletclass">
+ <para>
+ The Fully Qualified Name (FQN) of your portlet class must be
+ declared here.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.supports">
+ <para>
+ The
+ <computeroutput><supports></computeroutput>
+ element declares all of the markup types that a portlet supports
+ in the
+ <literal>render</literal>
+ method. This is accomplished via the
+ <computeroutput><mime-type></computeroutput>
+ element, which is required for every portlet. The declared MIME
+ types must match the capability of the portlet. As well, it allows
+ you to pair which modes and window states are supported for each
+ markup type. All portlets must support the
+ <computeroutput>view</computeroutput>
+ portlet mode, so this does not have to be declared. Use the
+ <computeroutput><mime-type></computeroutput>
+ element to define which markup type your portlet supports, which
+ in this example, is
+ <computeroutput>text/html</computeroutput>
+ . This section tells the portal that it only outputs HTML.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.simplest.portletinfo">
+ <para>
+ When rendered, the portlet's title is displayed as the header in
+ the portlet window, unless it is overridden programmatically. In
+ this example, the title would be
+ <computeroutput>Simplest Hello World Portlet</computeroutput>
+ .
+ </para>
+ </callout>
</calloutlist>
- </programlistingco>
+ </programlistingco>
<para>
The
- <filename>HelloWorldPortlet/WEB-INF/portlet-instances.xml</filename>
+ <filename>
+ SimplestHelloWorldPortlet/WEB-INF/portlet-instances.xml
+ </filename>
file is a JBoss Portal specific descriptor, that allows you to create
instances of portlets. The
<computeroutput><portlet-ref></computeroutput>
value must match the
<computeroutput><portlet-name></computeroutput>
value given in the
- <filename>HelloWorldPortlet/WEB-INF/portlet.xml</filename>
+ <filename>SimplestHelloWorldPortlet/WEB-INF/portlet.xml</filename>
file. The
<computeroutput><instance-id></computeroutput>
value can be named anything, but it must match the
@@ -425,10 +481,12 @@
</para>
<para>
The following is an example of the
- <filename>SimplestHelloWorldPortlet/WEB-INF/portlet-instances.xml</filename>
+ <filename>
+ SimplestHelloWorldPortlet/WEB-INF/portlet-instances.xml
+ </filename>
file:
</para>
- <programlisting role="XML"><![CDATA[<?xml version="1.0" standalone="yes"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0" standalone="yes"?>
<!DOCTYPE deployments PUBLIC
"-//JBoss Portal//DTD Portlet Instances 2.6//EN"
"http://www.jboss.org/portlet/dtd/portlet-instances_2_6.dtd">
@@ -440,7 +498,7 @@
</instance>
</deployment>
</deployments>]]>
- </programlisting>
+ </programlisting>
<para>
The
<filename>*-object.xml</filename>
@@ -456,14 +514,14 @@
<listitem>
<para>
specifies that the window displays the markup generated by the
- <computeroutput>HelloWorldPortletInstance</computeroutput>
+ <computeroutput>SimplestHelloWorldInstance</computeroutput>
portlet instance.
</para>
</listitem>
<listitem>
<para>
- the window is assigned to the
- <computeroutput>default.default</computeroutput>
+ the window is assigned to the page that we are creating and called
+ <computeroutput>SimplestHelloWorld</computeroutput>
page.
</para>
</listitem>
@@ -481,17 +539,17 @@
<filename>SimplestHelloWorldPortlet/WEB-INF/default-object.xml</filename>
file:
</para>
- <programlistingco>
- <areaspec>
- <area id="parentref" coords='7' />
- <area id="ifexists" coords='8' />
- <area id="windowname" coords='12' />
- <area id="instanceref" coords='13' />
- <area id="region" coords='14' />
- <area id="height" coords='15' />
- </areaspec>
- <programlisting><![CDATA[
-<?xml version="1.0" encoding="UTF-8"?>
+ <programlistingco>
+ <areaspec>
+ <area id="tutorials.simplest.parentref" coords='7' />
+ <area id="tutorials.simplest.ifexists" coords='8' />
+ <area id="tutorials.simplest.pagename" coords='12' />
+ <area id="tutorials.simplest.windowname" coords='12' />
+ <area id="tutorials.simplest.instanceref" coords='13' />
+ <area id="tutorials.simplest.region" coords='14' />
+ <area id="tutorials.simplest.height" coords='15' />
+ </areaspec>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE deployments PUBLIC
"-//JBoss Portal//DTD Portal Object 2.6//EN"
"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
@@ -512,63 +570,70 @@
</deployments>]]>
</programlisting>
<calloutlist>
- <callout arearefs="parentref">
- <para>
- Tells the portal where this portlet appears. In this case,
- <computeroutput>default.default</computeroutput>
- specifies that the portlet appears in the portal instance named
- <computeroutput>default</computeroutput>
- , and on the page named
- <computeroutput>default</computeroutput>
- .
- </para>
+ <callout arearefs="tutorials.simplest.parentref">
+ <para>
+ Tells the portal where this portlet appears. In this case,
+ <computeroutput>default.default</computeroutput>
+ specifies that the portlet appears in the portal instance named
+ <computeroutput>default</computeroutput>
+ , and on the page named
+ <computeroutput>default</computeroutput>
+ .
+ </para>
</callout>
- <callout arearefs="ifexists">
- <para>
- Instructs the portal to overwrite or keep this object if it
- already exists. Accepted values are
- <computeroutput>overwrite</computeroutput>
- and
- <computeroutput>keep</computeroutput>
- . The
- <computeroutput>overwrite</computeroutput>
- option destroys the existing object, and creates a new one
- based on the content of the deployment. The
- <computeroutput>keep</computeroutput>
- option maintains the existing object deployment, or creates a
- new one if it does not exist.
- </para>
+ <callout arearefs="tutorials.simplest.ifexists">
+ <para>
+ Instructs the portal to overwrite or keep this object if it
+ already exists. Accepted values are
+ <computeroutput>overwrite</computeroutput>
+ and
+ <computeroutput>keep</computeroutput>
+ . The
+ <computeroutput>overwrite</computeroutput>
+ option destroys the existing object, and creates a new one based
+ on the content of the deployment. The
+ <computeroutput>keep</computeroutput>
+ option maintains the existing object deployment, or creates a new
+ one if it does not exist.
+ </para>
</callout>
- <callout arearefs="windowname">
- <para>
- A
- <emphasis role="bold">unique name</emphasis>
- given to the portlet window. This can be named anything.
- </para>
+ <callout arearefs="tutorials.simplest.pagename">
+ <para>
+ Here we are creating a new page to put the new window on. We give
+ that new page a name that will be by default used on the tab of
+ the default theme.
+ </para>
</callout>
- <callout arearefs="instanceref">
- <para>
- The value of
- <computeroutput><instance-ref></computeroutput>
- must match the value of one of the
- <computeroutput><instance-id></computeroutput>
- elements found in the
- <filename>
- HelloWorldPortlet/WEB-INF/portlet-instances.xml
- </filename>
- file.
- </para>
+ <callout arearefs="tutorials.simplest.windowname">
+ <para>
+ A
+ <emphasis role="bold">unique name</emphasis>
+ given to the portlet window. This can be named anything.
+ </para>
</callout>
- <callout arearefs="region">
- <para>
- Specifies where the window appears within the page layout.
- </para>
+ <callout arearefs="tutorials.simplest.instanceref">
+ <para>
+ The value of
+ <computeroutput><instance-ref></computeroutput>
+ must match the value of one of the
+ <computeroutput><instance-id></computeroutput>
+ elements found in the
+ <filename>
+ HelloWorldPortlet/WEB-INF/portlet-instances.xml
+ </filename>
+ file.
+ </para>
</callout>
- <callout arearefs="height">
- <para>
- Specifies where the window appears within the page layout.
- </para>
+ <callout arearefs="tutorials.simplest.region">
+ <para>
+ Specifies where the window appears within the page layout.
+ </para>
</callout>
+ <callout arearefs="tutorials.simplest.height">
+ <para>
+ Specifies where the window appears within the page layout.
+ </para>
+ </callout>
</calloutlist>
</programlistingco>
<para>
@@ -577,15 +642,15 @@
,
<filename>portlet-instances.xml</filename>
, and
- <filename>helloworld-object.xml</filename>
+ <filename>default-object.xml</filename>
descriptors:
</para>
<para>
<mediaobject>
<imageobject>
- <imagedata align="center"
- fileref="images/tutorials/first_portlet/desc_relationship.gif"
- valign="middle" />
+ <imagedata
+ fileref="images/tutorials/first_portlet/desc_relationship.png"
+ align="center" scalefit="1" />
</imageobject>
</mediaobject>
</para>
@@ -602,8 +667,7 @@
following is an example deployment descriptor that uses the new content
framework:
</para>
- <programlisting role="XML"><![CDATA[
-<?xml version="1.0" encoding="UTF-8"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE deployments PUBLIC
"-//JBoss Portal//DTD Portal Object 2.6//EN"
"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
@@ -622,7 +686,7 @@
</window>
</deployment>
</deployments>]]>
- </programlisting>
+ </programlisting>
<para>
This declaration is equivalent to the previous
@@ -637,14 +701,14 @@
. The
<computeroutput><content-uri></computeroutput>
element specifies which content to display, which in this example, is the
- <computeroutput>HelloWorldPortletInstance</computeroutput>
+ <computeroutput>SimplestHelloWorldInstance</computeroutput>
:
</para>
- <programlisting role="XML"><![CDATA[<content>
+ <programlisting role="XML"><![CDATA[<content>
<content-type>portlet</content-type>
- <content-uri>HelloWorldPortletInstance</content-uri>
+ <content-uri>SimplestHelloWorldInstance</content-uri>
</content>]]>
- </programlisting>
+ </programlisting>
<para>
To display certain content or a file, use the
<computeroutput>cms</computeroutput>
@@ -653,285 +717,115 @@
element being the path to the file in the CMS. This behavior is pluggable:
you can plug in almost any type of content.
</para>
+ <note>
+ <title>Beware of context-path change</title>
+ <para>
+ If the context-path change the portal may not be able to find a
+ reference on your portlets anymore. For that reason it's recommended to
+ add the following descriptor
+ <literal>WEB-INF/jboss-portlet.xml</literal>
+ which is not mandatory:
+ </para>
+ <programlisting><![CDATA[<!DOCTYPE portlet-app PUBLIC
+ "-//JBoss Portal//DTD JBoss Portlet 2.6//EN"
+ "http://www.jboss.org/portal/dtd/jboss-portlet_2_6.dtd">
+
+<portlet-app>
+ <app-id>SimplestHelloWorld</app-id>
+</portlet-app>]]></programlisting>
+ </note>
</sect3>
- <sect3 id="first_portlet_build">
- <title>Building your Portlet</title>
- <para>
- The
- <filename>HelloWorldPortlet.zip</filename>
- file contains a pre-compiled
- <filename>helloworldportlet.war</filename>
- file; however, to manually build the
- <filename>helloworldportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
- <para>
- Change into the
- <filename>HelloWorldPortlet/</filename>
- directory, and remove the existing
- <filename>helloworldportlet.war</filename>
- file.
- </para>
- </listitem>
- <listitem>
- <para>
- If required, edit the
- <filename>
- HelloWorldPortlet/src/main/org/jboss/portlet/hello/HelloWorldPortlet.java
- </filename>
- file, and the application descriptors in the
- <filename>
- HelloWorldPortlet/src/resources/helloworldportlet-war/WEB-INF/
- </filename>
- directory.
- </para>
- </listitem>
- <listitem>
- <para>
- Change into
- <filename>HelloWorldPortlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. On Windows, the output will be similar to the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/first_portlet/building.gif"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
- <para>
- Expanding the
- <filename>helloworldportlet.war</filename>
- file allows you to deploy the portlet as an expanded directory, which makes
- development easier. As well, it gives you access to the application
- descriptors, resource files, JSF, and JSP pages. To expand the
- <filename>helloworldportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
- <para>
- If you do not have the
- <filename>HelloWorldPortlet/helloworldportlet.war</filename>
- file, change into the
- <filename>HelloWorldPortlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. This creates the
- <filename>helloworldportlet.war</filename>
- file.
- </para>
- </listitem>
- <listitem>
- <para>
- To expand the WAR file, change into the
- <filename>HelloWorldPortlet/</filename>
- directory, and run the
- <command>ant explode</command>
- command. On Windows, the output will be similar to the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/first_portlet/buildexplode.gif"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
- <para>
- The
- <command>ant explode</command>
- command creates a directory structure such as the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/first_portlet/exploded.gif"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- The expanded WAR file and the application descriptors are located in the
- <filename>
- HelloWorldPortlet/output/lib/exploded/helloworldportlet.war/WEB-INF/
- </filename>
- directory.
- </para>
- </sect3>
- <sect3>
- <title>Deploying your Portlet</title>
- <para>
- If you did not expand the
- <filename>helloworldportlet.war</filename>
- file, copy the
- <filename>HelloWorldPortlet/helloworldportlet.war</filename>
- file into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. If you expanded the
- <filename>helloworldportlet.war</filename>
- file, copy the
- <filename>
- HelloWorldPortlet/output/lib/exploded/helloworldportlet.war/
- </filename>
- directory into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. For example, if you are using the
- <computeroutput>default</computeroutput>
- JBoss AS profile, copy the WAR file or the expanded directory into the
- <filename>$JBOSS_HOME/server/default/deploy/</filename>
- directory.
- </para>
- <para>
- Performing this step on a running instance of JBoss AS or JBoss EAP, and
- JBoss Portal, triggers a hot-deploy of the portlet:
- </para>
- <para>
- <screen><![CDATA[
-INFO [TomcatDeployer] deploy, ctxPath=/helloworldportlet,
-warUrl=.../tmp/deploy/tmp35219helloworldportlet-exp.war/]]></screen>
- </para>
- <para>
- To see the HelloWorldPortlet, navigate to
- <ulink url="http://localhost:8080/portal/">
- http://localhost:8080/portal/
- </ulink>
- , or, if the default JBoss Portal page is already open, refresh the page.
- The HelloWorldPortlet is added to the bottom of the default JBoss Portal
- page:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/first_portlet/output.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- To re-deploy the portlet, for example, if you have made changes to any of
- the application descriptors, touch the
- <filename>
- $JBOSS_HOME/server/
- <replaceable>configuration</replaceable>
- /deploy/helloworldportlet.war/WEB-INF/web.xml
- </filename>
- file. This only works if you copied the
- <filename>
- HelloWorldPortlet/output/lib/exploded/helloworldportlet.war/
- </filename>
- directory into the JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. On Linux, run the <command>touch $JBOSS_HOME/server/<replaceable>configuration</replaceable>/deploy/helloworldportlet.war/WEB-INF/web.xml</command> command to re-deploy the HelloWorldPortlet.
- </para>
- <para>
- Re-deploying the HelloWorldPortlet produces output to the JBoss AS or JBoss
- EAP console, similar to the following:
- </para>
- <para>
- <screen><![CDATA[
-INFO [TomcatDeployer] undeploy, ctxPath=/helloworldportlet,
-warUrl=.../deploy/helloworldportlet.war/
-INFO [TomcatDeployer] deploy, ctxPath=/helloworldportlet,
-warUrl=.../deploy/helloworldportlet.war/]]>
- </screen>
- </para>
- </sect3>
</sect2>
<sect2>
<title>
- An example
- <trademark class="trade">JavaServer</trademark>
- Pages (
- <trademark class="trade">JSP</trademark>
- ) portlet
+ <trademark class="trade">JavaServer</trademark>
+ Pages Portlet Example
</title>
<sect3>
<title>Introduction</title>
<para>
- This section describes how to deploy a
- <trademark class="trade">JSP</trademark>
- portlet in JBoss Portal. Before proceeding, download the
- <ulink
- url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_4/bundles/HelloWorl...">
- HelloWorldJSPPortlet
- </ulink>
- from
- <ulink url="http://labs.jboss.com/portletswap/">JBoss PortletSwap</ulink>
- . The HelloWorldJSPPortlet demonstrates how to use JSP pages for view
- rendering, and the portlet tag library (taglib) for generating links.
+ Now we will add more features to the previous example and also use a JSP
+ page to render the markup. We will use the portlet tag library to generate
+ links to our portlet in different ways and use the other standard portlet
+ modes. This example can be found in the directory
+ <literal>JSPHelloUser</literal>.
+ Use <literal>mvn package</literal> then copy <filename>JSPHelloUser/target/JSPHelloUser-0.0.1.war</filename>
+ in the <literal>deploy</literal> directory of JBoss Application Server.
+ Point your brwoser to <literal></literal>, you should see the following:
+ <mediaobject>
+ <imageobject>
+ <imagedata
+ fileref="images/tutorials/jsp_portlet/output.png"
+ align="center" scalefit="1" />
+ </imageobject>
+ </mediaobject>
+ <note>
+ <para>The <literal>EDIT</literal> button only appears with logged-in users, which is not the case
+ on the screenshot</para>
+ </note>
</para>
</sect3>
<sect3>
<title>Package Structure</title>
<para>
- The application descriptors for the HelloWorldJSPPortlet portlet are
- similar to those from the HelloWorldPortlet (
- <xref linkend="first_portlet_descriptors" />
- ). Refer to
- <xref linkend="descriptors_portlet" />
- for further information about application descriptors.
+ The structure doesn't change much at the exception of adding some JSP files
+ detailed later.
</para>
<para>
- The HelloWorldJSPPortlet portlet contains the traditional portlet and JBoss
- Portal specific application descriptors. The following is an example of the
- directory structure of the HelloWorldJSPPortlet portlet:
+ The JSPHelloUser portlet contains the traditional portlet and JBoss Portal
+ specific application descriptors. The following is an example of the
+ directory structure of the JSPHelloUser portlet:
</para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsp_portlet/package.gif"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- To create the
- <filename>WEB-INF/</filename>
- and
- <filename>META-INF/</filename>
- directories, extract the
- <filename>helloworldjspportlet.war</filename>
- file.
- </para>
+ <programlisting><![CDATA[JSPHelloUser-0.0.1.war
+ |-- META-INF
+ | |-- MANIFEST.MF
+ | `-- maven
+ | `-- org.jboss.portal.example
+ | `-- JSPHelloUser
+ | |-- pom.properties
+ | `-- pom.xml
+ |-- WEB-INF
+ | |-- classes
+ | | `-- org
+ | | `-- jboss
+ | | `-- portal
+ | | `-- portlet
+ | | `-- samples
+ | | `-- JSPHelloUserPortlet.class
+ | |-- default-object.xml
+ | |-- jboss-portlet.xml
+ | |-- portlet-instances.xml
+ | |-- portlet.xml
+ | `-- web.xml
+ `-- jsp
+ |-- edit.jsp
+ |-- hello.jsp
+ |-- help.jsp
+ `-- welcome.jsp]]>
+ </programlisting>
</sect3>
<sect3>
- <title>Portlet Classes</title>
+ <title>Portlet Class</title>
+ <bridgehead>Let's study the Java class in detail.</bridgehead>
<para>
- The
- <ulink
- url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_4/bundles/HelloWorl...">
- HelloWorldJSPPortlet
- </ulink>
- contains the
+ The following file is the
<filename>
- HelloWorldJSPPortlet/src/main/org/jboss/portlet/hello/HelloWorldJSPPortlet.java
+ JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/JSPHelloUserPortlet.java
</filename>
- file:
+ Java source. It is split in different pieces.
</para>
- <programlisting role="JAVA"><![CDATA[
-package org.jboss.portlet.hello;
+ <programlistingco>
+ <areaspec>
+ <area id="tutorials.jsphello.doView" coords='18' />
+ <area id="tutorials.jsphello.renderParameter" coords='21' />
+ <area id="tutorials.jsphello.requestDispatcher" coords='25' />
+ <area id="tutorials.jsphello.include" coords='26' />
+ </areaspec>
+ <programlisting role="JAVA"><![CDATA[package org.jboss.portal.portlet.samples;
+package org.jboss.portal.portlet.samples;
+import java.io.IOException;
+
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
@@ -940,1615 +834,284 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.UnavailableException;
-import java.io.IOException;
-public class HelloWorldJSPPortlet extends GenericPortlet
+public class JSPHelloUserPortlet extends GenericPortlet
{
- protected void doView(RenderRequest rRequest, RenderResponse rResponse)
- throws PortletException, IOException, UnavailableException
+
+ public void doView(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException
{
- rResponse.setContentType("text/html");
-
- String sYourName = (String) rRequest.getParameter("yourname");
-
- if(sYourName != null)
+ String sYourName = (String) request.getParameter("yourname");
+ if (sYourName != null)
{
- rRequest.setAttribute("yourname", sYourName);
- PortletRequestDispatcher prd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/jsp/view2.jsp");
- prd.include(rRequest, rResponse);
+ request.setAttribute("yourname", sYourName);
+ PortletRequestDispatcher prd =
+ getPortletContext().getRequestDispatcher("/jsp/hello.jsp");
+ prd.include(request, response);
}
else
{
- PortletRequestDispatcher prd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/jsp/view.jsp");
- prd.include(rRequest, rResponse);
+ PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/welcome.jsp");
+ prd.include(request, response);
}
}
-
- public void processAction(ActionRequest aRequest, ActionResponse aResponse)
- throws PortletException, IOException, UnavailableException
+...]]></programlisting>
+ <calloutlist>
+ <callout arearefs="tutorials.jsphello.doView">
+ <para>
+ As in the first portlet, we override the
+ <emphasis>doView</emphasis>
+ method.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.jsphello.renderParameter">
+ <para>
+ Here we try to obtain the value of the render parameter names
+ <literal>yourname</literal>
+ . If defined we want to redirect to the
+ <filename>hello.jsp</filename>
+ JSP page, otherwise to the
+ <filename>welcome.jsp</filename>
+ JSP page.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.jsphello.requestDispatcher">
+ <para>
+ Very similar to the Servlet way, we get a request dispatcher on a
+ file located within the web archive.
+ </para>
+ </callout>
+ <callout arearefs="tutorials.jsphello.include">
+ <para>
+ The last step is to perform the inclusion of the markup obtained
+ from the JSP.
+ </para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+ <para>
+ We have seen the
+ <literal>VIEW</literal>
+ portlet mode, the spec defines two other modes that can be used called
+ <literal>EDIT</literal>
+ and
+ <literal>HELP</literal>
+ . In order to enable those modes, they will need to be defined in the
+ <filename>portlet.xml</filename>
+ descriptor as we will see later. Having those modes defined will enable the
+ corresponding buttons on the portlet's window.
+ </para>
+ <para>
+ The generic portlet that is inherited dispatches the different views to
+ methods named:
+ <literal>doView</literal>
+ ,
+ <literal>doHelp</literal>
+ and
+ <literal>doEdit</literal>
+ . Let's watch the code for those two last portlet modes.
+ </para>
+ <programlisting role="JAVA"><![CDATA[...
+ protected void doHelp(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException,
+ UnavailableException
{
- String sYourname = (String) aRequest.getParameter("yourname");
-
- // do something
-
- aResponse.setRenderParameter("yourname", sYourname);
- }
-
- protected void doHelp(RenderRequest rRequest, RenderResponse rResponse)
- throws PortletException, IOException, UnavailableException
- {
rResponse.setContentType("text/html");
- PortletRequestDispatcher prd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/jsp/help.jsp");
+ PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/help.jsp");
prd.include(rRequest, rResponse);
}
- protected void doEdit(RenderRequest rRequest, RenderResponse rResponse)
- throws PortletException, IOException, UnavailableException
+ protected void doEdit(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException,
+ UnavailableException
{
rResponse.setContentType("text/html");
- PortletRequestDispatcher prd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/jsp/edit.jsp");
+ PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/edit.jsp");
prd.include(rRequest, rResponse);
}
-}]]>
- </programlisting>
- <para>
- <variablelist>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-protected void doHelp(RenderRequest rRequest, RenderResponse rResponse)
- throws PortletException, IOException, UnavailableException]]>
- </programlisting>
- <programlisting><![CDATA[
-protected void doEdit(RenderRequest rRequest, RenderResponse rResponse)
- throws PortletException, IOException, UnavailableException]]>
- </programlisting>
- </term>
- <listitem>
- <para>
- Support for these modes must be declared in the
- <filename>HelloWorldJSPPortlet/WEB-INF/portlet.xml</filename>
- file. They are triggered when a user clicks on the respective
- icons in the portlet window titlebar, or through generated
- links within the portlet.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-public void processAction(ActionRequest aRequest, ActionResponse aResponse)
- throws PortletException, IOException, UnavailableException
-{
- String sYourname = (String) aRequest.getParameter("yourname");
+...]]></programlisting>
- // do something
-
- aResponse.setRenderParameter("yourname", sYourname);
-}]]></programlisting>
- </term>
- <listitem>
- <para>
- This method is triggered when a user clicks on an
- <computeroutput>actionURL</computeroutput>
- , which is defined in the
- <filename>HelloWorldJSPPortlet/WEB-INF/jsp/view.jsp</filename>
- file. This retrieves
- <computeroutput>yourname</computeroutput>
- from the HTML form, and passes it as a
- <computeroutput>aResponse.setRenderParameter</computeroutput>
- to the
- <literal>doView()</literal>
- method.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-rResponse.setContentType("text/html");]]>
- </programlisting>
- </term>
- <listitem>
- <para>
- As in the servlet world, you must declare what content-type the
- portlet will be responding in. Do this before starting to write
- content, or the portlet throws an exception.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-protected void doView(RenderRequest rRequest, RenderResponse rResponse)
- throws PortletException, IOException, UnavailableException]]>
- </programlisting>
- </term>
- <listitem>
- <para>
- The
- <literal>doView</literal>
- implementation is responsible for dispatching to the
- appropriate JSP,
- <filename>HelloWorldJSPPortlet/WEB-INF/jsp/view.jsp</filename>
- or
- <filename>HelloWorldJSPPortlet/WEB-INF/jsp/view2.jsp</filename>
- , depending on the existence of the
- <literal>yourname</literal>
- parameter passed in from
- <literal>processAction</literal>
- .
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
- </sect3>
- <sect3>
- <title>
- <trademark class="trade">JSP</trademark>
- files and the Portlet Tag Library
- </title>
<para>
- The
- <filename>HelloWorldJSPPortlet/WEB-INF/jsp/view.jsp</filename>
- and
- <filename>HelloWorldJSPPortlet/WEB-INF/jsp/view2.jsp</filename>
- <trademark class="trade">JSP</trademark>
- files are included in the HelloWorldJSPPortlet portlet. The
- <filename>view.jsp</filename>
- file allows a user to input their name. This is then posted to the
- <computeroutput>processAction</computeroutput>
- method in the portlet class, which is set as a
- <computeroutput>aResponse.setRenderParameter</computeroutput>
- . The
- <computeroutput>doView</computeroutput>
- <literal>render</literal>
- method is invoked, which dispatches to the
- <filename>view2.jsp</filename>
- JSP:
+ If you have read the portlet specification carefully you should have notice
+ that portlet calls happen in one or two phases. One when the portlet is
+ just rendered, two when the portlet is actionned then rendered. An action
+ phase is a phase where some state change. The render phase will have access
+ to render parameters that will be passed each time the portlet is refreshed
+ (with the exception of caching capabilities).
</para>
<para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsp_portlet/process.gif"
- valign="middle" />
- </imageobject>
- </mediaobject>
+ The code to be executed during an action has to be implemented in the
+ <emphasis>processAction</emphasis>
+ method of the portlet.
</para>
- <para>
- The following is an example of the
- <filename>HelloWorldJSPPortlet/WEB-INF/jsp/view.jsp</filename>
- file:
- </para>
- <programlisting><![CDATA[
-<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
-
-<portlet:defineObjects/>
-
-<div align="center">
- This is a simple HelloWorld JSP Portlet. Type in a name and it will dispatch
- to the view2.jsp to print out your name.
- <br/>
-
- <form action="<portlet:actionURL><portlet:param name="page" value="mainview"/>
- </portlet:actionURL>" method="POST">
- Name:<br/>
- <input type="text" name="yourname"/>
- </form>
- <br/>
- You can also link to other pages, using a renderURL, like <a
- href="<portlet:renderURL><portlet:param name="yourname" value="Roy Russo">
- </portlet:param></portlet:renderURL>">this</a>.
-</div>]]></programlisting>
- <para>
- <variablelist>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- Define the portlet taglib. You do not need to bundle the
- portlet taglib - JBoss Portal handles this for you.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
-<programlisting><![CDATA[
-<portlet:defineObjects/>]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- Calling
- <literal>defineObjects</literal>
- makes available implicit objects in the JSP, such as
- <literal>renderRequest</literal>
- ,
- <literal>actionRequest</literal>
- , and
- <literal>portletConfig</literal>
- .
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<form action="<portlet:actionURL><portlet:param name="page" value="mainview"/>
- </portlet:actionURL>" method="POST">]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- A HTML form is created. This form posts to the URL defined by
- the portlet taglib. In this example, an
- <computeroutput>actionURL</computeroutput>
- is created, that activates the
- <literal>processAction</literal>
- method, which passes the input parameters from the form.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<a href="<portlet:renderURL><portlet:param name="yourname" value="Roy Russo">
-</portlet:param></portlet:renderURL>">]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- You can create a link to the
- <computeroutput>doView</computeroutput>
- method by creating a
- <computeroutput>renderURL</computeroutput>
- , which passes the
- <computeroutput>yourname</computeroutput>
- parameter.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
- </sect3>
- <sect3>
- <title>
- Building your
- <trademark class="trade">JSP</trademark>
- portlet
- </title>
- <para>
- The
- <filename>HelloWorldJSPPortlet.zip</filename>
- file contains a pre-compiled
- <filename>helloworldjspportlet.war</filename>
- file; however, to manually build the
- <filename>helloworldjspportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
+ <programlistingco>
+ <areaspec>
+ <area id="tutorials.jsphello.processAction" coords='2' />
+ <area id="tutorials.jsphello.getActionParameter" coords='5' />
+ <area id="tutorials.jsphello.setRenderParameter" coords='6' />
+ </areaspec>
+ <programlisting role="JAVA"><![CDATA[...
+ public void processAction(ActionRequest aRequest, ActionResponse aResponse) throws PortletException, IOException,
+ UnavailableException
+ {
+ String sYourname = (String) aRequest.getParameter("yourname");
+ aResponse.setRenderParameter("yourname", sYourname);
+ }
+...]]></programlisting>
+ <calloutlist>
+ <callout arearefs="tutorials.jsphello.processAction">
<para>
- Change into the
- <filename>HelloWorldJSPPortlet/</filename>
- directory, and remove the existing
- <filename>helloworldjspportlet.war</filename>
- file.
+ <literal>processAction</literal>
+ is the method from GernericPorlet to override for the
+ <emphasis>action</emphasis>
+ phase.
</para>
- </listitem>
- <listitem>
+ </callout>
+ <callout arearefs="tutorials.jsphello.getActionParameter">
<para>
- If required, edit the
- <filename>
- HelloWorldJSPPortlet/src/main/org/jboss/portlet/hello/HelloWorldJSPPortlet.java
- </filename>
- file, and the application descriptors in the
- <filename>
- HelloWorldJSPPortlet/src/resources/helloworldjspportlet-war/WEB-INF/
- </filename>
- directory.
+ Here we retrieve the parameter obtained through an
+ <emphasis>action URL</emphasis>
+ .
</para>
- </listitem>
- <listitem>
+ </callout>
+ <callout arearefs="tutorials.jsphello.setRenderParameter">
<para>
- Change into
- <filename>HelloWorldJSPPortlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. On Linux, the output will be similar to the following:
+ Here we need to keep the value of
+ <literal>yourname</literal>
+ to make it available in the rendering phase. With the previous
+ line, we are simply copying an action parameter to a render
+ parameter for the sake of this example.
</para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsp_portlet/jsp_ant_deploy.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
- <para>
- Expanding the
- <filename>helloworldjspportlet.war</filename>
- file allows you to deploy the portlet as an expanded directory, which makes
- development easier. As well, it gives you access to the application
- descriptors, resource files, JSF, and
- <trademark class="trade">JSP</trademark>
- pages. To expand the
- <filename>helloworldjspportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
- <para>
- If you do not have the
- <filename>HelloWorldJSPPortlet/helloworldjspportlet.war</filename>
- file, change into the
- <filename>HelloWorldJSPPortlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. This creates the
- <filename>helloworldjspportlet.war</filename>
- file.
- </para>
- </listitem>
- <listitem>
- <para>
- To expand the WAR file, change into the
- <filename>HelloWorldJSPPortlet/</filename>
- directory, and run the
- <command>ant explode</command>
- command. On Linux, the output will be similar to the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsp_portlet/jsp_ant_explode.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
- <para>
- The
- <command>ant explode</command>
- command creates a directory structure such as the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsp_portlet/exploded.gif"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- The expanded WAR file and the application descriptors are located in the
- <filename>
- HelloWorldJSPPortlet/output/lib/exploded/helloworldjspportlet.war/WEB-INF/
- </filename>
- directory.
- </para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
</sect3>
<sect3>
<title>
- Deploying your
<trademark class="trade">JSP</trademark>
- portlet
+ files and the Portlet Tag Library
</title>
+ <bridgehead>Let's have a look inside the JSP pages.</bridgehead>
<para>
- If you did not expand the
- <filename>helloworldjspportlet.war</filename>
- file, copy the
- <filename>HelloWorldJSPPortlet/helloworldjspportlet.war</filename>
- file into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. If you expanded the
- <filename>helloworldjspportlet.war</filename>
- file, copy the
- <filename>
- HelloWorldJSPPortlet/output/lib/exploded/helloworldjspportlet.war/
- </filename>
- directory into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. For example, if you are using the
- <computeroutput>default</computeroutput>
- JBoss AS profile, copy the WAR file or the expanded directory into the
- <filename>$JBOSS_HOME/server/default/deploy/</filename>
- directory.
- </para>
- <para>
- Performing this step on a running instance of JBoss AS or JBoss EAP, and
- JBoss Portal, triggers a hot-deploy of the portlet:
- </para>
- <para>
- <screen><![CDATA[
-INFO [TomcatDeployer] deploy, ctxPath=/helloworldjspportlet,
-warUrl=.../deploy/helloworldjspportlet.war/]]>
- </screen>
- </para>
- <para>
- To see the HelloWorldJSPPortlet, navigate to
- <ulink url="http://localhost:8080/portal/"></ulink>
- , or, if the default JBoss Portal page is already open, refresh the page.
- The HelloWorldJSPPortlet is added to the bottom of the default JBoss Portal
- page:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsp_portlet/output.png" valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- To re-deploy the portlet, for example, if you have made changes to any of
- the application descriptors, touch the
- <filename>
- $JBOSS_HOME/server/
- <replaceable>configuration</replaceable>
- /deploy/helloworldjspportlet.war/WEB-INF/web.xml
- </filename>
- file. This only works if you copied the
- <filename>
- HelloWorldJSPPortlet/output/lib/exploded/helloworldjspportlet.war/
- </filename>
- directory into the JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. On Linux, run the <command>touch $JBOSS_HOME/server/<replaceable>configuration</replaceable>/deploy/helloworldjspportlet.war/WEB-INF/web.xml</command> command to re-deploy the HelloWorldJSPPortlet.
- </para>
- <para>
- Re-deploying the HelloWorldJSPPortlet produces output to the JBoss AS or
- JBoss EAP console, similar to the following:
- </para>
- <para>
- <screen><![CDATA[
-INFO [TomcatDeployer] undeploy, ctxPath=/helloworldjspportlet,
-warUrl=.../deploy/helloworldjspportlet.war/
-INFO [TomcatDeployer] deploy, ctxPath=/helloworldjspportlet,
-warUrl=.../deploy/helloworldjspportlet.war/]]>
- </screen>
- </para>
- </sect3>
- </sect2>
- <sect2 id="sunri_42x">
- <title>
- An example
- <trademark class="trade">Sun</trademark>
- JSF Reference Implementation (RI) portlet
- </title>
- <sect3>
- <title>Introduction</title>
- <para>
- This section describes how to deploy a JSF portlet in JBoss Portal, using
- the Apache MyFaces JSF implementation in JBoss AS and JBoss EAP. Before
- proceeding, download the
- <ulink
- url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/HelloWorl...">
- HelloWorldJSFSunRIPortlet
- </ulink>
- from
- <ulink url="http://labs.jboss.com/portletswap/">JBoss PortletSwap</ulink>
- .
- </para>
- </sect3>
- <sect3>
- <title>Package Structure</title>
- <para>
- JBoss Portal requires certain descriptors to be included in a portlet WAR
- file. Some of these descriptors are defined by the JSR-168 Portlet
- Specification, and others are specific to JBoss Portal. Like a typical JSF
- application, the HelloWorldJSFSunRIPortlet package contains a
- <filename>faces-config.xml</filename>
- file that defines managed-beans, converters, validators, navigation rules,
- and so on. The following is an example of the directory structure of the
- HelloWorldJSFSunRIPortlet portlet:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/package_sunri.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- To create the
- <filename>WEB-INF/</filename>
+ The
+ <filename>help.jsp</filename>
and
- <filename>META-INF/</filename>
- directories, extract the
- <filename>helloworldjsfsunriportlet.war</filename>
- file.
+ <filename>edit.jsp</filename>
+ files are very simple, they simply display some text. Note that we used CSS
+ styles as defined in the portlet specification. It ensures that the portlet
+ will look "good" within the theme and accross portal vendors.
</para>
+ <programlisting role="XHTML"><![CDATA[<div class="portlet-section-header">Help mode</div>
+<div class="portlet-section-body">This is the help mode, a convenient place to give the user some help information.</div>]]></programlisting>
+ <programlisting role="XHTML"><![CDATA[<div class="portlet-section-header">Edit mode</div>
+<div class="portlet-section-body">This is the edit mode, a convenient place to let the user change his portlet preferences.</div>]]></programlisting>
<para>
- <note>
- <title>
- Bundled
- <trademark class="trade">Sun</trademark>
- JSF RI
- </title>
- <para>
- JBoss AS version 4.2.
- <replaceable>x</replaceable>
- and JBoss EAP bundle the
- <trademark class="trade">Sun</trademark>
- JSF RI libraries in the
- <filename>
- $JBOSS_HOME/server/default/deploy/jboss-web.deployer/jsf-libs/
- </filename>
- directory. Therefore, you do not need to package the Sun JSF RI
- libraries with your portlet application.
- </para>
- </note>
+ Now let's have a look at the landing page, it contains the links and form
+ to call our portlet.
</para>
- </sect3>
- <sect3>
- <title>Application Descriptors</title>
- <para>
- Only the
- <filename>portlet.xml</filename>
- ,
- <filename>faces-config.xml</filename>
- , and
- <filename>web.xml</filename>
- descriptors are described here. For more information about application
- descriptors, refer to
- <xref linkend="first_portlet_descriptors" />
- and
- <xref linkend="descriptors_portlet" />
- .
- </para>
- <para>
- The following is an example of the
- <filename>HelloWorldJSFSunRIPortlet/WEB-INF/portlet.xml</filename>
- file. This file must adhere to its definition in the JSR-168 Portlet
- Specification. You may define more than one portlet application in this
- file:
- </para>
- <programlisting role="XML"><![CDATA[
-<?xml version="1.0" encoding="UTF-8"?>
-<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
- 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"
- version="1.0">
- <portlet>
- <portlet-name>HelloWorldJSFPortlet</portlet-name>
- <portlet-class>com.sun.faces.portlet.FacesPortlet</portlet-class>
- <init-param>
- <name>com.sun.faces.portlet.INIT_VIEW</name>
- <value>/WEB-INF/jsp/index.jsp</value>
- </init-param>
- <supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>view</portlet-mode>
- </supports>
- <portlet-info>
- <title>HelloWorld JSF Portlet</title>
- </portlet-info>
- </portlet>
-</portlet-app>]]>
- </programlisting>
- <para>
- <variablelist>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<portlet-class>com.sun.faces.portlet.FacesPortlet</portlet-class>]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- This specifies that the
- <computeroutput>
- com.sun.faces.portlet.FacesPortlet
- </computeroutput>
- handles all requests and responses from the users. This class
- is part of the
- <filename>
- HelloWorldJSFSunRIPortlet/WEB-INF/lib/jsf-portlet.jar
- </filename>
- file.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<init-param>
- <name>com.sun.faces.portlet.INIT_VIEW</name>
- <value>/WEB-INF/jsp/index.jsp</value>
-</init-param>]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- You must initialize the portlet with a default page to render,
- similar to a welcome page.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>view</portlet-mode>
-</supports>]]></programlisting>
- </term>
- <listitem>
- <para>
- The
- <computeroutput><supports></computeroutput>
- element allows you to declare all of the markup types that a
- portlet supports in the
- <literal>render</literal>
- method. This is accomplished via the
- <computeroutput><mime-type></computeroutput>
- element, which is required for every portlet. The declared MIME
- types must match the capability of the portlet. As well, it
- allows you to pair which modes and window states are supported
- for each markup type. All portlets must support the
- <computeroutput>view</computeroutput>
- portlet mode, so this does not have to be declared. Use the
- <computeroutput><mime-type></computeroutput>
- element to define which markup type your portlet supports,
- which in this example, is
- <computeroutput>text/html</computeroutput>
- . This section tells the portal that it only outputs text and
- HTML, and that it only supports the
- <computeroutput>view</computeroutput>
- mode.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
- <para>
- The following is an example
- <filename>HelloWorldJSFSunRIPortlet/WEB-INF/faces-config.xml</filename>
- file:
- </para>
- <programlisting role="XML"><![CDATA[
-<?xml version="1.0"?>
-<!DOCTYPE faces-config PUBLIC
- "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
-<faces-config>
- <managed-bean>
- <description>Basic UserBean</description>
- <managed-bean-name>user</managed-bean-name>
- <managed-bean-class>org.jboss.portlet.hello.bean.User</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
-
- <navigation-rule>
- <navigation-case>
- <from-outcome>done</from-outcome>
- <to-view-id>/WEB-INF/jsp/result.jsp</to-view-id>
- </navigation-case>
- </navigation-rule>
-</faces-config>]]>
- </programlisting>
- <para>
- Without the
- <filename>faces-config.xml</filename>
- file, the application would work the same outside of the portlet as it
- would inside a portlet container. In this example, a basic user bean,
- <computeroutput>
- <managed-bean-name>user</managed-bean-name>
- </computeroutput>
- , and a navigation rule are defined, which handle the submission of the
- original form in the
- <filename>HelloWorldJSFSunRIPortlet/WEB-INF/jsp/index.jsp</filename>
- file.
- </para>
- <para>
- The following is an example of the
- <computeroutput>Faces Servlet</computeroutput>
- and
- <computeroutput>Faces Servlet Mapping</computeroutput>
- sections from the
- <filename>HelloWorldJSFSunRIPortlet/WEB-INF/web.xml</filename>
- file:
- </para>
- <programlisting role="XML"><![CDATA[
-<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
+ <programlistingco>
+ <areaspec>
+ <area id="tutorials.jsphello.taglib" coords='1' />
+ <area id="tutorials.jsphello.method1" coords='13' />
+ <area id="tutorials.jsphello.method2.1" coords='20' />
+ <area id="tutorials.jsphello.method2.2" coords='24' />
+ <area id="tutorials.jsphello.method3.1" coords='30' />
+ <area id="tutorials.jsphello.method3.2" coords='31' />
+ </areaspec>
- <!-- Faces Servlet -->
- <servlet>
- <servlet-name>Faces Servlet</servlet-name>
- <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
+ <programlisting role="JSP"><![CDATA[<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
+<div class="portlet-section-header">Welcome !</div>
- <!-- Faces Servlet Mapping -->
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>*.jsf</url-pattern>
- </servlet-mapping>
+<br/>
-</web-app>]]>
- </programlisting>
- <para>
- For Sun JSF RI portlets, the
- <computeroutput>Faces Servlet</computeroutput>
- and
- <computeroutput>Faces Servlet Mapping</computeroutput>
- sections are required to associate files with the
- <filename>.jsf</filename>
- extension to the Apache MyFaces servlet.
- </para>
- <para>
- <warning>
- <title>Classes for the JSF-Portlet bridge are not included</title>
- <para>
- Unlike Apache MyFaces, the classes for the JSF-Portlet bridge are not
- included in the JSF implementation, JBoss AS, or JBoss EAP. This
- library must be available in your application package. Navigate to
- the
- <ulink
- url="https://jsfportletbridge.dev.java.net/servlets/ProjectDocumentList">
- JSF-Portlet bridge webpage
- </ulink>
- to download the JSF-Portlet bridge library.
- </para>
- </warning>
- </para>
- </sect3>
- <sect3>
- <title>Building your JSF portlet</title>
- <para>
- The
- <filename>HelloWorldJSFSunRIPortlet.zip</filename>
- file contains a pre-compiled
- <filename>helloworldjsfsunriportlet.war</filename>
- file; however, to manually build the
- <filename>helloworldjsfsunriportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
+<div class="portlet-font">Welcome on the JSP Hello User portlet,
+my name is JBoss Portal. What's yours ?</div>
+
+<br/>
+
+<div class="portlet-font">Method 1: We simply pass the parameter to the render phase:<br/>
+<a href="<portlet:renderURL><portlet:param name="yourname" value="John Doe"/>
+ </portlet:renderURL>">John Doe</a></div>
+
+<br/>
+
+<div class="portlet-font">Method 2: We pass the parameter to the render phase, using valid XML:
+Please check the source code to see the difference with Method 1.
+<portlet:renderURL var="myRenderURL">
+ <portlet:param name="yourname" value='John Doe'/>
+</portlet:renderURL>
+<br/>
+<a href="<%= myRenderURL %>">John Doe</a></div>
+
+<br/>
+
+<div class="portlet-font">Method 3: We use a form:<br/>
+
+<portlet:actionURL var="myActionURL"/>
+<form action="<%= myActionURL %>" method="POST">
+ <span class="portlet-form-field-label">Name:</span>
+ <input class="portlet-form-input-field" type="text" name="yourname"/>
+ <input class="portlet-form-button" type="Submit"/>
+</form>
+</div>]]></programlisting>
+ <calloutlist>
+ <callout arearefs="tutorials.jsphello.taglib">
<para>
- Change into the
- <filename>HelloWorldJSFSunRIPortlet/</filename>
- directory, and remove the existing
- <filename>helloworldjsfsunriportlet.war</filename>
- file.
+ Since we will use the portlet taglib, we first need to declare it.
</para>
- </listitem>
- <listitem>
+ </callout>
+ <callout arearefs="tutorials.jsphello.method1">
<para>
- If required, edit the
- <filename>
- HelloWorldJSFSunRIPortlet/src/main/org/jboss/portlet/hello/bean/User.java
- </filename>
- file, and the application descriptors in the
- <filename>
- HelloWorldJSFSunRIPortlet/src/resources/helloworldjsfsunriportlet-war/WEB-INF/
- </filename>
- directory.
+ The first method showed here is the simplest one,
+ <literal>portlet:renderURL</literal>
+ will create a URL that will call the render phase of the current
+ portlet and append the result at the place of the markup (Here
+ within a tag...). We also added a parameter directly on the URL.
</para>
- </listitem>
- <listitem>
+ </callout>
+ <callout arearefs="tutorials.jsphello.method2.1">
<para>
- Change into
- <filename>HelloWorldJSFSunRIPortlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. On Linux, the output will be similar to the following:
+ In this method instead of having a tag within another tag, which
+ is not XML valid, we use the
+ <literal>var</literal>
+ attribute. Instead of printing the url the
+ <literal>portlet:renderURL</literal>
+ tag will store the result in the referenced variable (
+ <literal>myRenderURL</literal>
+ in our case).
</para>
+ </callout>
+ <callout arearefs="tutorials.jsphello.method2.2">
<para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/jsf_ant_deploy.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
+ The variable
+ <literal>myRenderURL</literal>
+ is used like any other JSP variable.
</para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
- <para>
- Expanding the
- <filename>helloworldjsfsunriportlet.war</filename>
- file allows you to deploy the portlet as an expanded directory, which makes
- development easier. As well, it gives you access to the application
- descriptors, resource files, JSF, and JSP pages. To expand the
- <filename>helloworldjsfsunriportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
+ </callout>
+ <callout arearefs="tutorials.jsphello.method3.1">
<para>
- If you do not have the
- <filename>
- HelloWorldJSFSunRIPortlet/helloworldjsfsunriportlet.war
- </filename>
- file, change into the
- <filename>HelloWorldJSFSunRIPortlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. This creates the
- <filename>helloworldjsfsunriportlet.war</filename>
- file.
+ The third method mixes form submission and action request. Like in
+ the second method, we used a temporary variable to put the created
+ URL into.
</para>
- </listitem>
- <listitem>
- <para>
- To expand the WAR file, change into the
- <filename>HelloWorldJSFSunRIPortlet/</filename>
- directory, and run the
- <command>ant explode</command>
- command. On Linux, the output will be similar to the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/jsf_ant_explode.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
+ </callout>
+ <callout arearefs="tutorials.jsphello.method3.2">
+ <para>The action URL is used in the HTML form.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+
<para>
- The expanded WAR file and the application descriptors are located in the
- <filename>
- HelloWorldJSFSunRIPortlet/output/lib/exploded/helloworldjsfsunriportlet.war/WEB-INF/
- </filename>
- directory.
- </para>
- </sect3>
- <sect3>
- <title>Deploying your JSF portlet</title>
- <para>
- If you did not expand the
- <filename>helloworldjsfsunriportlet.war</filename>
- file, copy the
- <filename>
- HelloWorldJSFSunRIPortlet/helloworldjsfsunriportlet.war
- </filename>
- file into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. If you expanded the
- <filename>helloworldjsfsunriportlet.war</filename>
- file, copy the
- <filename>
- HelloWorldJSFSunRIPortlet/output/lib/exploded/helloworldjsfsunriportlet.war/
- </filename>
- directory into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. For example, if you are using
- <computeroutput>default</computeroutput>
- JBoss AS profile, copy the WAR file or the expanded directory into the
- <filename>$JBOSS_HOME/server/default/deploy/</filename>
- directory.
- </para>
- <para>
- Performing this step on a running instance of JBoss AS or JBoss EAP, and
- JBoss Portal, triggers a hot-deploy of the portlet:
- </para>
- <para>
- <screen><![CDATA[
-INFO [TomcatDeployer] deploy, ctxPath=/helloworldjsfsunriportlet,
-warUrl=.../tmp/deploy/tmp9138helloworldjsfsunriportlet-exp.war/]]>
- </screen>
- </para>
- <para>
- To see the HelloWorldJSFSunRIPortlet, navigate to
- <ulink url="http://localhost:8080/portal/">
- http://localhost:8080/portal/
- </ulink>
- , or, if the default JBoss Portal page is already open, refresh the page.
- The HelloWorldJSFSunRIPortlet is added to the bottom of the default JBoss
- Portal page:
- </para>
- <para>
+ On the third method, first the action phase is triggered then later in the request, the render
+ phase is triggered, which output some content back to the web browser based on the
+ available render parameters.
<mediaobject>
<imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/output.png" valign="middle" />
+ <imagedata format="PNG"
+ fileref="images/tutorials/jsp_portlet/process.png" scalefit="1" />
</imageobject>
</mediaobject>
</para>
- <para>
- To re-deploy the portlet, for example, if you have made changes to any of
- the application descriptors, touch the
- <filename>
- $JBOSS_HOME/server/
- <replaceable>configuration</replaceable>
- /deploy/helloworldjsfsunriportlet.war/WEB-INF/web.xml
- </filename>
- file. This only works if you copied the
- <filename>
- HelloWorldJSFSunRIPortlet/output/lib/exploded/helloworldjsfsunriportlet.war/
- </filename>
- directory into the JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. On Linux, run the <command>touch $JBOSS_HOME/server/<replaceable>configuration</replaceable>/deploy/helloworldjsfsunriportlet.war/WEB-INF/web.xml</command> command to re-deploy the HelloWorldJSFSunRIPortlet.
- </para>
- <para>
- Re-deploying the HelloWorldJSFSunRIPortlet produces output to the JBoss AS
- or JBoss EAP console, similar to the following:
- </para>
- <para>
- <screen><![CDATA[
-INFO [TomcatDeployer] undeploy, ctxPath=/helloworldjsfsunriportlet,
-warUrl=.../deploy/helloworldjsfsunriportlet.war/
-INFO [TomcatDeployer] deploy, ctxPath=/helloworldjsfsunriportlet,
-warUrl=.../deploy/helloworldjsfsunriportlet.war/]]>
- </screen>
- </para>
</sect3>
</sect2>
- <!--<sect2 id="sunri_42x_301">
- <title>Portal and JSF RI: A basic demonstration using common components</title>
- <sect3>
- <para>JSF portlets are now possible using the MyFaces 301 implementation of the JSR-301 specification.
- This does NOT mean that you are using the MyFaces implementation of JSF, it only means that you are
- using the 301 bridge implementation (which was initially donated by Oracle). The 301 spec or bridge is
- a subsystem that allows a JavaServer Faces resource to execute and satisfy a portlet request. You can
- read more about the specification details <ulink url="http://jcp.org/en/jsr/detail?id=301">here</ulink>.
- </para>
- </sect3>
- <sect3>
- <title>Downloading The Project Source</title>
- <para>
- You have 2 options for getting started.
- <sbr/>
- 1) Download the binary distribution in a zip file. This will
- include all the source files along with a deployable war file.
- <sbr/>
- 2) Use subversion to checkout the source
- code. If you plan on making changes to the source or possibly using it as a template for future development,
- it is recommended that you checkout the project and use maven to build the war.
- <para>
- For instructions on setting up Subversion and/or Maven 2 see <xref linkend="first_portlet_descriptors"/>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- You can download all the project files in one zip file here:
- <sbr/>
- <ulink url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/JSFRIPort...">http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/JSFRIPort...</ulink>.
- <sbr/>
- Once you extract the zip archive, the deployable war file is located in the target/ directory.
- </para>
- </listitem>
- <listitem>
- <para>
- The source code:
- <sbr/>
- <ulink url="http://anonsvn.jboss.org/repos/portletswap/portlets/src/framework/JSFRIPo...">http://anonsvn.jboss.org/repos/portletswap/portlets/src/framework/JSFRIPo...</ulink>.
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </sect3>
- </sect2>-->
- <sect2 id="myfaces_42x">
- <title>An example Apache MyFaces JSF portlet</title>
- <sect3>
- <title>Introduction</title>
- <para>
- This section describes how to deploy a JSF portlet in JBoss Portal, using
- the Apache MyFaces JSF implementation in JBoss AS and JBoss EAP. Before
- proceeding, download the
- <ulink
- url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/HelloWorl...">
- HelloWorldJSFMyFaces42Portlet
- </ulink>
- from
- <ulink url="http://labs.jboss.com/portletswap/">JBoss PortletSwap</ulink>
- .
- </para>
- <para>
- Apache MyFaces can be used globally for the entire server, replacing the
- Sun JSF RI libraries, but the HelloWorldJSFMyFaces42Portlet uses its own
- libraries, but does not affect the application server.
- </para>
- </sect3>
- <sect3>
- <title>Package Structure</title>
- <para>
- JBoss Portal requires certain descriptors to be included in a portlet WAR
- file. Some of these descriptors are defined by the JSR-168 Portlet
- Specification, and others are specific to JBoss Portal. Like a typical JSF
- application, the HelloWorldJSFMyFaces42Portlet package contains a
- <filename>faces-config.xml</filename>
- file that defines managed-beans, converters, validators, navigation rules,
- and so on. The following is an example of the directory structure of the
- HelloWorldJSFMyFaces42Portlet portlet:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/package_myfaces42.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- To create the
- <filename>WEB-INF/</filename>
- and
- <filename>META-INF/</filename>
- directories, extract the
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file. The
- <filename>WEB-INF/lib/</filename>
- directory must contain the Apache MyFaces libraries, along with the
- dependent libraries.
- </para>
- </sect3>
- <sect3>
- <title>Application Descriptors</title>
- <para>
- Only the
- <filename>portlet.xml</filename>
- ,
- <filename>faces-config.xml</filename>
- , and
- <filename>web.xml</filename>
- descriptors are described here. For more information about application
- descriptors, refer to
- <xref linkend="first_portlet_descriptors" />
- and
- <xref linkend="descriptors_portlet" />
- .
- </para>
- <para>
- The following is an example of the
- <filename>HelloWorldJSFMyFaces42Portlet/WEB-INF/portlet.xml</filename>
- file. This file must adhere to its definition in the JSR-168 Portlet
- Specification. You may define more than one portlet application in this
- file:
- </para>
- <programlisting role="XML"><![CDATA[
-<?xml version="1.0" encoding="UTF-8"?>
-<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
- 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"
- version="1.0">
- <portlet>
- <portlet-name>HelloWorldJSFPortlet</portlet-name>
- <portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>
- <init-param>
- <name>default-view</name>
- <value>/WEB-INF/jsp/index.jsp</value>
- </init-param>
- <supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>view</portlet-mode>
- </supports>
- <portlet-info>
- <title>HelloWorld JSF Portlet</title>
- </portlet-info>
- </portlet>
-</portlet-app>]]>
- </programlisting>
- <para>
- <variablelist>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- This specifies that the
- <computeroutput>
- org.apache.myfaces.portlet.MyFacesGenericPortlet
- </computeroutput>
- handles all requests and responses from the users. Therefore,
- there is no need to develop a specific portlet class, as Apache
- MyFaces provides a generic implementation which bridges the JSF
- and portlet worlds.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<init-param>
- <name>default-view</name>
- <value>/WEB-INF/jsp/index.jsp</value>
-</init-param>]]>
-</programlisting>
- </term>
- <listitem>
- <para>
- You must initialize the portlet with a default page to render,
- similar to a welcome page.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <programlisting><![CDATA[
-<supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>view</portlet-mode>
-</supports>]]></programlisting>
- </term>
- <listitem>
- <para>
- The
- <computeroutput><supports></computeroutput>
- element allows you to declare all of the markup types that a
- portlet supports in the
- <literal>render</literal>
- method. This is accomplished via the
- <computeroutput><mime-type></computeroutput>
- element, which is required for every portlet. The declared MIME
- types must match the capability of the portlet. As well, it
- allows you to pair which modes and window states are supported
- for each markup type. All portlets must support the
- <computeroutput>view</computeroutput>
- portlet mode, so this does not have to be declared. Use the
- <computeroutput><mime-type></computeroutput>
- element to define which markup type your portlet supports,
- which in this example, is
- <computeroutput>text/html</computeroutput>
- . This section tells the portal that it only outputs text and
- HTML, and that it only supports the
- <computeroutput>view</computeroutput>
- mode.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
- <para>
- <note>
- <title>Adding Functionality to an Apache MyFaces JSF portlet</title>
- <para>
- To add functionality to an Apache MyFaces JSF portlet, sub-class it
- and create your own class.
- </para>
- </note>
- </para>
- <para>
- The following is an example
- <filename>HelloWorldJSFMyFaces42Portlet/WEB-INF/faces-config.xml</filename>
- file:
- </para>
- <programlisting role="XML"><![CDATA[
-<?xml version="1.0"?>
-<!DOCTYPE faces-config PUBLIC
- "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
-<faces-config>
- <managed-bean>
- <description>Basic UserBean</description>
- <managed-bean-name>user</managed-bean-name>
- <managed-bean-class>org.jboss.portlet.hello.bean.User</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
-
- <navigation-rule>
- <navigation-case>
- <from-outcome>done</from-outcome>
- <to-view-id>/WEB-INF/jsp/result.jsp</to-view-id>
- </navigation-case>
- </navigation-rule>
-</faces-config>]]>
- </programlisting>
- <para>
- Without the
- <filename>faces-config.xml</filename>
- file, the application would work the same outside of the portlet as it
- would inside a portlet container. In this example, a basic user bean,
- <computeroutput>
- <managed-bean-name>user</managed-bean-name>
- </computeroutput>
- , and a navigation rule are defined, which handle the submission of the
- original form in the
- <filename>HelloWorldJSFMyFaces42Portlet/WEB-INF/jsp/index.jsp</filename>
- file.
- </para>
- <para>
- The following is an example of the
- <computeroutput><context-parm></computeroutput>
- element from the
- <filename>HelloWorldJSFMyFaces42Portlet/WEB-INF/web.xml</filename>
- file:
- </para>
- <programlisting role="XML"><![CDATA[
-<context-param>
- <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
- <param-value>true</param-value>
-</context-param>]]>
- </programlisting>
- <para>
- These extra parameters let the application server know that the portlet
- embeds its own libraries. This avoids collision with the Sun JSF RI
- libraries bundled with JBoss AS and JBoss EAP. For more information, refer
- to the
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossFaces">
- JBossFaces page on the JBoss Wiki
- </ulink>
- .
- </para>
- </sect3>
- <sect3>
- <title>Building your Apache MyFaces JSF portlet</title>
- <para>
- The
- <filename>HelloWorldJSFMyFaces42Portlet.zip</filename>
- file contains a pre-compiled
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file; however, to manually build the
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
- <para>
- Change into the
- <filename>HelloWorldJSFMyFaces42Portlet/</filename>
- directory, and remove the existing
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file.
- </para>
- </listitem>
- <listitem>
- <para>
- If required, edit the
- <filename>
- HelloWorldJSFMyFaces42Portlet/src/main/org/jboss/portlet/hello/bean/User.java
- </filename>
- file, and the application descriptors in the
- <filename>
- HelloWorldJSFMyFaces42Portlet/src/resources/helloworldjsfmyfacesportlet-war/WEB-INF/
- </filename>
- directory.
- </para>
- </listitem>
- <listitem>
- <para>
- Change into
- <filename>HelloWorldJSFMyFaces42Portlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. On Linux, the output will be similar to the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/myfaces_ant_deploy.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
- <para>
- Expanding the
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file allows you to deploy the portlet as an expanded directory, which makes
- development easier. As well, it gives you access to the application
- descriptors, resource files, JSF, and JSP pages. To expand the
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file:
- </para>
- <para>
- <orderedlist>
- <listitem>
- <para>
- If you do not have the
- <filename>
- HelloWorldJSFMyFaces42Portlet/helloworldjsfmyfacesportlet.war
- </filename>
- file, change into the
- <filename>HelloWorldJSFMyFaces42Portlet/</filename>
- directory, and run the
- <command>ant deploy</command>
- command. This creates the
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file.
- </para>
- </listitem>
- <listitem>
- <para>
- To expand the WAR file, change into the
- <filename>HelloWorldJSFMyFaces42Portlet/</filename>
- directory, and run the
- <command>ant explode</command>
- command. On Linux, the output will be similar to the following:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/myfaces_ant_explode.png"
- valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- </listitem>
- </orderedlist>
- </para>
- <para>Note: the directory names will be different for your system.</para>
- <para>
- The expanded WAR file and the application descriptors are located in the
- <filename>
- HelloWorldJSFMyFaces42Portlet/output/lib/exploded/helloworldjsfmyfacesportlet.war/WEB-INF/
- </filename>
- directory.
- </para>
- </sect3>
- <sect3>
- <title>Deploying your Apache MyFaces JSF portlet</title>
- <para>
- If you did not expand the
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file, copy the
- <filename>
- HelloWorldJSFMyFaces42Portlet/helloworldjsfmyfacesportlet.war
- </filename>
- file into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. If you expanded the
- <filename>helloworldjsfmyfacesportlet.war</filename>
- file, copy the
- <filename>
- HelloWorldJSFMyFaces42Portlet/output/lib/exploded/helloworldjsfmyfacesportlet.war/
- </filename>
- directory into the correct JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. For example, if you are using the
- <computeroutput>default</computeroutput>
- JBoss AS profile, copy the WAR file or the expanded directory into the
- <filename>$JBOSS_HOME/server/default/deploy/</filename>
- directory.
- </para>
- <para>
- Performing this step on a running instance of JBoss AS or JBoss EAP, and
- JBoss Portal, triggers a hot-deploy of the portlet.
- </para>
- <para>
- To see the HelloWorldJSFMyFaces42Portlet, navigate to
- <ulink url="http://localhost:8080/portal/"></ulink>
- , or, if the default JBoss Portal page is already open, refresh the page.
- The HelloWorldJSFMyFaces42Portlet is added to the bottom of the default
- JBoss Portal page:
- </para>
- <para>
- <mediaobject>
- <imageobject>
- <imagedata align="center"
- fileref="images/tutorials/jsf_portlet/output.png" valign="middle" />
- </imageobject>
- </mediaobject>
- </para>
- <para>
- To re-deploy the portlet, for example, if you have made changes to any of
- the application descriptors, touch the
- <filename>
- $JBOSS_HOME/server/
- <replaceable>configuration</replaceable>
- /deploy/helloworldjsfmyfacesportlet.war/WEB-INF/web.xml
- </filename>
- file. This only works if you copied the
- <filename>
- HelloWorldJSFMyFaces42Portlet/output/lib/exploded/helloworldjsfmyfacesportlet.war/
- </filename>
- directory into the JBoss AS or JBoss EAP
- <filename>deploy/</filename>
- directory. On Linux, run the <command>touch $JBOSS_HOME/server/<replaceable>configuration</replaceable>/deploy/helloworldjsfmyfacesportlet.war/WEB-INF/web.xml</command> command to re-deploy the
- HelloWorldJSFMyFaces42Portlet.
- </para>
- </sect3>
- </sect2>
- <!-- sect2>
- <title>Adapting MyFaces JSF Portlet to work on JBoss AS 4.2.x</title>
- <para>We saw in <xref linkend="myfaces_40x"/> how to create a JSF-based portlet using Apache's MyFaces
- JSF implementation on JBoss Application Server 4.0.x. Starting with version 4.2.0 of JBoss Application
- Server, the default bundled JSF implementation is Sun's Reference Implementation (RI). We thus need to
- adapt our MyFaces portlet sightly so that it works in this new environment.
- </para>
- <para>The first step is to provide access to MyFaces as it's not bundled anymore in JBoss AS. This is
- accomplished by adding <literal>myfaces-api.jar</literal> and <literal>myfaces-impl.jar</literal> in
- our portlet <literal>WEB-INF/lib</literal> directory. This can be done automatically via a modification of
- the ant script and is left as an exercise to the reader.
- </para>
- <para>
- We also need to need to tell JBoss AS not to use its bundled JSF implementation for our portlet. This
- is accomplished by adding the following to our portlet's <literal>web.xml</literal>:
- <programlisting><![CDATA[<context-param>
- <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
- <param-value>true</param-value>
- </context-param>]]></programlisting>
- More details on this procedure can be found at <ulink
- url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossFaces">http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossFaces</ulink>.
- </para>
- <para>
- We should get the following package content for our portlet:
- <mediaobject>
- <imageobject>
- <imagedata align="center" fileref="images/tutorials/jsf_portlet/package_42x.png" valign="middle"/>
- </imageobject>
- </mediaobject>
- </para>
- </sect2-->
- <!-- sect2 id="richfaces">
- <title>Portal and RichFaces: A basic demonstration using Ajax4JSF and RichFaces components</title>
- <sect3>
- <para>
- RichFaces is currently in technology preview mode and not fully supported in Jboss Portal.
- </para>
- </sect3>
- <sect3>
- <title>Downloading The Binaries or Project Source</title>
- <para>
- You have 2 options for getting started.
- <-<para>
- For instructions on setting up Subversion and/or Maven 2 see <xref linkend="build_instructions"/>
- </para>->
- <itemizedlist>
- <listitem>
- <para>
- 1) Download the binary distribution in a zip file. This will
- include all the source files along with a deployable war file.
- <sbr/>
- <ulink url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/RichFaces...">http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/RichFaces...</ulink>.
- <sbr/>
- Once you extract the zip archive, the deployable war file is located in the target/ directory.
- </para>
- </listitem>
- <listitem>
- <para>
- 2) Use subversion to checkout the source code.
- If you plan on making changes to the source or possibly using it as a template for future development,
- it is recommended that you checkout the project and use maven to build the war.
- <sbr/>
- <ulink url="http://anonsvn.jboss.org/repos/portletswap/portlets/src/framework/RichFac...">http://anonsvn.jboss.org/repos/portletswap/portlets/src/framework/RichFac...</ulink>.
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </sect3>
- <sect3>
- <title>Project Configuration</title>
- <para>
- The following configurations must be made to use RichFaces in your portlet.
- </para>
- <para>
- Here we use javax.portlet.faces.GenericFacesPortlet which is part of the JSR-301 specification. We also
- must declare the view, edit, and help modes as shown below.
- <itemizedlist>
- <listitem>
- <literal>portlet.xml</literal>
- <programlisting>
- <![CDATA[<portlet-app version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/portlet"
- xmlns="http://java.sun.com/xml/ns/portlet">
- <portlet>
- <portlet-name>ajaxPortlet</portlet-name>
- <portlet-class>
- javax.portlet.faces.GenericFacesPortlet
- </portlet-class>
-
- <init-param>
- <name>javax.portlet.faces.defaultViewId.view</name>
- <value>/jsf/start.xhtml</value>
- </init-param>
-
- <init-param>
- <name>javax.portlet.faces.defaultViewId.edit</name>
- <value>/jsf/edit.xhtml</value>
- </init-param>
-
- <init-param>
- <name>javax.portlet.faces.defaultViewId.help</name>
- <value>/jsf/help.xhtml</value>
- </init-param>
-
- <expiration-cache>-0</expiration-cache>
- <portlet-info>
- <title>Ajax Portlet</title>
- </portlet-info>
- <supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>VIEW</portlet-mode>
- <portlet-mode>EDIT</portlet-mode>
- <portlet-mode>HELP</portlet-mode>
- </supports>
- </portlet>
- </portlet-app>]]>
- </programlisting>
- </listitem>
- <listitem>
- <literal>faces-config.xml</literal>
- <programlisting>
- <![CDATA[...
- <application>
- <view-handler>
- org.ajax4jsf.portlet.application.PortletViewHandler
- </view-handler>
- <state-manager>
- org.ajax4jsf.portlet.application.PortalStateManager
- </state-manager>
- </application>
- <factory>
- <faces-context-factory>
- org.ajax4jsf.portlet.context.FacesContextFactoryImpl
- </faces-context-factory>
- </factory>
- ...]]>
- </programlisting>
- </listitem>
- <listitem>
- <literal>web.xml</literal>
- <programlisting>
- <![CDATA[...
- <context-param>
- <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
- <param-value>org.ajax4jsf.portlet.application.FaceletPortletViewHandler</param-value>
- </context-param>
- <filter>
- <display-name>Ajax4jsf Filter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.Filter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>ajax4jsf</filter-name>
- <servlet-name>FacesServlet</servlet-name>
- <dispatcher>FORWARD</dispatcher>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>INCLUDE</dispatcher>
- </filter-mapping>
- ...]]>
- </programlisting>
- </listitem>
- </itemizedlist>
- </para>
- </sect3>
- </sect2-->
</sect1>
</chapter>
\ No newline at end of file
16 years, 3 months
JBoss Portal SVN: r11406 - in branches/JBoss_Portal_Branch_2_7: registration/src/main/org/jboss/portal/registration/policies and 3 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:59:26 -0400 (Thu, 10 Jul 2008)
New Revision: 11406
Modified:
branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
Log:
- Do not check for duplicate registration if the registration is currently pending.
- Transparently call modifyRegistration if we detect a rare situation where it might be needed.
- Generification.
Modified: branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2008-07-10 11:58:54 UTC (rev 11405)
+++ branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2008-07-10 11:59:26 UTC (rev 11406)
@@ -49,8 +49,8 @@
* @throws IllegalArgumentException if any of the registration properties is invalid for the specified Consumer
* @throws RegistrationException if an exception occured in the registration service
*/
- void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity)
- throws IllegalArgumentException, RegistrationException;
+ void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException;
/**
* Generates a registration handle based on the database identity of the Registration. This allows users to customize
@@ -90,7 +90,7 @@
* @throws IllegalArgumentException if the specified Consumer name if <code>null</code> or empty
*/
String getConsumerIdFrom(String consumerName, Map registrationProperties)
- throws IllegalArgumentException, InvalidConsumerDataException;
+ throws IllegalArgumentException, InvalidConsumerDataException;
/**
* Determines if the specified Consumer name is acceptable. This method is called before a Consumer is created and
@@ -102,7 +102,7 @@
* @throws RegistrationException if an exception occurred in the Registration service
*/
void validateConsumerName(String consumerName)
- throws IllegalArgumentException, RegistrationException;
+ throws IllegalArgumentException, RegistrationException;
/**
* Determines if the specified ConsumerGroup name is acceptable. This method is called before a ConsumerGroup is
Modified: branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2008-07-10 11:58:54 UTC (rev 11405)
+++ branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2008-07-10 11:59:26 UTC (rev 11406)
@@ -33,6 +33,7 @@
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationStatus;
import javax.xml.namespace.QName;
import java.util.Collections;
@@ -77,8 +78,8 @@
* @throws DuplicateRegistrationException if a Consumer with the same identity has already registered with the same
* registration properties.
*/
- public void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity)
- throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNull(registrationProperties, "Registration properties");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerIdentity, "Consumer identity", null);
@@ -98,7 +99,7 @@
{
consistentWithExpectations = false;
message.append("Consumer '").append(consumerIdentity)
- .append("' provided values for unexpected registration properties:\n");
+ .append("' provided values for unexpected registration properties:\n");
for (QName name : unexpected)
{
message.append("\t- ").append(name).append("\n");
@@ -127,9 +128,9 @@
}
}
- // check that this is not a duplicate registration
+ // check that this is not a duplicate registration if the status is not pending
Consumer consumer = manager.getConsumerByIdentity(consumerIdentity);
- if (consumer != null)
+ if (consumer != null && !RegistrationStatus.PENDING.equals(consumer.getStatus()))
{
// allow the new registration only if the registration properties are different that existing registrations
// for this consumer...
@@ -139,7 +140,7 @@
if (registration.hasEqualProperties(registrationProperties))
{
throw new DuplicateRegistrationException("Consumer named '" + consumer.getName()
- + "' has already been registered with the same set of registration properties. Registration rejected!");
+ + "' has already been registered with the same set of registration properties. Registration rejected!");
}
}
}
Modified: branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java 2008-07-10 11:58:54 UTC (rev 11405)
+++ branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java 2008-07-10 11:59:26 UTC (rev 11406)
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.jboss.portal.registration.DuplicateRegistrationException;
+import org.jboss.portal.registration.PropertyDescription;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationManager;
@@ -52,7 +53,7 @@
RegistrationManager manager = new RegistrationManagerImpl();
RegistrationPolicy policy = new DefaultRegistrationPolicy()
{
- public void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
{
// accept any registration data here
}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java 2008-07-10 11:58:54 UTC (rev 11405)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java 2008-07-10 11:59:26 UTC (rev 11406)
@@ -39,7 +39,7 @@
*/
public class TestRegistrationPolicy implements RegistrationPolicy
{
- public void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException
{
}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-10 11:58:54 UTC (rev 11405)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-10 11:59:26 UTC (rev 11406)
@@ -108,8 +108,6 @@
private boolean isModifyRegistrationRequired;
private ConsumerRegistry registry;
- private static final String REGISTER_MEANING = "Should clients ask for a new service description?";
- private static final String REFRESH_MEANING = "Did just refresh?";
private static final String ERASED_LOCAL_REGISTRATION_INFORMATION = "Erased local registration information!";
private Map<String, ItemDescription> customModes;
@@ -340,6 +338,13 @@
isModifyRegistrationRequired = true;
setActiveAndSave(false);
}
+ else
+ {
+ // we might be in a situation where the producer changed the registration back to the initial state
+ // which is, granted, pretty rare... attempt modifyRegistration
+ log.debug("modifyRegistration was called after OperationFailedFault when a check of registration data didn't reveal any issue...");
+ modifyRegistration();
+ }
result.setRegistrationResult(registrationResult);
return result;
@@ -702,7 +707,7 @@
{
Throwable cause = e.getCause();
throw new InvokerUnavailableException("Problem getting service description for producer "
- + persistentId + ", please see the logs for more information.", cause == null ? e : cause);
+ + persistentId + ", please see the logs for more information. ", cause == null ? e : cause);
}
private GetServiceDescription getServiceDescriptionRequest(boolean asUnregistred) throws PortletInvokerException
@@ -835,11 +840,9 @@
String msg = "Consumer with id '" + persistentId + "' successfully registered with handle: '"
+ registrationContext.getRegistrationHandle() + "'";
log.debug(msg);
-// result.appendToStatus(msg);
RefreshResult res = new RefreshResult();
res.setRegistrationResult(result);
return res;
-// return new RefreshResult(result, true, REGISTER_MEANING);
}
catch (Exception e)
{
@@ -988,6 +991,5 @@
registry.updateProducerInfo(this);
log.warn(ERASED_LOCAL_REGISTRATION_INFORMATION);
- log.debug(ERASED_LOCAL_REGISTRATION_INFORMATION);
}
}
16 years, 3 months
JBoss Portal SVN: r11405 - in branches/JBoss_Portal_Branch_2_6: registration/src/main/org/jboss/portal/registration/policies and 3 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:58:54 -0400 (Thu, 10 Jul 2008)
New Revision: 11405
Modified:
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
Log:
- Do not check for duplicate registration if the registration is currently pending.
- Transparently call modifyRegistration if we detect a rare situation where it might be needed.
- Generification.
Modified: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2008-07-10 11:51:37 UTC (rev 11404)
+++ branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2008-07-10 11:58:54 UTC (rev 11405)
@@ -49,8 +49,8 @@
* @throws IllegalArgumentException if any of the registration properties is invalid for the specified Consumer
* @throws RegistrationException if an exception occured in the registration service
*/
- void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity)
- throws IllegalArgumentException, RegistrationException;
+ void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException;
/**
* Generates a registration handle based on the database identity of the Registration. This allows users to customize
@@ -90,7 +90,7 @@
* @throws IllegalArgumentException if the specified Consumer name if <code>null</code> or empty
*/
String getConsumerIdFrom(String consumerName, Map registrationProperties)
- throws IllegalArgumentException, InvalidConsumerDataException;
+ throws IllegalArgumentException, InvalidConsumerDataException;
/**
* Determines if the specified Consumer name is acceptable. This method is called before a Consumer is created and
@@ -102,7 +102,7 @@
* @throws RegistrationException if an exception occurred in the Registration service
*/
void validateConsumerName(String consumerName)
- throws IllegalArgumentException, RegistrationException;
+ throws IllegalArgumentException, RegistrationException;
/**
* Determines if the specified ConsumerGroup name is acceptable. This method is called before a ConsumerGroup is
Modified: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2008-07-10 11:51:37 UTC (rev 11404)
+++ branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2008-07-10 11:58:54 UTC (rev 11405)
@@ -33,6 +33,7 @@
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationStatus;
import javax.xml.namespace.QName;
import java.util.Collections;
@@ -77,8 +78,8 @@
* @throws DuplicateRegistrationException if a Consumer with the same identity has already registered with the same
* registration properties.
*/
- public void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity)
- throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNull(registrationProperties, "Registration properties");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerIdentity, "Consumer identity", null);
@@ -98,7 +99,7 @@
{
consistentWithExpectations = false;
message.append("Consumer '").append(consumerIdentity)
- .append("' provided values for unexpected registration properties:\n");
+ .append("' provided values for unexpected registration properties:\n");
for (QName name : unexpected)
{
message.append("\t- ").append(name).append("\n");
@@ -127,9 +128,9 @@
}
}
- // check that this is not a duplicate registration
+ // check that this is not a duplicate registration if the status is not pending
Consumer consumer = manager.getConsumerByIdentity(consumerIdentity);
- if (consumer != null)
+ if (consumer != null && !RegistrationStatus.PENDING.equals(consumer.getStatus()))
{
// allow the new registration only if the registration properties are different that existing registrations
// for this consumer...
@@ -139,7 +140,7 @@
if (registration.hasEqualProperties(registrationProperties))
{
throw new DuplicateRegistrationException("Consumer named '" + consumer.getName()
- + "' has already been registered with the same set of registration properties. Registration rejected!");
+ + "' has already been registered with the same set of registration properties. Registration rejected!");
}
}
}
Modified: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java 2008-07-10 11:51:37 UTC (rev 11404)
+++ branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java 2008-07-10 11:58:54 UTC (rev 11405)
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.jboss.portal.registration.DuplicateRegistrationException;
+import org.jboss.portal.registration.PropertyDescription;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationManager;
@@ -52,7 +53,7 @@
RegistrationManager manager = new RegistrationManagerImpl();
RegistrationPolicy policy = new DefaultRegistrationPolicy()
{
- public void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
{
// accept any registration data here
}
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java 2008-07-10 11:51:37 UTC (rev 11404)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java 2008-07-10 11:58:54 UTC (rev 11405)
@@ -39,7 +39,7 @@
*/
public class TestRegistrationPolicy implements RegistrationPolicy
{
- public void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription> registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException
{
}
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-10 11:51:37 UTC (rev 11404)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-10 11:58:54 UTC (rev 11405)
@@ -108,8 +108,6 @@
private boolean isModifyRegistrationRequired;
private ConsumerRegistry registry;
- private static final String REGISTER_MEANING = "Should clients ask for a new service description?";
- private static final String REFRESH_MEANING = "Did just refresh?";
private static final String ERASED_LOCAL_REGISTRATION_INFORMATION = "Erased local registration information!";
private Map<String, ItemDescription> customModes;
@@ -340,6 +338,13 @@
isModifyRegistrationRequired = true;
setActiveAndSave(false);
}
+ else
+ {
+ // we might be in a situation where the producer changed the registration back to the initial state
+ // which is, granted, pretty rare... attempt modifyRegistration
+ log.debug("modifyRegistration was called after OperationFailedFault when a check of registration data didn't reveal any issue...");
+ modifyRegistration();
+ }
result.setRegistrationResult(registrationResult);
return result;
@@ -702,7 +707,7 @@
{
Throwable cause = e.getCause();
throw new InvokerUnavailableException("Problem getting service description for producer "
- + persistentId + ", please see the logs for more information.", cause == null ? e : cause);
+ + persistentId + ", please see the logs for more information. ", cause == null ? e : cause);
}
private GetServiceDescription getServiceDescriptionRequest(boolean asUnregistred) throws PortletInvokerException
@@ -835,11 +840,9 @@
String msg = "Consumer with id '" + persistentId + "' successfully registered with handle: '"
+ registrationContext.getRegistrationHandle() + "'";
log.debug(msg);
-// result.appendToStatus(msg);
RefreshResult res = new RefreshResult();
res.setRegistrationResult(result);
return res;
-// return new RefreshResult(result, true, REGISTER_MEANING);
}
catch (Exception e)
{
@@ -988,6 +991,5 @@
registry.updateProducerInfo(this);
log.warn(ERASED_LOCAL_REGISTRATION_INFORMATION);
- log.debug(ERASED_LOCAL_REGISTRATION_INFORMATION);
}
}
16 years, 3 months
JBoss Portal SVN: r11404 - branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:51:37 -0400 (Thu, 10 Jul 2008)
New Revision: 11404
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
Log:
- Now deal with doubly encoded & (encoded as &amp;). Not sure if this should stay in...
- Improved error reporting.
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2008-07-10 11:51:22 UTC (rev 11403)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2008-07-10 11:51:37 UTC (rev 11404)
@@ -52,10 +52,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.INTERACTION_STATE);
if (paramValue != null)
{
@@ -68,7 +68,7 @@
{
navigationalState = new OpaqueStateString(paramValue);
params.remove(WSRPRewritingConstants.NAVIGATIONAL_STATE);
- }
+ }
}
protected String getURLType()
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2008-07-10 11:51:22 UTC (rev 11403)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2008-07-10 11:51:37 UTC (rev 11404)
@@ -110,7 +110,7 @@
if (strict && portletURL instanceof WSRPPortletURL)
{
WSRPPortletURL other = (WSRPPortletURL)portletURL;
- url.setParams(other.extraParams);
+ url.setParams(other.extraParams, other.toString());
}
return url;
@@ -146,7 +146,7 @@
// find end token and extract it
int endTokenIndex = encodedURL.indexOf('/');
- if(endTokenIndex < 0)
+ if (endTokenIndex < 0)
{
throw new IllegalArgumentException(originalURL + " does not contain " + WSRPRewritingConstants.END_WSRP_REWRITE);
}
@@ -168,10 +168,11 @@
// next param should be the url type
if (!encodedURL.startsWith(WSRPRewritingConstants.URL_TYPE_NAME + EQUALS))
{
- throw new IllegalArgumentException(encodedURL + " does not specify a URL type.");
+ throw new IllegalArgumentException(originalURL + " does not specify a URL type.");
}
// standardize parameter separators
+ encodedURL = Tools.replace(encodedURL, "&amp;", PARAM_SEPARATOR); // sanitize doubly encoded & fix-me: should be removed?
encodedURL = Tools.replace(encodedURL, AMPERSAND, PARAM_SEPARATOR);
encodedURL = Tools.replace(encodedURL, "&", PARAM_SEPARATOR); // this second shouldn't be used but in case it is...
@@ -197,7 +198,8 @@
}
else
{
- throw new IllegalArgumentException("Unrecognized URL type: " + encodedURL.substring(0, encodedURL.indexOf(PARAM_SEPARATOR)));
+ throw new IllegalArgumentException("Unrecognized URL type: " + encodedURL.substring(0, encodedURL.indexOf(PARAM_SEPARATOR))
+ + "in " + originalURL);
}
// other parameters
@@ -217,7 +219,7 @@
+ originalURL + "'");
}
- url.setParams(params);
+ url.setParams(params, originalURL);
url.setExtraParamsAfterEndToken(extraAfterEnd);
return url;
}
@@ -251,10 +253,10 @@
{
}
- protected final void setParams(Map<String, String> params)
+ protected final void setParams(Map<String, String> params, String originalURL)
{
// First extract specific parameters and remove them from the param map...
- dealWithSpecificParams(params);
+ dealWithSpecificParams(params, originalURL);
// ... then deal with extra params if in relaxed mode
if (!strict)
@@ -268,9 +270,10 @@
* Deal with specific parameters first so that we can remove them before dealing with extra params. Sub-classes
* override to provide support for their specific parameters.
*
- * @param params name-value map of the URL parameters
+ * @param params name-value map of the URL parameters
+ * @param originalURL a String reprensenting the URL we are working with
*/
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
// mode
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.MODE);
@@ -430,9 +433,17 @@
// extract param name
String name = param.substring(0, equalsIndex);
- if (strict && !name.startsWith("wsrp-"))
+ if (!name.startsWith("wsrp-"))
{
- throw new IllegalArgumentException("Invalid parameter name: '" + name + "'");
+ if (strict)
+ {
+ throw new IllegalArgumentException("Invalid parameter name in strict validation mode (see documentation): '"
+ + name + "' in " + originalURL);
+ }
+ else
+ {
+ log.debug("Relaxed validation allowed invalid parameter name: " + name + " in " + originalURL);
+ }
}
// extract param value
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java 2008-07-10 11:51:22 UTC (rev 11403)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java 2008-07-10 11:51:37 UTC (rev 11404)
@@ -50,10 +50,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.NAVIGATIONAL_STATE);
if (paramValue != null)
{
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2008-07-10 11:51:22 UTC (rev 11403)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2008-07-10 11:51:37 UTC (rev 11404)
@@ -96,10 +96,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE);
if (paramValue != null)
{
@@ -108,7 +108,7 @@
else
{
throw new IllegalArgumentException("The parsed parameters don't contain a value for the required "
- + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter.");
+ + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter in " + originalURL);
}
paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.RESOURCE_URL);
@@ -135,7 +135,7 @@
catch (MimeTypeParseException e)
{
log.debug("Couldn't determine (based on extension) MIME type of file: " + file
- + "\nRetrieving the associated resource will probably fail.");
+ + "\nRetrieving the associated resource will probably fail.");
}
isSupported(mediaType);
@@ -148,7 +148,7 @@
else
{
throw new IllegalArgumentException("The parsed parameters don't contain a value for the required "
- + WSRPRewritingConstants.RESOURCE_URL + " parameter.");
+ + WSRPRewritingConstants.RESOURCE_URL + " parameter in " + originalURL);
}
}
@@ -161,7 +161,7 @@
if (!type.isAllowedSubType(mediaType))
{
log.debug("MIME type '" + mediaType
- + "' is not currently supported. Retrieving the associated resource will probably fail.");
+ + "' is not currently supported. Retrieving the associated resource will probably fail.");
return;
}
}
16 years, 3 months
JBoss Portal SVN: r11403 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:51:22 -0400 (Thu, 10 Jul 2008)
New Revision: 11403
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
Log:
- Now deal with doubly encoded & (encoded as &amp;). Not sure if this should stay in...
- Improved error reporting.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2008-07-10 11:41:33 UTC (rev 11402)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2008-07-10 11:51:22 UTC (rev 11403)
@@ -52,9 +52,9 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
- super.dealWithSpecificParams(params);
+ super.dealWithSpecificParams(params, originalURL);
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.INTERACTION_STATE);
if (paramValue != null)
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2008-07-10 11:41:33 UTC (rev 11402)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2008-07-10 11:51:22 UTC (rev 11403)
@@ -102,7 +102,7 @@
if (strict && portletURL instanceof WSRPPortletURL)
{
WSRPPortletURL other = (WSRPPortletURL)portletURL;
- url.setParams(other.extraParams);
+ url.setParams(other.extraParams, other.toString());
}
return url;
@@ -138,7 +138,7 @@
// find end token and extract it
int endTokenIndex = encodedURL.indexOf('/');
- if(endTokenIndex < 0)
+ if (endTokenIndex < 0)
{
throw new IllegalArgumentException(originalURL + " does not contain " + WSRPRewritingConstants.END_WSRP_REWRITE);
}
@@ -160,10 +160,11 @@
// next param should be the url type
if (!encodedURL.startsWith(WSRPRewritingConstants.URL_TYPE_NAME + EQUALS))
{
- throw new IllegalArgumentException(encodedURL + " does not specify a URL type.");
+ throw new IllegalArgumentException(originalURL + " does not specify a URL type.");
}
// standardize parameter separators
+ encodedURL = Tools.replace(encodedURL, "&amp;", PARAM_SEPARATOR); // sanitize doubly encoded & fix-me: should be removed?
encodedURL = Tools.replace(encodedURL, AMPERSAND, PARAM_SEPARATOR);
encodedURL = Tools.replace(encodedURL, "&", PARAM_SEPARATOR); // this second shouldn't be used but in case it is...
@@ -189,7 +190,8 @@
}
else
{
- throw new IllegalArgumentException("Unrecognized URL type: " + encodedURL.substring(0, encodedURL.indexOf(PARAM_SEPARATOR)));
+ throw new IllegalArgumentException("Unrecognized URL type: " + encodedURL.substring(0, encodedURL.indexOf(PARAM_SEPARATOR))
+ + "in " + originalURL);
}
// other parameters
@@ -209,7 +211,7 @@
+ originalURL + "'");
}
- url.setParams(params);
+ url.setParams(params, originalURL);
url.setExtraParamsAfterEndToken(extraAfterEnd);
return url;
}
@@ -243,10 +245,10 @@
{
}
- protected final void setParams(Map<String, String> params)
+ protected final void setParams(Map<String, String> params, String originalURL)
{
// First extract specific parameters and remove them from the param map...
- dealWithSpecificParams(params);
+ dealWithSpecificParams(params, originalURL);
// ... then deal with extra params if in relaxed mode
if (!strict)
@@ -260,9 +262,10 @@
* Deal with specific parameters first so that we can remove them before dealing with extra params. Sub-classes
* override to provide support for their specific parameters.
*
- * @param params name-value map of the URL parameters
+ * @param params name-value map of the URL parameters
+ * @param originalURL a String reprensenting the URL we are working with
*/
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
// mode
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.MODE);
@@ -422,9 +425,17 @@
// extract param name
String name = param.substring(0, equalsIndex);
- if (strict && !name.startsWith("wsrp-"))
+ if (!name.startsWith("wsrp-"))
{
- throw new IllegalArgumentException("Invalid parameter name: '" + name + "'");
+ if (strict)
+ {
+ throw new IllegalArgumentException("Invalid parameter name in strict validation mode (see documentation): '"
+ + name + "' in " + originalURL);
+ }
+ else
+ {
+ log.debug("Relaxed validation allowed invalid parameter name: " + name + " in " + originalURL);
+ }
}
// extract param value
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java 2008-07-10 11:41:33 UTC (rev 11402)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java 2008-07-10 11:51:22 UTC (rev 11403)
@@ -49,10 +49,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.NAVIGATIONAL_STATE);
if (paramValue != null)
{
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2008-07-10 11:41:33 UTC (rev 11402)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2008-07-10 11:51:22 UTC (rev 11403)
@@ -96,10 +96,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE);
if (paramValue != null)
{
@@ -108,7 +108,7 @@
else
{
throw new IllegalArgumentException("The parsed parameters don't contain a value for the required "
- + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter.");
+ + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter in " + originalURL);
}
paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.RESOURCE_URL);
@@ -135,7 +135,7 @@
catch (MimeTypeParseException e)
{
log.debug("Couldn't determine (based on extension) MIME type of file: " + file
- + "\nRetrieving the associated resource will probably fail.");
+ + "\nRetrieving the associated resource will probably fail.");
}
isSupported(mediaType);
@@ -148,7 +148,7 @@
else
{
throw new IllegalArgumentException("The parsed parameters don't contain a value for the required "
- + WSRPRewritingConstants.RESOURCE_URL + " parameter.");
+ + WSRPRewritingConstants.RESOURCE_URL + " parameter in " + originalURL);
}
}
@@ -161,7 +161,7 @@
if (!type.isAllowedSubType(mediaType))
{
log.debug("MIME type '" + mediaType
- + "' is not currently supported. Retrieving the associated resource will probably fail.");
+ + "' is not currently supported. Retrieving the associated resource will probably fail.");
return;
}
}
16 years, 3 months
JBoss Portal SVN: r11402 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:41:33 -0400 (Thu, 10 Jul 2008)
New Revision: 11402
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
Log:
- Generification.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2008-07-10 11:27:02 UTC (rev 11401)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2008-07-10 11:41:33 UTC (rev 11402)
@@ -23,6 +23,8 @@
package org.jboss.portal.wsrp.producer;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.Tools;
@@ -89,7 +91,7 @@
}
void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault, InvalidHandleFault,
- UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
+ UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
{
Registration registration = producer.getRegistrationOrFailIfInvalid(getRegistrationContext());
@@ -117,7 +119,7 @@
catch (PortletInvokerException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
- "Could not retrieve portlet '" + portletContext + "'", e);
+ "Could not retrieve portlet '" + portletContext + "'", e);
}
// get portlet description for the desired portlet...
@@ -126,7 +128,7 @@
if (Boolean.TRUE.equals(portletDescription.getUsesMethodGet()))
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
- "Portlets using GET method in forms are not currently supported.", null);
+ "Portlets using GET method in forms are not currently supported.", null);
}
MarkupType[] markupTypes = portletDescription.getMarkupTypes();
@@ -181,7 +183,7 @@
* @return a MarkupRequest containing the most appropriate information to base markup generation for this request
*/
private MarkupRequest createMarkupRequestFrom(MarkupType[] markupTypes, MarkupParams params, Portlet portlet)
- throws UnsupportedMimeTypeFault, UnsupportedModeFault, UnsupportedWindowStateFault
+ throws UnsupportedMimeTypeFault, UnsupportedModeFault, UnsupportedWindowStateFault
{
String[] desiredMIMETypes = params.getMimeTypes();
MarkupType markupType = null;
@@ -190,11 +192,11 @@
for (int i = 0; markupType == null && i < desiredMIMETypes.length; i++)
{
String desiredMIMEType = desiredMIMETypes[i];
- for (int j = 0; j < markupTypes.length; j++)
+ for (MarkupType mt : markupTypes)
{
- if (desiredMIMEType.equalsIgnoreCase(markupTypes[j].getMimeType()))
+ if (desiredMIMEType.equalsIgnoreCase(mt.getMimeType()))
{
- markupType = markupTypes[j];
+ markupType = mt;
break;
}
}
@@ -204,7 +206,7 @@
if (markupType == null)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_MIME_TYPE,
- "None of the specified MIME types are supported by portlet '" + portlet.getContext().getId() + "'", null);
+ "None of the specified MIME types are supported by portlet '" + portlet.getContext().getId() + "'", null);
}
// get the mode
@@ -216,7 +218,7 @@
catch (IllegalArgumentException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_MODE,
- "Unsupported mode '" + params.getMode() + "'", e);
+ "Unsupported mode '" + params.getMode() + "'", e);
}
// get the window state
@@ -228,7 +230,7 @@
catch (IllegalArgumentException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_WINDOW_STATE,
- "Unsupported window state '" + params.getMode() + "'", e);
+ "Unsupported window state '" + params.getMode() + "'", e);
}
// get the character set
@@ -271,13 +273,13 @@
{
if (preferredValues != null && possibleValues != null)
{
- List possibleList = Arrays.asList(possibleValues);
+ List<String> possibleList = Arrays.asList(possibleValues);
- for (int i = 0; i < preferredValues.length; i++)
+ for (String preferredValue : preferredValues)
{
- if (possibleList.contains(preferredValues[i]))
+ if (possibleList.contains(preferredValue))
{
- return preferredValues[i];
+ return preferredValue;
}
}
}
@@ -362,10 +364,9 @@
String[] validNewWindowStates = params.getValidNewWindowStates();
if (validNewWindowStates != null)
{
- Set states = new HashSet(validNewWindowStates.length);
- for (int i = 0; i < validNewWindowStates.length; i++)
+ Set<WindowState> states = new HashSet<WindowState>(validNewWindowStates.length);
+ for (String state : validNewWindowStates)
{
- String state = validNewWindowStates[i];
states.add(WSRPUtils.getJSR168WindowStateFromWSRPName(state));
}
return states;
@@ -378,10 +379,9 @@
String[] validNewModes = params.getValidNewModes();
if (validNewModes != null)
{
- Set modes = new HashSet(validNewModes.length);
- for (int i = 0; i < validNewModes.length; i++)
+ Set<Mode> modes = new HashSet<Mode>(validNewModes.length);
+ for (String mode : validNewModes)
{
- String mode = validNewModes[i];
modes.add(WSRPUtils.getJSR168PortletModeFromWSRPName(mode));
}
return modes;
@@ -406,7 +406,7 @@
catch (MimeTypeParseException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_MIME_TYPE,
- e.getLocalizedMessage(), e);
+ e.getLocalizedMessage(), e);
}
return markupInfo;
}
16 years, 3 months
JBoss Portal SVN: r11401 - in branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp: producer and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:27:02 -0400 (Thu, 10 Jul 2008)
New Revision: 11401
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
Log:
- JBPORTAL-2067: Added more rewriting of URLs on both Consumer and Producer.
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-10 11:26:34 UTC (rev 11400)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-10 11:27:02 UTC (rev 11401)
@@ -57,6 +57,7 @@
// transient variables
/** Access to the WS */
private ServiceFactory serviceFactory;
+ private transient String remoteHostAddress;
static final String SERVICE_DESCRIPTION = "service description";
static final String MARKUP = "markup";
@@ -394,7 +395,7 @@
catch (Exception e)
{
throw new InvokerUnavailableException("Couldn't access " + description + " service. Cause: "
- + e.getLocalizedMessage(), e);
+ + e.getLocalizedMessage(), e);
}
}
@@ -440,7 +441,7 @@
private boolean areURLsDirty()
{
return !clean.get(SD) || !clean.get(M) || (persistentPortletManagementURL != null && !clean.get(PM))
- || (persistentRegistrationURL != null && !clean.get(R));
+ || (persistentRegistrationURL != null && !clean.get(R));
}
public void refresh() throws InvokerUnavailableException
@@ -468,4 +469,16 @@
}
}
}
+
+ public String getRemoteHostAddress()
+ {
+ if (remoteHostAddress == null || areURLsDirty())
+ {
+ // extract host URL
+ int hostBegin = persistentMarkupURL.indexOf("://") + 3;
+ remoteHostAddress = persistentMarkupURL.substring(0, persistentMarkupURL.indexOf('/', hostBegin));
+ }
+
+ return remoteHostAddress;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2008-07-10 11:26:34 UTC (rev 11400)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2008-07-10 11:27:02 UTC (rev 11401)
@@ -86,7 +86,7 @@
// process the response
consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(), invocation,
- requestPrecursor.getPortletHandle());
+ requestPrecursor.getPortletHandle());
MarkupContext markupContext = markupResponse.getMarkupContext();
String markup = markupContext.getMarkupString();
@@ -94,19 +94,19 @@
if (markup != null && binary != null)
{
return new ErrorResponse(new IllegalArgumentException("Markup response cannot contain both string and binary " +
- "markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
+ "markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
}
if (markup == null && binary == null)
{
- if (markupContext.getUseCachedMarkup().booleanValue())
+ if (markupContext.getUseCachedMarkup())
{
//todo: deal with cache
}
else
{
return new ErrorResponse(new IllegalArgumentException("Markup response must contain at least string or binary" +
- " markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
+ " markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
}
}
@@ -129,7 +129,7 @@
org.jboss.portal.portlet.cache.CacheControl cacheControl = createCacheControl(markupContext);
FragmentResponse result = new FragmentResponse(null, null, mimeType, null, markup,
- markupContext.getPreferredTitle(), cacheControl, invocation.getPortalContext().getModes());
+ markupContext.getPreferredTitle(), cacheControl, invocation.getPortalContext().getModes());
log.debug("Response processed");
return result;
@@ -177,7 +177,7 @@
if (rewriteURLs)
{
URLFormat format = new URLFormat(invocation.getSecurityContext().isSecure(),
- invocation.getSecurityContext().isAuthenticated(), true, true);
+ invocation.getSecurityContext().isAuthenticated(), true, true);
WSRPURLRewriter rewriter = new WSRPURLRewriter(invocation.getContext(), format, consumer);
markup = URLTools.replaceURLsBy(markup, rewriter);
}
@@ -228,6 +228,7 @@
private PortletInvocationContext context;
private URLFormat format;
private WSRPConsumer consumer;
+ private static final String SLASH = "/";
private WSRPURLRewriter(PortletInvocationContext context, URLFormat format, WSRPConsumer consumer)
{
@@ -239,17 +240,24 @@
public String getReplacementFor(int currentIndex, URLTools.URLMatch currentMatch)
{
String urlAsString = currentMatch.getURLAsString();
+ ProducerInfo info = consumer.getProducerInfo();
if (urlAsString.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
{
- WSRPPortletURL portletURL = WSRPPortletURL.create(urlAsString,
- consumer.getProducerInfo().getSupportedCustomModes(), consumer.getProducerInfo().getSupportedCustomWindowStates());
+ WSRPPortletURL portletURL = WSRPPortletURL.create(urlAsString,
+ info.getSupportedCustomModes(), info.getSupportedCustomWindowStates());
if (portletURL instanceof WSRPResourceURL)
{
log.debug("URL '" + urlAsString + "' seems to refer to a resource which are not currently supported. " +
- "Trying to use the raw URL but this probably won't work...");
+ "Trying to use the raw URL but this probably won't work...");
return portletURL.toString();
}
+ // todo: this is a hack to circumvent frameworks that don't properly request resource encoding (icefaces)
+ if (urlAsString.startsWith(SLASH))
+ {
+ return info.getEndpointConfigurationInfo().getRemoteHostAddress() + urlAsString;
+ }
+
return context.renderURL(portletURL, format);
}
return urlAsString;
@@ -267,7 +275,7 @@
{
int index = urlAsString.indexOf(WSRPRewritingConstants.FAKE_RESOURCE_REQ_REW);
String requireRewriteStr = urlAsString.substring(index + WSRPRewritingConstants.FAKE_RESOURCE_REQ_REW.length());
- boolean requireRewrite = Boolean.valueOf(requireRewriteStr).booleanValue();
+ boolean requireRewrite = Boolean.valueOf(requireRewriteStr);
urlAsString = urlAsString.substring(prefix.length(), index);
if (requireRewrite)
Added: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java 2008-07-10 11:27:02 UTC (rev 11401)
@@ -0,0 +1,62 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.producer;
+
+import org.jboss.portal.common.net.URLTools;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class AbsoluteURLReplacementGenerator extends URLTools.URLReplacementGenerator
+{
+ private String serverAddress;
+ static final String SCH_END = "://";
+ static final String PORT_END = ":";
+
+ public AbsoluteURLReplacementGenerator(HttpServletRequest request)
+ {
+ String scheme = request.getScheme();
+ String host = request.getServerName();
+ int port = request.getServerPort();
+
+ serverAddress = scheme + SCH_END + host + PORT_END + port;
+ }
+
+ public String getReplacementFor(int i, URLTools.URLMatch urlMatch)
+ {
+ return getAbsoluteURLFor(urlMatch.getURLAsString());
+ }
+
+ public String getAbsoluteURLFor(String url)
+ {
+ if (!URLTools.isNetworkURL(url))
+ {
+ return serverAddress + url;
+ }
+
+ return url;
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2008-07-10 11:26:34 UTC (rev 11400)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2008-07-10 11:27:02 UTC (rev 11401)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.producer;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -60,8 +61,8 @@
private final GetMarkup getMarkup;
public RenderRequestProcessor(WSRPProducerImpl producer, GetMarkup getMarkup) throws UnsupportedMimeTypeFault,
- UnsupportedWindowStateFault, InvalidHandleFault, UnsupportedModeFault, MissingParametersFault,
- InvalidRegistrationFault, OperationFailedFault
+ UnsupportedWindowStateFault, InvalidHandleFault, UnsupportedModeFault, MissingParametersFault,
+ InvalidRegistrationFault, OperationFailedFault
{
super(producer);
this.getMarkup = getMarkup;
@@ -166,10 +167,13 @@
*/
private String processFragmentString(String renderString)
{
- return Tools.replaceAllInstancesOfBoundedString(
- renderString,
- PortletUtils.PREFIX,
- PortletUtils.SUFFIX,
- WSRPRewritingConstants.WSRP_REWRITE_TOKEN);
+ String result = Tools.replaceAllInstancesOfBoundedString(
+ renderString,
+ PortletUtils.PREFIX,
+ PortletUtils.SUFFIX,
+ WSRPRewritingConstants.WSRP_REWRITE_TOKEN);
+
+ result = URLTools.replaceURLsBy(result, new AbsoluteURLReplacementGenerator(invocation.getDispatchedRequest()));
+ return result;
}
}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java 2008-07-10 11:26:34 UTC (rev 11400)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java 2008-07-10 11:27:02 UTC (rev 11401)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.wsrp.producer;
-import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
-import org.jboss.portal.common.invocation.resolver.RequestAttributeResolver;
import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.portlet.ContainerURL;
@@ -63,8 +61,6 @@
private InstanceContext instanceContext;
private WindowContext windowContext;
- private static final String SCH_END = "://";
- private static final String PORT_END = ":";
private static final String EQ = "=";
private static final String AMP = "&";
private static final String EQ_TRUE = "=true";
@@ -108,28 +104,19 @@
}
else
{
- StringBuffer sb;
- if (!URLTools.isNetworkURL(url))
- {
- // URL is not an absolute URL so we need to build one
- HttpServletRequest req = getClientRequest();
- String scheme = req.getScheme();
- String host = req.getServerName();
- int port = req.getServerPort();
- sb = new StringBuffer(url.length() * 2);
- sb.append(scheme).append(SCH_END).append(host).append(PORT_END).append(port).append(url);
- url = sb.toString();
- }
+ // make root relative URLs absolute
+ url = new AbsoluteURLReplacementGenerator(getClientRequest()).getAbsoluteURLFor(url);
+ // properly encode the URL
url = URLTools.encodeXWWWFormURL(url);
// build the WSRP resource URL with rewrite tokens
- sb = new StringBuffer(url.length() * 2);
+ StringBuffer sb = new StringBuffer(url.length() * 2);
sb.append(WSRPRewritingConstants.BEGIN_WSRP_REWRITE).append(WSRPRewritingConstants.URL_TYPE_NAME)
- .append(EQ).append(WSRPRewritingConstants.URL_TYPE_RESOURCE).append(AMP)
- .append(WSRPRewritingConstants.RESOURCE_URL).append(EQ).append(url)
- .append(AMP).append(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE)
- .append(EQ_TRUE).append(WSRPRewritingConstants.END_WSRP_REWRITE);
+ .append(EQ).append(WSRPRewritingConstants.URL_TYPE_RESOURCE).append(AMP)
+ .append(WSRPRewritingConstants.RESOURCE_URL).append(EQ).append(url)
+ .append(AMP).append(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE)
+ .append(EQ_TRUE).append(WSRPRewritingConstants.END_WSRP_REWRITE);
return sb.toString();
}
}
16 years, 3 months
JBoss Portal SVN: r11400 - in branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp: producer and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:26:34 -0400 (Thu, 10 Jul 2008)
New Revision: 11400
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
Log:
- JBPORTAL-2067: Added more rewriting of URLs on both Consumer and Producer.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-10 10:03:46 UTC (rev 11399)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-10 11:26:34 UTC (rev 11400)
@@ -57,6 +57,7 @@
// transient variables
/** Access to the WS */
private ServiceFactory serviceFactory;
+ private transient String remoteHostAddress;
static final String SERVICE_DESCRIPTION = "service description";
static final String MARKUP = "markup";
@@ -394,7 +395,7 @@
catch (Exception e)
{
throw new InvokerUnavailableException("Couldn't access " + description + " service. Cause: "
- + e.getLocalizedMessage(), e);
+ + e.getLocalizedMessage(), e);
}
}
@@ -440,7 +441,7 @@
private boolean areURLsDirty()
{
return !clean.get(SD) || !clean.get(M) || (persistentPortletManagementURL != null && !clean.get(PM))
- || (persistentRegistrationURL != null && !clean.get(R));
+ || (persistentRegistrationURL != null && !clean.get(R));
}
public void refresh() throws InvokerUnavailableException
@@ -468,4 +469,16 @@
}
}
}
+
+ public String getRemoteHostAddress()
+ {
+ if (remoteHostAddress == null || areURLsDirty())
+ {
+ // extract host URL
+ int hostBegin = persistentMarkupURL.indexOf("://") + 3;
+ remoteHostAddress = persistentMarkupURL.substring(0, persistentMarkupURL.indexOf('/', hostBegin));
+ }
+
+ return remoteHostAddress;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2008-07-10 10:03:46 UTC (rev 11399)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2008-07-10 11:26:34 UTC (rev 11400)
@@ -95,7 +95,7 @@
// process the response
consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(), invocation,
- requestPrecursor.getPortletHandle());
+ requestPrecursor.getPortletHandle());
MarkupContext markupContext = markupResponse.getMarkupContext();
String markup = markupContext.getMarkupString();
@@ -103,7 +103,7 @@
if (markup != null && binary != null)
{
return new ErrorResponse(new IllegalArgumentException("Markup response cannot contain both string and binary " +
- "markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
+ "markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
}
if (markup == null && binary == null)
@@ -115,7 +115,7 @@
else
{
return new ErrorResponse(new IllegalArgumentException("Markup response must contain at least string or binary" +
- " markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
+ " markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
}
}
@@ -228,6 +228,7 @@
private Boolean secure;
private Boolean authenticated;
private WSRPConsumer consumer;
+ private static final String SLASH = "/";
public void setContext(PortletInvocationContext context)
{
@@ -236,12 +237,12 @@
public void setSecure(boolean secure)
{
- this.secure = Boolean.valueOf(secure);
+ this.secure = secure;
}
public void setAuthenticated(boolean authenticated)
{
- this.authenticated = Boolean.valueOf(authenticated);
+ this.authenticated = authenticated;
}
public void setConsumer(WSRPConsumer consumer)
@@ -252,19 +253,28 @@
public String getReplacementFor(int currentIndex, URLTools.URLMatch currentMatch)
{
String urlAsString = currentMatch.getURLAsString();
+ ProducerInfo info = consumer.getProducerInfo();
+
if (urlAsString.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
{
WSRPPortletURL portletURL = WSRPPortletURL.create(urlAsString,
- consumer.getProducerInfo().getSupportedCustomModes(), consumer.getProducerInfo().getSupportedCustomWindowStates());
+ info.getSupportedCustomModes(), info.getSupportedCustomWindowStates());
if (portletURL instanceof WSRPResourceURL)
{
log.debug("URL '" + urlAsString + "' seems to refer to a resource which are not currently supported. " +
- "Trying to use the raw URL but this probably won't work...");
+ "Trying to use the raw URL but this probably won't work...");
return portletURL.toString();
}
return context.renderURL(portletURL, secure, authenticated, true);
}
+
+ // todo: this is a hack to circumvent frameworks that don't properly request resource encoding (icefaces)
+ if (urlAsString.startsWith(SLASH))
+ {
+ return info.getEndpointConfigurationInfo().getRemoteHostAddress() + urlAsString;
+ }
+
return urlAsString;
}
}
@@ -280,7 +290,7 @@
{
int index = urlAsString.indexOf(WSRPRewritingConstants.FAKE_RESOURCE_REQ_REW);
String requireRewriteStr = urlAsString.substring(index + WSRPRewritingConstants.FAKE_RESOURCE_REQ_REW.length());
- boolean requireRewrite = Boolean.valueOf(requireRewriteStr).booleanValue();
+ boolean requireRewrite = Boolean.valueOf(requireRewriteStr);
urlAsString = urlAsString.substring(prefix.length(), index);
if (requireRewrite)
Added: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java 2008-07-10 11:26:34 UTC (rev 11400)
@@ -0,0 +1,62 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.producer;
+
+import org.jboss.portal.common.net.URLTools;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class AbsoluteURLReplacementGenerator extends URLTools.URLReplacementGenerator
+{
+ private String serverAddress;
+ static final String SCH_END = "://";
+ static final String PORT_END = ":";
+
+ public AbsoluteURLReplacementGenerator(HttpServletRequest request)
+ {
+ String scheme = request.getScheme();
+ String host = request.getServerName();
+ int port = request.getServerPort();
+
+ serverAddress = scheme + SCH_END + host + PORT_END + port;
+ }
+
+ public String getReplacementFor(int i, URLTools.URLMatch urlMatch)
+ {
+ return getAbsoluteURLFor(urlMatch.getURLAsString());
+ }
+
+ public String getAbsoluteURLFor(String url)
+ {
+ if (!URLTools.isNetworkURL(url))
+ {
+ return serverAddress + url;
+ }
+
+ return url;
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2008-07-10 10:03:46 UTC (rev 11399)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2008-07-10 11:26:34 UTC (rev 11400)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.producer;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.StateString;
@@ -65,8 +66,8 @@
private final GetMarkup getMarkup;
public RenderRequestProcessor(WSRPProducerImpl producer, GetMarkup getMarkup) throws UnsupportedMimeTypeFault,
- UnsupportedWindowStateFault, InvalidHandleFault, UnsupportedModeFault, MissingParametersFault,
- InvalidRegistrationFault, OperationFailedFault
+ UnsupportedWindowStateFault, InvalidHandleFault, UnsupportedModeFault, MissingParametersFault,
+ InvalidRegistrationFault, OperationFailedFault
{
super(producer);
this.getMarkup = getMarkup;
@@ -115,9 +116,9 @@
)
{
WSRPRenderContext renderContext = new WSRPRenderContext(navigationalState, securityContext, markupInfo,
- portalContext, userContext, instanceContext, windowContext,
- WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
- WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
+ portalContext, userContext, instanceContext, windowContext,
+ WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
+ WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
setInvocation(new RenderInvocation(renderContext));
renderContext.contextualize(invocation);
@@ -182,10 +183,13 @@
*/
private String processFragmentString(String renderString)
{
- return Tools.replaceAllInstancesOfBoundedString(
- renderString,
- PortletUtils.PREFIX,
- PortletUtils.SUFFIX,
- WSRPRewritingConstants.WSRP_REWRITE_TOKEN);
+ String result = Tools.replaceAllInstancesOfBoundedString(
+ renderString,
+ PortletUtils.PREFIX,
+ PortletUtils.SUFFIX,
+ WSRPRewritingConstants.WSRP_REWRITE_TOKEN);
+
+ result = URLTools.replaceURLsBy(result, new AbsoluteURLReplacementGenerator(invocation.getDispatchedRequest()));
+ return result;
}
}
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java 2008-07-10 10:03:46 UTC (rev 11399)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java 2008-07-10 11:26:34 UTC (rev 11400)
@@ -62,8 +62,6 @@
private InstanceContext instanceContext;
private WindowContext windowContext;
- private static final String SCH_END = "://";
- private static final String PORT_END = ":";
private static final String EQ = "=";
private static final String AMP = "&";
private static final String EQ_TRUE = "=true";
@@ -111,28 +109,19 @@
}
else
{
- StringBuffer sb;
- if (!URLTools.isNetworkURL(url))
- {
- // URL is not an absolute URL so we need to build one
- HttpServletRequest req = getClientRequest();
- String scheme = req.getScheme();
- String host = req.getServerName();
- int port = req.getServerPort();
- sb = new StringBuffer(url.length() * 2);
- sb.append(scheme).append(SCH_END).append(host).append(PORT_END).append(port).append(url);
- url = sb.toString();
- }
+ // make root relative URLs absolute
+ url = new AbsoluteURLReplacementGenerator(getClientRequest()).getAbsoluteURLFor(url);
+ // properly encode the URL
url = URLTools.encodeXWWWFormURL(url);
// build the WSRP resource URL with rewrite tokens
- sb = new StringBuffer(url.length() * 2);
+ StringBuffer sb = new StringBuffer(url.length() * 2);
sb.append(WSRPRewritingConstants.BEGIN_WSRP_REWRITE).append(WSRPRewritingConstants.URL_TYPE_NAME)
- .append(EQ).append(WSRPRewritingConstants.URL_TYPE_RESOURCE).append(AMP)
- .append(WSRPRewritingConstants.RESOURCE_URL).append(EQ).append(url)
- .append(AMP).append(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE)
- .append(EQ_TRUE).append(WSRPRewritingConstants.END_WSRP_REWRITE);
+ .append(EQ).append(WSRPRewritingConstants.URL_TYPE_RESOURCE).append(AMP)
+ .append(WSRPRewritingConstants.RESOURCE_URL).append(EQ).append(url)
+ .append(AMP).append(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE)
+ .append(EQ_TRUE).append(WSRPRewritingConstants.END_WSRP_REWRITE);
return sb.toString();
}
}
16 years, 3 months