JBoss Portal SVN: r6665 - trunk/core/src/main/org/jboss/portal/core/aspects/controller.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-14 10:07:51 -0400 (Wed, 14 Mar 2007)
New Revision: 6665
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
Log:
Don't display unauthorized sub-menu links [JBPORTAL-1319]
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-03-14 13:41:46 UTC (rev 6664)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-03-14 14:07:51 UTC (rev 6665)
@@ -55,6 +55,7 @@
import org.jboss.portal.theme.page.WindowResult;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -352,8 +353,10 @@
}
html.append(" onmouseover=\"this.className='hoverOn'\" onmouseout=\"this.className='hoverOff'\"><a href='").append(childURL).append("'>").append(name);
+ List childPages = getAuthorizedChildrenPages(navElement);
+
// ie 6 hack
- if (hasChildPages(navElement))
+ if (childPages.size() != 0)
{
html.append("<!--[if IE 7]><!--></a><!--<![endif]-->");
html.append("<!--[if lte IE 6]><table><tr><td><![endif]-->");
@@ -364,10 +367,10 @@
}
// Submenu logic
- if (hasChildPages(navElement))
+ if (childPages.size() != 0)
{
html.append("<ul>");
- for (Iterator j = navElement.getChildren().iterator(); j.hasNext();)
+ for (Iterator j = childPages.iterator(); j.hasNext();)
{
PortalObject child = (PortalObject)j.next();
if (child.getType() == PortalObject.TYPE_PAGE)
@@ -394,18 +397,24 @@
return null;
}
}
-
- private boolean hasChildPages(PortalObject portalObject)
+
+ private List getAuthorizedChildrenPages(PortalObject portalObject)
{
- for (Iterator i = portalObject.getChildren().iterator(); i.hasNext();)
+ List result = new ArrayList();
+ Collection children = portalObject.getChildren(PortalObject.PAGE_MASK);
+
+ for (Iterator i = children.iterator(); i.hasNext();)
{
PortalObject child = (PortalObject)i.next();
- if (child.getType() == PortalObject.TYPE_PAGE)
+ PortalObjectId id = child.getId();
+
+ PortalObjectPermission perm = new PortalObjectPermission(id, PortalObjectPermission.VIEW_MASK);
+ if (portalAuthorizationManagerFactory.getManager().checkPermission(perm))
{
- return true;
+ result.add(child);
}
}
- return false;
+ return result;
}
protected void sortTabs(List navElements)
17 years, 6 months
JBoss Portal SVN: r6664 - docs/trunk/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-14 09:41:46 -0400 (Wed, 14 Mar 2007)
New Revision: 6664
Modified:
docs/trunk/referenceGuide/en/modules/authentication.xml
docs/trunk/referenceGuide/en/modules/identity.xml
docs/trunk/referenceGuide/en/modules/ldap.xml
Log:
ldap docs update
Modified: docs/trunk/referenceGuide/en/modules/authentication.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/authentication.xml 2007-03-14 12:21:56 UTC (rev 6663)
+++ docs/trunk/referenceGuide/en/modules/authentication.xml 2007-03-14 13:41:46 UTC (rev 6664)
@@ -183,7 +183,7 @@
</mbean>]]>
</programlisting>
</sect2>
- <sect2>
+ <sect2 id="authentication.synchronizing_login_module">
<title>org.jboss.portal.identity.auth.SynchronizingLoginModule</title>
<para>
This module is designed to provide synchronization support for any other LoginModule placed in the authentication stack.
Modified: docs/trunk/referenceGuide/en/modules/identity.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/identity.xml 2007-03-14 12:21:56 UTC (rev 6663)
+++ docs/trunk/referenceGuide/en/modules/identity.xml 2007-03-14 13:41:46 UTC (rev 6664)
@@ -813,7 +813,7 @@
</itemizedlist>
</para>
</sect2>
- <sect2>
+ <sect2 id="identity.management_api">
<title>Delegating UserProfile module</title>
<para>Delegating UserProfileModule implementation has very specific role. When we use storage mechanism like LDAP we may not be able to map all
user properties into LDAP attributes because of schema limitations. To solve this problem we use database to store such not mapped properties.
Modified: docs/trunk/referenceGuide/en/modules/ldap.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/ldap.xml 2007-03-14 12:21:56 UTC (rev 6663)
+++ docs/trunk/referenceGuide/en/modules/ldap.xml 2007-03-14 13:41:46 UTC (rev 6664)
@@ -169,6 +169,43 @@
</sect2>
<sect2>
<title>UserModule</title>
+ <para>
+ <table frame="all">
+ <title>Comparision of UserModule implementations</title>
+ <tgroup cols="3" align="left" colsep="1" rowset="1">
+ <colspec colname='c1'/>
+ <colspec colname='c2'/>
+ <colspec colname='c3'/>
+ <thead>
+ <row>
+ <entry align="center" morerows="1">Features</entry>
+ <entry align="center" namest="c2" nameend="c3">UserModule</entry>
+ </row>
+ <row>
+ <entry align="center">LDAPUserModuleImpl</entry>
+ <entry align="center">LDAPExtUserModuleImpl</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>User creation</entry>
+ <entry align="center">X</entry>
+ <entry align="center">-</entry>
+ </row>
+ <row>
+ <entry>User removal</entry>
+ <entry align="center">X</entry>
+ <entry align="center">-</entry>
+ </row>
+ <row>
+ <entry>User search</entry>
+ <entry align="center">Flat - one level scope</entry>
+ <entry align="center">Flexible filter - sub tree scope</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
<sect3>
<title>LDAPUserModuleImpl</title>
<para>TODO:</para>
@@ -290,8 +327,8 @@
<listitem>
<emphasis role="bold">searchTimeLimit</emphasis> - The timeout in milliseconds for the user searches. Defaults to 10000 (10 seconds).
</listitem>
- <listitem>
- <emphasis role="bold">searchScope</emphasis> - Sets the search scope to one of the strings. The default is SUBTREE_SCOPE.
+ <!--<listitem>
+ <emphasis role="bold">searchScope</emphasis> - Sets the search scope to one of the strings. The default is SUBTREE_SCOPE.
<itemizedlist>
<listitem>
<emphasis role="bold">OBJECT_SCOPE</emphasis> - only search the named users context.
@@ -304,7 +341,7 @@
If the users context is a <emphasis>DirContext</emphasis>, search the subtree rooted at the named object, including the named object itself.
</listitem>
</itemizedlist>
- </listitem>
+ </listitem>-->
</itemizedlist>
</listitem>
</itemizedlist>
@@ -314,9 +351,47 @@
</sect2>
<sect2>
<title>RoleModule</title>
+ <para>
+ <table frame="all">
+ <title>Comparision of RoleModule implementations</title>
+ <tgroup cols="3" align="left" colsep="1" rowset="1">
+ <colspec colname='c1'/>
+ <colspec colname='c2'/>
+ <colspec colname='c3'/>
+ <thead>
+ <row>
+ <entry align="center" morerows="1">Features</entry>
+ <entry align="center" namest="c2" nameend="c3">RoleModule</entry>
+ </row>
+ <row>
+ <entry align="center">LDAPRoleModuleImpl</entry>
+ <entry align="center">LDAPExtRoleModuleImpl</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Role creation</entry>
+ <entry align="center">X</entry>
+ <entry align="center">-</entry>
+ </row>
+ <row>
+ <entry>Role removal</entry>
+ <entry align="center">X</entry>
+ <entry align="center">-</entry>
+ </row>
+ <row>
+ <entry>Role search</entry>
+ <entry align="center">Flat - one level scope</entry>
+ <entry align="center">Flexible filter - sub tree scope</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
<sect3>
<title>LDAPRoleModuleImpl</title>
<para>TODO:</para>
+ <para>This module doesn't support role creation and removal</para>
<para>To enable it in your configuration you should have:
<programlisting>
<![CDATA[
@@ -408,9 +483,62 @@
</itemizedlist>
</para>
</sect3>
+ <note>In <emphasis>UserModule</emphasis> there are two methods that handle offset/limit (pagination) behaviour.
+ <programlisting>
+ <![CDATA[
+ /** Get a range of users.*/
+ Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException;
+
+ /** Get a range of users.*/
+ Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException;
+ ]]>
+ </programlisting>
+ Pagination support is not widely implemented in LDAP servers. Because <emphasis>UserModule</emphasis>
+ implementations rely on JNDI and are targetted to be LDAP server agnostic those methods are very effecient.
+ As long as you don't rely on portal user management and use dedicated tools for user provisioning it
+ shouldn't bother you. Otherwise you should consider extending the implementation and providing
+ solution dedicated to your LDAP server.
+ </note>
</sect2>
<sect2>
<title>MembershipModule</title>
+ <para>
+ <table frame="all">
+ <title>Comparision of MembershipModule implementations</title>
+ <tgroup cols="3" align="left" colsep="1" rowset="1">
+ <colspec colname='c1'/>
+ <colspec colname='c2'/>
+ <colspec colname='c3'/>
+ <thead>
+ <row>
+ <entry align="center" morerows="1">Features</entry>
+ <entry align="center" namest="c2" nameend="c3">MembershipModule</entry>
+ </row>
+ <row>
+ <entry align="center">LDAPStaticGroupMembershipModuleImpl</entry>
+ <entry align="center">LDAPStaticRoleMembershipModuleImpl</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Role assignment stored in LDAP role entry</entry>
+ <entry align="center">X</entry>
+ <entry align="center">-</entry>
+ </row>
+ <row>
+ <entry>Role assignment stored in LDAP user entry</entry>
+ <entry align="center">-</entry>
+ <entry align="center">X</entry>
+ </row>
+ <row>
+ <entry>User/Role relationship creation</entry>
+ <entry align="center">X</entry>
+ <entry align="center">X</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
<sect3>
<title>LDAPStaticGroupMembershipModuleImpl</title>
<para>TODO:</para>
@@ -516,7 +644,9 @@
</module>
]]>
</programlisting>
- <note>Using such configuration you will have LDAP MembershipModule along with DB MembershipModule and Delegating MembershipModule</note>
+ <note>Using such configuration you will have LDAP MembershipModule along with DB MembershipModule and Delegating MembershipModule. Please read
+ <link linkend="identity.management_api">Identity</link> chapter to see why this is important.
+ </note>
</para>
<para>org.jboss.portal.identity.ldap.LDAPUserModuleImpl configuration option-groups options:
<itemizedlist>
@@ -536,46 +666,171 @@
</sect1>
<sect1>
<title>LDAP server tree shapes</title>
- <para>TODO:</para>
- <para>Tree:
- <mediaobject>
- <imageobject>
- <imagedata align="center" valign="middle" fileref="images/ldap/tree1-1.png"/>
- </imageobject>
- </mediaobject>
+ <para>JBoss Portal supports full user/role management for simple LDAP tree shapes. Some more flexible
+ trees can be supported by <emphasis>LdapExtUserModuleImpl</emphasis> and <emphasis>LdapExtRoleModuleImpl</emphasis>
+ - but without user/role creation, removal capabilities.
+ However if you have complex LDAP tree you should consider using
+ <link linkend="authentication.synchronizing_login_module">SynchronizingLoginModule</link> described in
+ <link linkend="authentication">Authentication</link> chapter along with dedicated tools for user
+ provisioning provided with LDAP server.</para>
+ <para>
+ In following subsections we will describe two base LDAP tree shapes along with example ldifs and portal
+ identity modules configurations.
</para>
- <para>Tree:
+ <sect2>
+ <title>Keeping users membership in role entries</title>
+ <para>TODO></para>
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree1-1.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree1-2.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <para>Example LDIF:
+ <programlisting>
+ <![CDATA[
+dn: dc=example,dc=com
+objectclass: top
+objectclass: dcObject
+objectclass: organization
+dc: example
+o: example
+
+dn: ou=People,dc=example,dc=com
+objectclass: top
+objectclass: organizationalUnit
+ou: People
+
+dn: uid=user,ou=People,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: user
+cn: JBoss Portal user
+sn: user
+userPassword: user
+mail: email(a)email.com
+
+dn: ou=Roles,dc=example,dc=com
+objectclass: top
+objectclass: organizationalUnit
+ou: Roles
+
+dn: cn=User,ou=Roles,dc=example,dc=com
+objectClass: top
+objectClass: groupOfNames
+cn: User
+description: the JBoss Portal user group
+member: uid=user,ou=People,dc=example,dc=com
+ ]]>
+ </programlisting>
+ </para>
+ <para>Example identity configuration:
+ <programlisting>
+ <![CDATA[
+
+ ]]>
+ </programlisting>
+ </para>
+ </sect2>
+ <sect2>
+ <title>Keeping users membership in user entries</title>
+ <!--<para>Tree:
<mediaobject>
<imageobject>
- <imagedata align="center" valign="middle" fileref="images/ldap/tree1-2.png"/>
- </imageobject>
- </mediaobject>
- </para>
- <!--<para>Tree:
- <mediaobject>
- <imageobject>
<imagedata align="center" valign="middle" fileref="images/ldap/tree2-1.png"/>
</imageobject>
</mediaobject>
</para>-->
- <para>Tree:
- <mediaobject>
- <imageobject>
- <imagedata align="center" valign="middle" fileref="images/ldap/tree2-3.png"/>
- </imageobject>
- </mediaobject>
- </para>
- <para>Tree:
- <mediaobject>
- <imageobject>
- <imagedata align="center" valign="middle" fileref="images/ldap/tree2-4.png"/>
- </imageobject>
- </mediaobject>
- </para>
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree2-3.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree2-4.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <para>Example LDIF:
+ <programlisting>
+ <![CDATA[
+dn: dc=example,dc=com
+objectclass: top
+objectclass: dcObject
+objectclass: organization
+dc: example
+o: example
+
+dn: o=example2,dc=example,dc=com
+objectclass: top
+objectclass: organization
+o: example2
+
+dn: ou=People,o=example2,dc=example,dc=com
+objectclass: top
+objectclass: organizationalUnit
+ou: People
+
+dn: uid=admin,ou=People,o=example2,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: inetUser
+uid: admin
+cn: JBoss Portal admin
+sn: admin
+userPassword: admin
+mail: email(a)email.com
+memberOf: cn=Admin,ou=Roles,o=example2,dc=example,dc=com
+
+dn: ou=Roles,o=example2,dc=example,dc=com
+objectclass: top
+objectclass: organizationalUnit
+ou: Roles
+
+dn: cn=Admin,ou=Roles,o=example2,dc=example,dc=com
+objectClass: top
+objectClass: organizationalRole
+cn: Echo
+description: the JBossAdmin group
+ ]]>
+ </programlisting>
+ </para>
+ <para>Example identity configuration:
+ <programlisting>
+ <![CDATA[
+
+ ]]>
+ </programlisting>
+ </para>
+ </sect2>
</sect1>
<sect1>
<title>Supported LDAP servers</title>
- <para></para>
+ <para>LDAP servers support depends on few conditions. In most cases thy differ in schema support - various objectClass
+ objects are not present by default in server schema. Sometimes it can be workarounded by manually
+ extending schema.</para>
+ <para>
+ Servers can be
+ <itemizedlist>
+ <listitem><emphasis>Supported</emphasis></listitem>
+ <listitem><emphasis>Not Supported</emphasis></listitem>
+ <listitem><emphasis>Experimental</emphasis> - implementation can work with such server but it's not well tested so
+ shouldn't be considered for production.</listitem>
+ </itemizedlist>
+ </para>
<table frame="all">
<title>Support of identity modules with different LDAP servers</title>
<tgroup cols="8" align="left" colsep="1" rowset="1">
@@ -608,33 +863,33 @@
<tbody>
<row>
<entry>Red Hat Directory Server</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
</row>
<row>
<entry>OpenDS</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">-</entry>
- <entry align="center">X</entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Not Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
</row>
<row>
<entry>OpenLDAP</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">X</entry>
- <entry align="center">-</entry>
- <entry align="center">X</entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
+ <entry align="center"><emphasis>Not Supported</emphasis></entry>
+ <entry align="center"><emphasis>Supported</emphasis></entry>
</row>
<row>
<entry>Microsoft Active Directory</entry>
17 years, 6 months
JBoss Portal SVN: r6663 - in trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf: common and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-14 08:21:56 -0400 (Wed, 14 Mar 2007)
New Revision: 6663
Added:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editWindowTheme.xhtml
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindowTheme.xhtml
Log:
Couldn't remove window decorations anymore [JBPORTAL-1318]
Added: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editWindowTheme.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editWindowTheme.xhtml (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editWindowTheme.xhtml 2007-03-14 12:21:56 UTC (rev 6663)
@@ -0,0 +1,48 @@
+<div
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <h:panelGroup styleClass="portlet-section-body" id="themepg">
+ <h:form id="themeform">
+ <fieldset style="border: 1px solid;">
+ <legend>Theme properties</legend>
+ <table>
+ <tbody>
+ <tr>
+ <td class="portlet-form-field-label"><label class="portlet-form-field-label">Window Renderer:</label>
+ </td>
+ <td>
+ <h:selectOneMenu styleClass="portlet-form-field" value="#{themePropertyAction.windowRendererName}">
+ <f:selectItems value="#{portalobjectmgr.themes.renderSetNames}"/>
+ </h:selectOneMenu>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-form-field-label"><label class="portlet-form-field-label">Decoration Renderer:</label>
+ </td>
+ <td>
+ <h:selectOneMenu styleClass="portlet-form-field" value="#{themePropertyAction.decorationRendererName}">
+ <f:selectItems value="#{portalobjectmgr.themes.renderSetNames}"/>
+ </h:selectOneMenu>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-form-field-label"><label class="portlet-form-field-label">Portlet Renderer:</label>
+ </td>
+ <td>
+ <h:selectOneMenu styleClass="portlet-form-field" value="#{themePropertyAction.portletRendererName}">
+ <f:selectItems value="#{portalobjectmgr.themes.renderSetNames}"/>
+ </h:selectOneMenu>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </fieldset>
+ <div style="text-align:center;padding: 1em 0 1em 0">
+ <ui:insert name="form_submit"/>
+ </div>
+ </h:form>
+</h:panelGroup>
+</div>
\ No newline at end of file
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindowTheme.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindowTheme.xhtml 2007-03-14 11:46:07 UTC (rev 6662)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindowTheme.xhtml 2007-03-14 12:21:56 UTC (rev 6663)
@@ -8,7 +8,7 @@
<h3>Please set the display options for the window:
<h:outputText value="#{portalobjectmgr.selectedObject.name}"/>
</h3>
- <ui:decorate template="common/editTheme.xhtml">
+ <ui:decorate template="common/editWindowTheme.xhtml">
<ui:define name="form_submit">
<h:form>
<h:commandButton value="Update" action="#{themePropertyAction.execute}" styleClass="portlet-form-button"/>
17 years, 6 months
JBoss Portal SVN: r6662 - branches/JBoss_Portal_Branch_2_4/core/src/main/org/jboss/portal/core/portlet/management.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-14 07:46:07 -0400 (Wed, 14 Mar 2007)
New Revision: 6662
Modified:
branches/JBoss_Portal_Branch_2_4/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
Log:
preserveDataModel on the properties broke the management portlet
Modified: branches/JBoss_Portal_Branch_2_4/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java 2007-03-14 05:34:40 UTC (rev 6661)
+++ branches/JBoss_Portal_Branch_2_4/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java 2007-03-14 11:46:07 UTC (rev 6662)
@@ -315,10 +315,13 @@
//return selectedProperties;
PortalObject object = getSelectedObject();
List properties = new ArrayList();
- for (Iterator i = object.getDeclaredPropertyMap().entrySet().iterator(); i.hasNext();)
+ if (object != null)
{
- Map.Entry entry = (Map.Entry)i.next();
- properties.add(new String[]{(String)entry.getKey(), (String)entry.getValue()});
+ for (Iterator i = object.getDeclaredPropertyMap().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ properties.add(new String[]{(String)entry.getKey(), (String)entry.getValue()});
+ }
}
return properties;
}
17 years, 6 months
JBoss Portal SVN: r6661 - in trunk/wsrp: src/main/org/jboss/portal/wsrp and 8 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-03-14 01:34:40 -0400 (Wed, 14 Mar 2007)
New Revision: 6661
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
trunk/wsrp/src/resources/portal-wsrp-war/style.css
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jboss-portlet.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/portlet.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml
Log:
- Started JSF implementation of WSRP Consumers configuration.
- Renamed portal.wsrp:service=ConsumersRegistry service to portal.wsrp:service=ConsumerRegistry.
- Added ProducerInfo.isRegistered method.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-03-14 05:32:02 UTC (rev 6660)
+++ trunk/wsrp/build.xml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -138,6 +138,7 @@
<path refid="jboss.portal-portlet.classpath"/>
<path refid="jboss.portal-portlet-federation.classpath"/>
<path refid="jboss.portal-test.classpath"/>
+ <path refid="jboss.portal-faces.classpath"/>
</path>
<!--+=======================================+-->
@@ -281,6 +282,12 @@
</fileset>
<!--<fileset dir="${build.resources}/portal-wsrp-lib-jar"/>-->
</jar>
+ <copy todir="${build.resources}/portal-wsrp-war/lib">
+ <!-- For JSF -->
+ <fileset dir="../core-admin/src/etc/sun-jsf" includes="jsf-example.jar"/>
+ <fileset dir="${facelets.facelets.lib}" includes="jsf-facelets.jar"/>
+ <fileset dir="${el.el.lib}" includes="el-api.jar,el-ri.jar"/>
+ </copy>
<jar jarfile="${build.lib}/portal-wsrp-test-lib.jar">
<fileset dir="${build.classes}">
<include name="org/jboss/portal/test/**"/>
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-03-14 05:34:40 UTC (rev 6661)
@@ -0,0 +1,73 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, 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.admin.ui;
+
+import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerManagerBean
+{
+ private ConsumerRegistry registry;
+
+ public ConsumerRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(ConsumerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public Collection getConsumers()
+ {
+ return new ArrayList(registry.getConfiguredConsumers());
+ }
+
+ public void activateConsumer()
+ {
+
+ }
+
+ public void registerConsumer()
+ {
+
+ }
+
+ public void destroyConsumer()
+ {
+
+ }
+
+ public void configureConsumer()
+ {
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-14 05:32:02 UTC (rev 6660)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-14 05:34:40 UTC (rev 6661)
@@ -161,6 +161,11 @@
this.persistentRegistrationInfo = registrationInfo;
}
+ public boolean isRegistered()
+ {
+ return persistentRegistrationInfo != null && persistentRegistrationInfo.isRegistrationValid();
+ }
+
/**
* Determines whether the associated consumer is active.
*
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2007-03-14 05:32:02 UTC (rev 6660)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -129,7 +129,7 @@
<attribute name="DefaultWSRPLocation">default-wsrp.xml</attribute>
<depends>jboss.system:service=MainDeployer</depends>
<depends optional-attribute-name="ConsumerRegistry"
- proxy-type="attribute">portal.wsrp:service=ConsumersRegistry</depends>
+ proxy-type="attribute">portal.wsrp:service=ConsumerRegistry</depends>
<depends optional-attribute-name="EntityResolver"
proxy-type="attribute">portal.wsrp:service=EntityResolver</depends>
</mbean>
@@ -151,7 +151,7 @@
<!-- Consumers registry for WSRP consumers -->
<mbean code="org.jboss.portal.wsrp.consumer.ConsumerRegistryService"
- name="portal.wsrp:service=ConsumersRegistry"
+ name="portal.wsrp:service=ConsumerRegistry"
xmbean-dd="" xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<depends>portal:service=Hibernate,type=WSRPConsumer</depends>
Added: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml (rev 0)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2007, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!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>
+
+ <!-- Facelet portlet view handler-->
+ <application>
+ <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
+ </application>
+
+ <managed-bean>
+ <managed-bean-name>consumersMgr</managed-bean-name>
+ <managed-bean-class>org.jboss.portal.wsrp.admin.ui.ConsumerManagerBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>registry</property-name>
+ <property-class>org.jboss.portal.wsrp.consumer.ConsumerRegistry</property-class>
+ <value>#{applicationScope.ConsumerRegistry}</value>
+ </managed-property>
+ </managed-bean>
+
+ <navigation-rule>
+ <navigation-case>
+ <from-outcome>index</from-outcome>
+ <to-view-id>/WEB-INF/jsf/consumers/consumers.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+</faces-config>
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jboss-portlet.xml 2007-03-14 05:32:02 UTC (rev 6660)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jboss-portlet.xml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -22,10 +22,19 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!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>
+ <portlet>
+ <portlet-name>WSRPConsumersConfigurationPortlet</portlet-name>
+ <transaction>
+ <trans-attribute>Required</trans-attribute>
+ </transaction>
+ <header-content>
+ <link rel="stylesheet" type="text/css" href="/style.css" title="" media="screen"/>
+ </header-content>
+ </portlet>
<service>
- <service-name>ConsumersRegistry</service-name>
+ <service-name>ConsumerRegistry</service-name>
<service-class>org.jboss.portal.wsrp.consumer.ConsumerRegistry</service-class>
- <service-ref>portal.wsrp:service=ConsumersRegistry</service-ref>
+ <service-ref>portal.wsrp:service=ConsumerRegistry</service-ref>
</service>
</portlet-app>
Added: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml (rev 0)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -0,0 +1,53 @@
+<div class="wsrp-consumers-ui"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+ <h1 class="portlet">Configured WSRP Consumers</h1>
+
+ <hr/>
+
+ <h:form>
+ <table width="100%" class="portlet-table-body">
+ <thead class="portlet-table-header">
+ <tr>
+ <th>Consumer</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tfoot class="portlet-table-footer">
+ <tr>
+ <th>Consumer</th>
+ <th>Actions</th>
+ </tr>
+ </tfoot>
+ <tbody>
+ <c:forEach items="#{consumersMgr.consumers}" var="consumer" varStatus="status">
+ <tr class="status.index % 2 == 0 ? 'portlet-table-body' : 'portlet-table-alternate'">
+ <td>
+ <h:commandLink action="#{consumersMgr.configureConsumer}">
+ <h:outputText value="#{consumer.producerId}"/>
+ </h:commandLink>
+ </td>
+ <td>
+ <h:commandLink action="#{consumersMgr.configureConsumer}">
+ <h:outputText value="Configure"/>
+ </h:commandLink> | <h:commandLink action="#{consumersMgr.activateConsumer}">
+ <h:outputText value='#{consumer.producerInfo.active ? "Deactivate" : "Activate"}'/>
+ </h:commandLink>
+ <c:if test="#{consumer.producerInfo.active}"> | <h:commandLink
+ action="#{consumersMgr.registerConsumer}">
+ <h:outputText value="#{consumer.producerInfo.registered ? 'Deregister' : 'Register'}"/>
+ </h:commandLink>
+ </c:if> | <h:commandLink action="#{consumersMgr.destroyConsumer}">
+ <h:outputText value="Destroy"/>
+ </h:commandLink>
+ </td>
+ </tr>
+ </c:forEach>
+ </tbody>
+ </table>
+ </h:form>
+</div>
\ No newline at end of file
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/portlet.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/portlet.xml 2007-03-14 05:32:02 UTC (rev 6660)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/portlet.xml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -1,6 +1,6 @@
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ Copyright 2007, 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. ~
@@ -29,14 +29,20 @@
<description>Configuration portlet for WSRP remote producers.</description>
<portlet-name>WSRPConsumersConfigurationPortlet</portlet-name>
<display-name>WSRP Consumers Configuration</display-name>
- <portlet-class>org.jboss.portal.wsrp.portlet.consumers.WSRPConsumerConfigurationPortlet</portlet-class>
+ <portlet-class>org.jboss.portal.faces.portlet.JSFMetaBridgePortlet</portlet-class>
+ <init-param>
+ <name>VIEW</name>
+ <value>/WEB-INF/jsf/consumers/consumers.xhtml</value>
+ </init-param>
+ <expiration-cache>-1</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<portlet-info>
<title>WSRP Consumers Configuration</title>
+ <keywords>management,admin,wsrp</keywords>
</portlet-info>
- </portlet>
+ </portlet>
</portlet-app>
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml 2007-03-14 05:32:02 UTC (rev 6660)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -32,23 +32,27 @@
<filter-name>ServletAccessFilter</filter-name>
<filter-class>org.jboss.portal.wsrp.servlet.ServletAccessFilter</filter-class>
</filter>
+ <filter-mapping>
+ <filter-name>ServletAccessFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <!-- Wraps WSRP requests in transactions -->
<filter>
<filter-name>TransactionFilter</filter-name>
<filter-class>org.jboss.portal.wsrp.servlet.TransactionFilter</filter-class>
</filter>
+ <filter-mapping>
+ <filter-name>TransactionFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <!-- Fixes port numbers that are not properly propagated by JBoss WS -->
<filter>
<filter-name>WSDLPortFixFilter</filter-name>
<filter-class>org.jboss.portal.wsrp.servlet.WSDLPortFixFilter</filter-class>
</filter>
<filter-mapping>
- <filter-name>ServletAccessFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>TransactionFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <filter-mapping>
<filter-name>WSDLPortFixFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
@@ -92,7 +96,7 @@
</init-param>
</servlet>
- <!-- Mappings -->
+ <!-- WSRP endpoint mappings -->
<servlet-mapping>
<servlet-name>ServiceDescriptionService</servlet-name>
<url-pattern>/ServiceDescriptionService</url-pattern>
@@ -109,6 +113,60 @@
<servlet-name>PortletManagementService</servlet-name>
<url-pattern>/PortletManagementService</url-pattern>
</servlet-mapping>
+
+ <!-- MyFaces specific configuration -->
+ <context-param>
+ <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!-- Facelet configuration -->
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>facelets.SKIP_COMMENTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!-- JSF configuration -->
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+
+ <!-- JSF entry point -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Bootstrap MyFaces -->
+ <listener>
+ <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
+ </listener>
</web-app>
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml 2007-03-14 05:32:02 UTC (rev 6660)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml 2007-03-14 05:34:40 UTC (rev 6661)
@@ -22,9 +22,7 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-<!DOCTYPE deployments PUBLIC
- "-//JBoss Portal//DTD Portal Object 2.6//EN"
- "http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
+<!DOCTYPE deployments PUBLIC "-//JBoss Portal//DTD Portal Object 2.6//EN" "http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
<deployments>
<deployment>
@@ -32,18 +30,24 @@
<if-exists>keep</if-exists>
<page>
<page-name>WSRP</page-name>
+ <security-constraint>
+ <policy-permission>
+ <action-name>viewrecursive</action-name>
+ <role-name>Admin</role-name>
+ </policy-permission>
+ </security-constraint>
<window>
<window-name>WSRPConsumersConfigurationPortletWindow</window-name>
<instance-ref>WSRPConsumersConfigurationPortletInstance</instance-ref>
<region>center</region>
<height>0</height>
</window>
- <security-constraint>
- <policy-permission>
- <role-name>Admin</role-name>
- <action-name>viewrecursive</action-name>
- </policy-permission>
- </security-constraint>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
</page>
</deployment>
</deployments>
Added: trunk/wsrp/src/resources/portal-wsrp-war/style.css
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/style.css (rev 0)
+++ trunk/wsrp/src/resources/portal-wsrp-war/style.css 2007-03-14 05:34:40 UTC (rev 6661)
@@ -0,0 +1,16 @@
+.wsrp-consumers-ui table {
+ border: 0;
+ border-collapse: separate;
+}
+
+.wsrp-consumers-ui th {
+ text-align: left;
+ border: 0;
+ border-bottom: 1px solid;
+}
+
+.wsrp-consumers-ui td {
+ border: 0;
+ padding-bottom: 2px;
+ padding-top: 2px;
+}
17 years, 6 months
JBoss Portal SVN: r6660 - trunk/core/src/bin/portal-core-war/themes/renaissance.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-03-14 01:32:02 -0400 (Wed, 14 Mar 2007)
New Revision: 6660
Modified:
trunk/core/src/bin/portal-core-war/themes/renaissance/portal_style.css
Log:
- Fix portlet-table-footer.
Modified: trunk/core/src/bin/portal-core-war/themes/renaissance/portal_style.css
===================================================================
--- trunk/core/src/bin/portal-core-war/themes/renaissance/portal_style.css 2007-03-13 23:49:21 UTC (rev 6659)
+++ trunk/core/src/bin/portal-core-war/themes/renaissance/portal_style.css 2007-03-14 05:32:02 UTC (rev 6660)
@@ -168,8 +168,7 @@
float: left;
margin: 0px;
padding: 0px;
- min-width: 250px;
- /*height: 300px;*/
+ min-width: 250px; /*height: 300px;*/
}
#regionB {
@@ -180,8 +179,7 @@
margin: 0 0 0 30%;*/
padding: 0px; /* test to add 3rd region in layout...*/
width: 67%;
- float: left;
- /*height: 300px;*/
+ float: left; /*height: 300px;*/
}
#regionC {
@@ -229,7 +227,7 @@
margin-top: 39px;
min-width: 550px;
z-index: 100; /* added for submenu hover */
- /*position: relative; added for submenu hover */
+/*position: relative; added for submenu hover */
}
UL#tabsHeader li {
@@ -298,8 +296,7 @@
background-image: url( images/tab_right_current.gif );
background-repeat: no-repeat;
background-position: right top;
- padding-top: -3px;
- /*border-bottom: 2px solid #fff;*/
+ padding-top: -3px; /*border-bottom: 2px solid #fff;*/
}
UL#tabsHeader #current a, #current a:hover {
@@ -1025,10 +1022,20 @@
padding: 0px 5px 5px 5px;
font-weight: bold;
color: #656565;
- font-size: 10px;
+ font-size: 12px;
border-bottom: 1px solid #d5d5d5;
}
+/* Table footer */
+.portlet-table-footer {
+ padding: 5px 5px 0px 5px;
+ font-weight: bold;
+ color: #656565;
+ font-size: 12px;
+ border: none;
+ border-top: 1px solid #d5d5d5;
+}
+
/* Normal text in a table cell */
.portlet-table-body {
@@ -1054,11 +1061,6 @@
font-size: 12px;
}
-/* Table footer */
-.portlet-table-footer {
- font-size: 11px;
-}
-
/* Text that belongs to the table but does not fall in one of the other categories (e.g. explanatory or help text that is associated with the table). */
.portlet-table-text {
padding: 3px 5px;
17 years, 6 months
JBoss Portal SVN: r6659 - in docs/trunk/referenceGuide/en: images/ldap and 1 other directories.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-13 19:49:21 -0400 (Tue, 13 Mar 2007)
New Revision: 6659
Added:
docs/trunk/referenceGuide/en/images/ldap/
docs/trunk/referenceGuide/en/images/ldap/tree1-1.png
docs/trunk/referenceGuide/en/images/ldap/tree1-2.png
docs/trunk/referenceGuide/en/images/ldap/tree2-1.png
docs/trunk/referenceGuide/en/images/ldap/tree2-3.png
docs/trunk/referenceGuide/en/images/ldap/tree2-4.png
Modified:
docs/trunk/referenceGuide/en/modules/ldap.xml
Log:
ldap trees screenshots
Added: docs/trunk/referenceGuide/en/images/ldap/tree1-1.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/ldap/tree1-1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: docs/trunk/referenceGuide/en/images/ldap/tree1-2.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/ldap/tree1-2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: docs/trunk/referenceGuide/en/images/ldap/tree2-1.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/ldap/tree2-1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: docs/trunk/referenceGuide/en/images/ldap/tree2-3.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/ldap/tree2-3.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: docs/trunk/referenceGuide/en/images/ldap/tree2-4.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/ldap/tree2-4.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: docs/trunk/referenceGuide/en/modules/ldap.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/ldap.xml 2007-03-13 23:29:15 UTC (rev 6658)
+++ docs/trunk/referenceGuide/en/modules/ldap.xml 2007-03-13 23:49:21 UTC (rev 6659)
@@ -537,6 +537,41 @@
<sect1>
<title>LDAP server tree shapes</title>
<para>TODO:</para>
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree1-1.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree1-2.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <!--<para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree2-1.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>-->
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree2-3.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <para>Tree:
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" valign="middle" fileref="images/ldap/tree2-4.png"/>
+ </imageobject>
+ </mediaobject>
+ </para>
</sect1>
<sect1>
<title>Supported LDAP servers</title>
17 years, 6 months
JBoss Portal SVN: r6658 - in trunk: core/src/main/org/jboss/portal/core/controller and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-13 19:29:15 -0400 (Tue, 13 Mar 2007)
New Revision: 6658
Removed:
trunk/portlet/src/main/org/jboss/portal/portlet/test/UserInterceptor.java
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/CachedUserImpl.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
trunk/server/src/main/org/jboss/portal/server/ServerInvocation.java
trunk/server/src/main/org/jboss/portal/server/ServerRequest.java
Log:
simplified user/profile access in the code base, having the logic to fetch user for request in one place.
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -23,18 +23,15 @@
package org.jboss.portal.core.aspects.server;
import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.UserProfileModule;
-import org.jboss.portal.identity.UserModule;
import org.jboss.portal.server.ServerInterceptor;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerRequest;
+import org.jboss.portal.identity.User;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
/**
* If the user is authenticated and has a preferred locale then this one is chosen. Otherwhise the locale used is the
@@ -52,25 +49,13 @@
// The locales
List locales = new ArrayList(4);
- // Try to get the locale from the user
- User user = (User)invocation.getRequest().getUser();
+ //
+ Map profile = (Map)invocation.getAttribute(ServerInvocation.PRINCIPAL_SCOPE, UserInterceptor.PROFILE_KEY);
- UserProfileModule userProfileModule = null;
-
- //TODO: identity code change
- try
+ //
+ if (profile != null)
{
- userProfileModule = (UserProfileModule)new InitialContext().lookup("java:portal/UserProfileModule");
- }
- catch (NameNotFoundException ignore)
- {
- // Name is not bound anymore, it could happen during a shutdown, we don't do anything
- }
-
- if (user != null && userProfileModule != null)
- {
- //Locale locale = user.getPreferredLocale();
- Object lc = userProfileModule.getProperty(user,User.INFO_USER_LOCALE);
+ Object lc = profile.get(User.INFO_USER_LOCALE);
Locale locale = null;
if (lc instanceof Locale)
{
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -24,6 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.core.CoreConstants;
import org.jboss.portal.core.controller.portlet.CachedUserImpl;
import org.jboss.portal.identity.NoSuchUserException;
@@ -44,6 +45,7 @@
import java.security.Principal;
import java.util.Date;
import java.util.Map;
+import java.util.HashMap;
/**
* The interceptor is responsible for managing the user identity lifecycle based on the principal name returned by the
@@ -58,6 +60,12 @@
public class UserInterceptor extends ServerInterceptor
{
+ /** . */
+ public static final String PROFILE_KEY = "profile";
+
+ /** . */
+ public static final String USER_KEY = "user";
+
/** Our logger. */
private static final Logger log = Logger.getLogger(UserInterceptor.class);
@@ -67,6 +75,7 @@
/** UserProfile */
protected UserProfileModule userProfileModule = null;
+ /** . */
protected boolean cacheUser = true;
public UserModule getUserModule()
@@ -113,19 +122,22 @@
HttpServletRequest req = invocation.getServerContext().getClientRequest();
HttpSession httpSession = req.getSession();
+ // Get scope
+ AttributeResolver principalScopeResolver = invocation.getContext().getAttributeResolver(ServerInvocation.PRINCIPAL_SCOPE);
+
// Get the id
Principal userPrincipal = req.getUserPrincipal();
- // The user for the request
+ // The user and its profile
User user = null;
+ Map profile = null;
+
// Fetch user if we can
if (userPrincipal != null)
{
String userName = userPrincipal.getName();
-
-
//
try
{
@@ -134,27 +146,31 @@
log.trace("About to fetch user=" + userName);
}
- if (isCacheUser())
+ // Try to obtain cached user
+ user = (User)principalScopeResolver.getAttribute(USER_KEY);
+
+ //
+ if (user == null)
{
- //try to obtain cached user
- user = (User)invocation.getContext().getAttributeResolver(ServerInvocation.PRINCIPAL_SCOPE).getAttribute("cachedUser");
+ // Fetch user info
+ user = getUserModule().findUserByUserName(userName);
- //create new cached one
- if (user == null)
- {
- user = getUserModule().findUserByUserName(userName);
- Map props = getUserProfileModule().getProperties(user);
- user = new CachedUserImpl(user.getId(), user.getUserName(), props);
+ // Get profile
+ profile = getUserProfileModule().getProperties(user);
- //cache user
- invocation.getContext().setAttribute(ServerInvocation.PRINCIPAL_SCOPE, "cachedUser", user);
- }
+ // Build detached pojo
+ user = new CachedUserImpl(user.getId(), user.getUserName());
+
+ // Cache
+ invocation.getContext().setAttribute(ServerInvocation.PRINCIPAL_SCOPE, USER_KEY, user);
+
+ // Get a detached object
+ profile = new HashMap(profile);
+
+ // Cache
+ invocation.getContext().setAttribute(ServerInvocation.PRINCIPAL_SCOPE, PROFILE_KEY, profile);
}
- else
- {
- // Lookup
- user = getUserModule().findUserByUserName(userName);
- }
+
//
if (trace)
{
@@ -225,16 +241,16 @@
try
{
- // Attach the request user to the invocation
- invocation.getRequest().setUser(user);
-
// Continue the invocation
invocation.invokeNext();
}
finally
{
- // Clean up the request user
- invocation.getRequest().setUser(null);
+ if (!cacheUser)
+ {
+ principalScopeResolver.setAttribute(USER_KEY, null);
+ principalScopeResolver.setAttribute(PROFILE_KEY, null);
+ }
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -30,7 +30,10 @@
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.identity.User;
+import org.jboss.portal.core.aspects.server.UserInterceptor;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -115,6 +118,11 @@
public User getUser()
{
- return (User)serverInvocation.getRequest().getUser();
+ return (User)getAttribute(ServerInvocation.PRINCIPAL_SCOPE, UserInterceptor.USER_KEY);
}
+
+ public Map getUserProfile()
+ {
+ return (Map)getAttribute(ServerInvocation.PRINCIPAL_SCOPE, UserInterceptor.PROFILE_KEY);
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/CachedUserImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/CachedUserImpl.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/CachedUserImpl.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -27,31 +27,27 @@
import java.util.Map;
/**
- * Simple POJO to cache user data
+ * Simple POJO to cache user data.
*
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
* @version $Revision: 0.1 $
*/
public class CachedUserImpl implements User
{
+
+ /** . */
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(CachedUserImpl.class);
+ /** . */
private Object id;
+ /** . */
private String name;
- private Map profile;
-
- //restrict constructor
- private CachedUserImpl()
+ public CachedUserImpl(Object id, String name)
{
- }
-
- public CachedUserImpl(Object id, String name, Map profile)
- {
this.id = id;
this.name = name;
- this.profile = profile;
}
public Object getId()
@@ -66,17 +62,11 @@
public void updatePassword(String password)
{
- log.error("Cached user. Password cannot be updated using this object. Obtain User using UserModule.");
+ throw new UnsupportedOperationException("Cached user. Password cannot be updated using this object. Obtain User using UserModule.");
}
public boolean validatePassword(String password)
{
- log.error("Cached user. Password cannot be validated using this object. Obtain User using UserModule.");
- return false;
+ throw new UnsupportedOperationException("Cached user. Password cannot be validated using this object. Obtain User using UserModule.");
}
-
- public Map getProfile()
- {
- return profile;
- }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -24,14 +24,10 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.UserProfileModule;
-import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.core.controller.ControllerContext;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -51,13 +47,16 @@
/** . */
private final User user;
+ /** . */
+ private final Map profile;
+
public ControllerUserContext(ControllerContext controllerContext)
{
this.invocation = controllerContext.getServerInvocation();
this.user = controllerContext.getUser();
+ this.profile = controllerContext.getUserProfile();
}
- /** This implementation returns the remote user value from the underlying http request. */
public String getId()
{
return user != null ? user.getUserName() : null;
@@ -65,44 +64,7 @@
public Map getInformations()
{
- User user = getUser();
-
- //check if user has been cached and obtain profile from it.
- if (user instanceof CachedUserImpl)
- {
- return ((CachedUserImpl)user).getProfile();
- }
-
- //if user was not cached - obtain profile in traditional way.
-
- UserProfileModule userProfileModule = null;
-
- //MARK: identity code change
- try
- {
- userProfileModule = (UserProfileModule)new InitialContext().lookup("java:portal/UserProfileModule");
- }
- catch (NamingException ignore)
- {
- // Name is not bound anymore, it could happen during a shutdown, we don't do anything
- }
-
- if (user != null && userProfileModule != null)
- {
- try
- {
- return userProfileModule.getProperties(user);
- }
- catch (IdentityException e)
- {
- log.error("Cannot obtain user profile information: ", e);
- return null;
- }
- }
- else
- {
- return null;
- }
+ return profile;
}
public User getUser()
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -27,6 +27,7 @@
import org.jboss.portal.server.ServerInterceptor;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.aspects.server.UserInterceptor;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -41,7 +42,7 @@
{
// setup the portal user information to be used by the CMS Business Layer
// for fine grained access control enforcement
- User user = (User)invocation.getRequest().getUser();
+ User user = (User)invocation.getAttribute(ServerInvocation.PRINCIPAL_SCOPE, UserInterceptor.USER_KEY);
JCRCMS.getUserInfo().set(user);
invocation.invokeNext();
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -82,6 +82,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -542,7 +543,7 @@
public Map getInformations()
{
- return ((UserInterceptor.User)serverInvocation.getRequest().getUser()).getInformations();
+ return new HashMap();
}
public Locale getLocale()
Deleted: trunk/portlet/src/main/org/jboss/portal/portlet/test/UserInterceptor.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/UserInterceptor.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/UserInterceptor.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -1,81 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.portlet.test;
-
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.server.ServerInterceptor;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerRequest;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The user interceptor is a simple implementation that is used to run the portlet controller.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class UserInterceptor extends ServerInterceptor
-{
-
- protected void invoke(ServerInvocation invocation) throws Exception, InvocationException
- {
- ServerRequest sreq = invocation.getRequest();
- HttpServletRequest hreq = invocation.getServerContext().getClientRequest();
- HttpSession session = hreq.getSession();
-
- //
- User ctx = (User)session.getAttribute("org.jboss.portal.server.aspects.server#UserContext");
- if (ctx == null)
- {
- ctx = new User();
- session.setAttribute("org.jboss.portal.server.aspects.server#UserContext", ctx);
- }
-
- //
- try
- {
- sreq.setUser(ctx);
- invocation.invokeNext();
- }
- finally
- {
- sreq.setUser(null);
- }
- }
-
- public static class User implements Serializable
- {
- /** . */
- private Map informations = new HashMap();
-
- public Map getInformations()
- {
- return informations;
- }
- }
-}
Modified: trunk/server/src/main/org/jboss/portal/server/ServerInvocation.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerInvocation.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/server/src/main/org/jboss/portal/server/ServerInvocation.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -45,9 +45,6 @@
/** . */
public static final Scope NAVIGATIONAL_STATE_SCOPE = new Scope("navigationalstate");
- /** . */
- public static final String IDENTITY_KEY = "identity";
-
/** The request. */
private ServerRequest req;
Modified: trunk/server/src/main/org/jboss/portal/server/ServerRequest.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerRequest.java 2007-03-13 22:28:49 UTC (rev 6657)
+++ trunk/server/src/main/org/jboss/portal/server/ServerRequest.java 2007-03-13 23:29:15 UTC (rev 6658)
@@ -31,9 +31,6 @@
public class ServerRequest
{
- /** The request user. */
- protected Object user;
-
/** The locales for the scope of the current request. */
protected Locale[] locales;
@@ -47,26 +44,6 @@
this.invocationContext = invocationContext;
}
- public Object getUser()
- {
- return user;
- }
-
- /**
- * Associate a user object with the current request. If the user is null, it is equivalent to remove it.
- * The underlying server invocation will have the user object bound into the <code>ServerInvocation.REQUEST_SCOPE</code>
- * using the <code>ServerInvocation.USER_IDENTITY_KEY</code> name.
- *
- * @param user the request user
- */
- public void setUser(Object user)
- {
- this.user = user;
-
- //
- invocationContext.setAttribute(ServerInvocation.REQUEST_SCOPE, ServerInvocation.IDENTITY_KEY, user);
- }
-
public Server getServer()
{
return server;
17 years, 6 months
JBoss Portal SVN: r6656 - in trunk: build/ide/intellij/idea60/modules/core-admin and 13 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-13 18:24:32 -0400 (Tue, 13 Mar 2007)
New Revision: 6656
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java
trunk/faces/src/main/org/jboss/portal/faces/component/
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java
Removed:
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java
Modified:
trunk/build/build.xml
trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml
trunk/build/ide/intellij/idea60/modules/faces/faces.iml
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml
trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java
trunk/faces/build.xml
Log:
moved JSF portlet component and scroller component to the faces package
Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/build/build.xml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -141,7 +141,7 @@
<group name="portal">
<include
- modules="common, test, api, faces, jems, server, security, identity, search, format, portlet, portlet-federation, theme, workflow, cms, bridge, samples, registration, wsrp, core, core-admin, core-cms, core-management, core-samples"/>
+ modules="common, test, api, jems, server, security, identity, search, format, portlet, bridge, faces, portlet-federation, theme, workflow, cms, samples, registration, wsrp, core, core-admin, core-cms, core-management, core-samples"/>
</group>
<group name="cms">
@@ -152,10 +152,6 @@
<include modules="common, test, jems, security"/>
</group>
- <group name="faces">
- <include modules="common, test, faces"/>
- </group>
-
<group name="default">
<include groups="portal"/>
</group>
Modified: trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -112,6 +112,15 @@
</orderEntry>
<orderEntry type="module" module-name="bridge" />
<orderEntry type="module" module-name="server" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-log4j/lib/log4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/build/ide/intellij/idea60/modules/faces/faces.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/faces/faces.iml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/build/ide/intellij/idea60/modules/faces/faces.iml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -74,6 +74,10 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module" module-name="api" />
+ <orderEntry type="module" module-name="portlet" />
+ <orderEntry type="module" module-name="server" />
+ <orderEntry type="module" module-name="bridge" />
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -37,7 +37,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface Instance
+public interface Instance
{
/**
* Return the id.
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -54,8 +54,9 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.admin.ui.actions.WindowComparator;
+import org.jboss.portal.core.admin.ui.portlet.PortletDefinitionInvoker;
import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
-import org.jboss.portal.core.faces.PortletActionEvent;
+import org.jboss.portal.faces.component.portlet.PortletActionEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.security.AuthorizationDomainRegistry;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -68,6 +69,7 @@
import org.jboss.portal.theme.ThemeService;
import org.jboss.portal.theme.render.PortalRenderSet;
import org.jboss.portal.theme.strategy.LayoutStrategy;
+import org.jboss.portal.portlet.PortletInvoker;
/** The portal object manager bean. */
public class PortalObjectManagerBean implements Serializable
@@ -145,6 +147,9 @@
/** . */
private List selectedProperties;
+ /** . */
+ private PortletInvoker portletDefinitionInvoker;
+
// Wired services
public List getAvailableContentTypes()
@@ -220,6 +225,7 @@
public void setInstanceContainer(InstanceContainer instanceContainer)
{
this.instanceContainer = instanceContainer;
+ this.portletDefinitionInvoker = new PortletDefinitionInvoker(instanceContainer);
}
public LayoutService getLayoutService()
@@ -304,6 +310,11 @@
// Runtime state
+ public PortletInvoker getPortletDefinitionInvoker()
+ {
+ return portletDefinitionInvoker;
+ }
+
public AbstractAuthorizationBean getAuth()
{
return auth;
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,174 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.core.admin.ui.portlet;
+
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import java.util.Set;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * Adapt the instance container as a portlet invoker. Will be removed later when
+ * migrating the instance container to the portlet package will be done in a
+ * suitable form.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletDefinitionInvoker implements PortletInvoker
+{
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ public PortletDefinitionInvoker(InstanceContainer instanceContainer)
+ {
+ if (instanceContainer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.instanceContainer = instanceContainer;
+ }
+
+ public Set getPortlets() throws PortletInvokerException
+ {
+ Collection defs = instanceContainer.getDefinitions();
+ Set portlets = new HashSet(defs.size());
+ for (Iterator i = defs.iterator();i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ portlets.add(new PortletDefinition(instance));
+ }
+ return portlets;
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
+ {
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String instanceId = portletContext.getId();
+ Instance instance = instanceContainer.getDefinition(instanceId);
+ if (instance == null)
+ {
+ throw new NoSuchPortletException(instanceId);
+ }
+ return new PortletDefinition(instance);
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
+ {
+ if (invocation == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ PortletContext portletContext = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ if (portletContext == null)
+ {
+ throw new InvocationException("No portlet context provided");
+ }
+ String instanceId = portletContext.getId();
+ Instance instance = instanceContainer.getDefinition(instanceId);
+ if (instance == null)
+ {
+ throw new NoSuchPortletException(instanceId);
+ }
+ return instance.invoke(invocation);
+ }
+
+ public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List destroyClones(List portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final class PortletDefinition implements Portlet
+ {
+
+ /** . */
+ private final PortletContext ctx;
+
+ /** . */
+ private final PortletInfo info;
+
+ /** . */
+ private final boolean remote;
+
+ public PortletDefinition(Instance instance) throws PortletInvokerException
+ {
+ this.ctx = PortletContext.createPortletContext(instance.getId());
+ this.info = instance.getPortlet().getInfo();
+ this.remote = instance.getPortlet().isRemote();
+ }
+
+ public PortletContext getContext()
+ {
+ return ctx;
+ }
+
+ public PortletInfo getInfo()
+ {
+ return info;
+ }
+
+ public boolean isRemote()
+ {
+ return remote;
+ }
+ }
+}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.EmptyAttributeResolver;
-import org.jboss.portal.server.util.HTTPStreamInfo;
-import org.jboss.portal.server.impl.RequestAttributeResolver;
-import org.jboss.portal.server.impl.PrincipalAttributeResolver;
-import org.jboss.portal.server.impl.MapAttributeResolver;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFActionContext extends AbstractActionContext
-{
-
- /** . */
- private final JSFInvocation invocation;
-
- public JSFActionContext(
- Mode mode, WindowState
- windowState,
- StateString interactionState,
- HTTPStreamInfo streamInfo,
- JSFInvocation invocation)
- {
- super(mode, windowState, null, streamInfo, interactionState, null);
-
- //
- this.invocation = invocation;
-
- //
- addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(invocation.clientRequest));
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(invocation.clientRequest));
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
- addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
- }
-
- public HttpServletRequest getClientRequest() throws IllegalStateException
- {
- return invocation.clientRequest;
- }
-
- public HttpServletResponse getClientResponse() throws IllegalStateException
- {
- return invocation.clientResponse;
- }
-
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- return invocation.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,195 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.spi.PortalContext;
-import org.jboss.portal.portlet.spi.RequestContext;
-import org.jboss.portal.portlet.spi.SecurityContext;
-import org.jboss.portal.portlet.spi.UserContext;
-import org.jboss.portal.portlet.spi.WindowContext;
-import org.jboss.portal.portlet.spi.RenderContext;
-import org.jboss.portal.portlet.spi.ActionContext;
-import org.jboss.portal.portlet.impl.PortletRequestEncoder;
-import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
-import org.jboss.portal.common.text.FastURLEncoder;
-import org.jboss.portal.common.MediaType;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.bridge.JBossServletContextProvider;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.server.util.HTTPStreamInfo;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.faces.context.FacesContext;
-import javax.faces.application.ViewHandler;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFInvocation
-{
-
- /** . */
- final HttpServletRequest clientRequest;
-
- /** . */
- final HttpServletResponse clientResponse;
-
- /** . */
- final FacesContext faces;
-
- /** . */
- final UIPortlet uiportlet;
-
- /** . */
- final PortalContext portalContext;
-
- /** . */
- final RequestContext requestContext;
-
- /** . */
- final SecurityContext securityContext;
-
- /** . */
- final UserContext userContext;
-
- /** . */
- final WindowContext windowContext;
-
- public JSFInvocation(FacesContext faces, UIPortlet uiportlet)
- {
- // Get request and response
- JBossServletContextProvider.BridgeInfo info = JBossServletContextProvider.get();
- PortletInvocation portletInvocation = info.getInvocation();
- this.clientRequest = portletInvocation.getDispatchedRequest();
- this.clientResponse = portletInvocation.getDispatchedResponse();
- this.faces = faces;
- this.uiportlet = uiportlet;
-
- //
- this.portalContext = new JSFPortalContext(faces, uiportlet);
- this.requestContext = new AbstractRequestContext(clientRequest, clientResponse);
- this.securityContext = new JSFSecurityContext(faces);
- this.userContext = new JSFUserContext(faces);
- this.windowContext = new JSFWindowContext(faces);
- }
-
- String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- ViewHandler vh = faces.getApplication().getViewHandler();
- String viewId = faces.getViewRoot().getViewId();
- String clientId = uiportlet.getClientId(faces);
- StringBuffer url = new StringBuffer(vh.getActionURL(faces, viewId));
-
- //
- url.append("&").append(clientId).append("=jbp");
-
- //
- PortletRequestEncoder encoder = new PortletRequestEncoder();
- encoder.encode(portletURL);
- for (Iterator i = encoder.getQueryParameters().entrySet().iterator();i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String name = FastURLEncoder.DEFAULT_ENCODER.encode((String)entry.getKey());
- String[] values = (String[])entry.getValue();
- for (int j = 0;j < values.length;j++)
- {
- String value = values[j];
- url.append("&").append(name).append('=');
- FastURLEncoder.DEFAULT_ENCODER.encode(value, url);
- }
- }
-
- //
- return url.toString();
- }
-
- public PortletInvocationResponse action(
- Instance instance,
- Mode mode,
- WindowState windowState,
- StateString interactionState) throws PortletInvokerException
- {
- //
- ActionContext actionContext = new JSFActionContext(
- mode,
- windowState,
- interactionState,
- new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
- this);
-
- //
- PortletInvocation action = new ActionInvocation(actionContext);
-
- //
- return invoke(instance, action);
- }
-
- public PortletInvocationResponse render(
- Instance instance,
- Mode mode,
- WindowState windowState,
- PortletParameters navState) throws PortletInvokerException
- {
- //
- RenderContext renderContext = new JSFRenderContext(
- mode,
- windowState,
- navState,
- new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
- this);
-
- //
- PortletInvocation render = new RenderInvocation(renderContext);
-
- //
- return invoke(instance, render);
- }
-
- private PortletInvocationResponse invoke(
- Instance instance,
- PortletInvocation invocation) throws PortletInvokerException
- {
- //
- invocation.setPortalContext(portalContext);
- invocation.setSecurityContext(securityContext);
- invocation.setUserContext(userContext);
- invocation.setRequestContext(requestContext);
- invocation.setWindowContext(windowContext);
-
- //
- return instance.invoke(invocation);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,118 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.portlet.spi.PortalContext;
-
-import javax.faces.context.FacesContext;
-import java.util.Set;
-import java.util.Map;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFPortalContext implements PortalContext
-{
-
- /** . */
- private static final Set defaultModes = Collections.unmodifiableSet(Tools.toSet(new Mode[]{Mode.VIEW,Mode.EDIT,Mode.HELP}));
-
- /** . */
- private static final Set defaultWindowStates = Collections.unmodifiableSet(Tools.toSet(new WindowState[]{WindowState.NORMAL,WindowState.MINIMIZED,WindowState.MAXIMIZED}));
-
- /** . */
- private final FacesContext faces;
-
- /** . */
- private final UIPortlet portlet;
-
- /** . */
- private Set modes;
-
- /** . */
- private Set windowStates;
-
- public JSFPortalContext(FacesContext faces, UIPortlet portlet)
- {
- this.faces = faces;
- this.portlet = portlet;
- }
-
- public Set getWindowStates()
- {
- if (windowStates == null)
- {
- Set tmp = portlet.getSupportedWindowStates();
- if (tmp != null)
- {
- windowStates = new HashSet(tmp.size());
- for (Iterator i = tmp.iterator();i.hasNext();)
- {
- String windowStateName = (String)i.next();
- WindowState windowState = WindowState.create(windowStateName);
- windowStates.add(windowState);
- }
- }
- else
- {
- windowStates = defaultWindowStates;
- }
- }
- return windowStates;
- }
-
- public Set getModes()
- {
- if (modes == null)
- {
- Set tmp = portlet.getSupportedModes();
- if (tmp != null)
- {
- modes = new HashSet(tmp.size());
- for (Iterator i = tmp.iterator();i.hasNext();)
- {
- String modeName = (String)i.next();
- Mode windowState = Mode.create(modeName);
- modes.add(windowState);
- }
- }
- else
- {
- modes = defaultModes;
- }
- }
- return modes;
- }
-
- public Map getProperties()
- {
- return Collections.EMPTY_MAP;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,85 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.EmptyAttributeResolver;
-import org.jboss.portal.server.util.HTTPStreamInfo;
-import org.jboss.portal.server.impl.MapAttributeResolver;
-import org.jboss.portal.server.impl.PrincipalAttributeResolver;
-import org.jboss.portal.server.impl.RequestAttributeResolver;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFRenderContext extends AbstractRenderContext
-{
-
- /** . */
- private final JSFInvocation invocation;
-
- public JSFRenderContext(
- Mode mode, WindowState
- windowState,
- PortletParameters navState,
- HTTPStreamInfo streamInfo,
- JSFInvocation invocation)
- {
- super(mode, windowState, navState != null ? new PortletParametersStateString(navState) : null, streamInfo);
-
- //
- this.invocation = invocation;
-
- //
- addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(invocation.clientRequest));
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(invocation.clientRequest));
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
- addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
- }
-
- public HttpServletRequest getClientRequest() throws IllegalStateException
- {
- return invocation.clientRequest;
- }
-
- public HttpServletResponse getClientResponse() throws IllegalStateException
- {
- return invocation.clientResponse;
- }
-
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- return invocation.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,74 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.portlet.spi.SecurityContext;
-
-import javax.faces.context.FacesContext;
-import java.security.Principal;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFSecurityContext implements SecurityContext
-{
-
- /** . */
- private final FacesContext faces;
-
- public JSFSecurityContext(FacesContext faces)
- {
- this.faces = faces;
- }
-
- public boolean isSecure()
- {
- return false;
- }
-
- public boolean isAuthenticated()
- {
- return faces.getExternalContext().getRemoteUser() != null;
- }
-
- public String getAuthType()
- {
- return faces.getExternalContext().getAuthType();
- }
-
- public String getRemoteUser()
- {
- return faces.getExternalContext().getRemoteUser();
- }
-
- public Principal getUserPrincipal()
- {
- return faces.getExternalContext().getUserPrincipal();
- }
-
- public boolean isUserInRole(String roleName)
- {
- return faces.getExternalContext().isUserInRole(roleName);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,67 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.portlet.spi.UserContext;
-import org.jboss.portal.common.util.Tools;
-
-import javax.faces.context.FacesContext;
-import java.util.Map;
-import java.util.Locale;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFUserContext implements UserContext
-{
-
- /** . */
- private final FacesContext faces;
-
- public JSFUserContext(FacesContext faces)
- {
- this.faces = faces;
- }
-
- public String getId()
- {
- return null;
- }
-
- public Map getInformations()
- {
- return null;
- }
-
- public Locale getLocale()
- {
- return faces.getExternalContext().getRequestLocale();
- }
-
- public List getLocales()
- {
- return Tools.toList(faces.getExternalContext().getRequestLocales());
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.portlet.spi.WindowContext;
-import org.jboss.portal.common.util.UUIDGenerator;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFWindowContext implements WindowContext
-{
-
- /** . */
- private static final UUIDGenerator generator = new UUIDGenerator();
-
- /** . */
- private final FacesContext faces;
-
- /** . */
- private String id;
-
- public JSFWindowContext(FacesContext faces)
- {
- this.faces = faces;
- this.id = generator.generateKey();
- }
-
- public String getId()
- {
- return id;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,149 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletActionEvent extends PortletEvent
-{
-
- /** . */
- private final PortletParameters interactionState;
-
- /** . */
- private Mode mode;
-
- /** . */
- private WindowState windowState;
-
- PortletActionEvent(UIComponent uiComponent, PortletParameters interactionState, Mode mode, WindowState windowState)
- {
- super(uiComponent);
-
- //
- if (mode == null)
- {
- throw new IllegalArgumentException();
- }
- if (windowState == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.interactionState = interactionState;
- this.mode = mode;
- this.windowState = windowState;
- }
-
- public Map getParameterMap()
- {
- return interactionState;
- }
-
- public String getMode()
- {
- return mode.toString();
- }
-
- public void setMode(String mode)
- {
- if (mode == null)
- {
- throw new IllegalArgumentException("No mode provided");
- }
- this.mode = Mode.create(mode);
- }
-
- public String getWindowState()
- {
- return windowState.toString();
- }
-
- public void setWindowState(String windowState)
- {
- if (mode == null)
- {
- throw new IllegalArgumentException("No window state provided");
- }
- this.windowState = WindowState.create(windowState);
- }
-
- void execute(FacesContext faces)
- {
- UIPortlet uiportlet = (UIPortlet)getComponent();
-
- // Get instance
- String instanceId = uiportlet.getInstanceId();
- InstanceContainer instanceContainer = (InstanceContainer)faces.getApplication().getVariableResolver().resolveVariable(faces, "InstanceContainer");
- Instance instance = instanceContainer.getDefinition(instanceId);
-
- //
- JSFInvocation invocation = new JSFInvocation(faces, uiportlet);
-
- //
- try
- {
- PortletInvocationResponse pir = invocation.action(instance, mode, windowState, new PortletParametersStateString(interactionState));
- if (pir instanceof RenderResponse)
- {
- RenderResponse render = (RenderResponse)pir;
-
- //
- uiportlet.setInternalNavState(((PortletParametersStateString)render.getNavigationalState()).getParameters());
-
- //
- if (render.getWindowState() != null)
- {
- uiportlet.setInternalWindowState(render.getWindowState());
- }
-
- //
- if (render.getMode() != null)
- {
- uiportlet.setInternalMode(render.getMode());
- }
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.ActionEvent;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletEvent extends ActionEvent
-{
-
- public PortletEvent(UIComponent uiComponent)
- {
- super(uiComponent);
- }
-
- public boolean isAppropriateListener(FacesListener listener)
- {
- return listener instanceof PortletListener;
- }
-
- public void processListener(FacesListener listener)
- {
- ((PortletListener)listener).processEvent(this);
- }
-
- void execute(FacesContext faces)
- {
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,106 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import com.sun.facelets.tag.jsf.ComponentHandler;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.FaceletContext;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-
-import org.jboss.portal.common.util.Tools;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletHandler extends ComponentHandler
-{
- public PortletHandler(ComponentConfig config)
- {
- super(config);
- }
-
-
- protected MetaRuleset createMetaRuleset(Class type)
- {
- MetaRuleset mr = super.createMetaRuleset(type);
-
- //
- mr.addRule(new MetaRule()
- {
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
- {
- if ("supportedModes".equals(name))
- {
- if (attribute.isLiteral())
- {
- String s = attribute.getValue();
- PropertyEditor editor = PropertyEditorManager.findEditor(String[].class);
- editor.setAsText(s);
- String[] values = (String[])editor.getValue();
- final Set set = Tools.toSet(values);
- return new Metadata()
- {
- public void applyMetadata(FaceletContext ctx, Object instance)
- {
- UIPortlet portlet = (UIPortlet)instance;
- portlet.setSupportedModes(set);
- }
- };
- }
- }
- if ("supportedWindowStates".equals(name))
- {
- if (attribute.isLiteral())
- {
- String s = attribute.getValue();
- PropertyEditor editor = PropertyEditorManager.findEditor(String[].class);
- editor.setAsText(s);
- String[] values = (String[])editor.getValue();
- final Set set = Tools.toSet(values);
- return new Metadata()
- {
- public void applyMetadata(FaceletContext ctx, Object instance)
- {
- UIPortlet portlet = (UIPortlet)instance;
- portlet.setSupportedWindowStates(set);
- }
- };
- }
- }
- return null;
- }
- });
-
- return mr;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,34 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface PortletListener extends FacesListener
-{
- void processEvent(PortletEvent event);
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,102 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletRenderEvent extends PortletEvent
-{
-
- /** . */
- private final PortletParameters navState;
-
- /** . */
- private Mode mode;
-
- /** . */
- private WindowState windowState;
-
- public PortletRenderEvent(UIComponent uiComponent, PortletParameters navState, Mode mode, WindowState windowState)
- {
- super(uiComponent);
-
- //
- this.navState = navState;
- this.mode = mode;
- this.windowState = windowState;
- }
-
- public Map getParameterMap()
- {
- return navState;
- }
-
- public String getMode()
- {
- return mode != null ? mode.toString() : null;
- }
-
- public void setMode(String mode)
- {
- this.mode = mode != null ? Mode.create(mode) : null;
- }
-
- public String getWindowState()
- {
- return windowState != null ? windowState.toString() : null;
- }
-
- public void setWindowState(String windowState)
- {
- this.windowState = windowState != null ? WindowState.create(windowState) : null;
- }
-
- void execute(FacesContext faces)
- {
- UIPortlet uiportlet = (UIPortlet)getComponent();
- uiportlet.setInternalNavState(navState);
-
- //
- if (windowState != null)
- {
-
- uiportlet.setInternalWindowState(windowState);
- }
-
- //
- if (mode != null)
- {
- uiportlet.setInternalMode(mode);
- }
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,593 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.core.faces;
-
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.portlet.impl.PortletRequestDecoder;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-import javax.faces.component.UICommand;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.ValueBinding;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.EvaluationException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.PhaseId;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @todo:
- * - add validation of initial mode and window state against the supported values
- * - add validation of mode and window state on portlet events against the supported values
- * - add handling of non expected results from render and process action
- * - add handling when instance does not exist (probably show the nested content of the tag as markup)
- *
- * @todo but less important:
- * - integrate user profile
- * - clean up the facelet portlet handler
- * - make a JSP tag
- *
- * @todo later:
- * - form rewriting so it can work in a JSF form
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UIPortlet extends UICommand
-{
-
- /** The portlet instance id. */
- private String instanceId;
-
- /** The event listener if not null. */
- private MethodBinding portletListener;
-
- /** The supported window states. */
- private Set supportedWindowStates;
-
- /** The supported modes. */
- private Set supportedModes;
-
- /** The initial window state value if not null, otherwise NORMAL is used. */
- private String initialWindowState;
-
- /** The initial mode value if not null, otherwise VIEW is used. */
- private String initialMode;
-
- /** . */
- private String onClick;
-
- /** The internal nav state. */
- private PortletParameters internalNavState;
-
- /** The internal window state value. */
- private WindowState internalWindowState;
-
- /** The internal mode value. */
- private Mode internalMode;
-
- public String getInstanceId()
- {
- if (instanceId != null)
- {
- return instanceId;
- }
-
- //
- ValueBinding vb = getValueBinding("instanceId");
- if (vb != null)
- {
- return (String)vb.getValue(getFacesContext());
- }
-
- //
- return null;
- }
-
- public void setInstanceId(String instanceId)
- {
- this.instanceId = instanceId;
- }
-
- public Set getSupportedModes()
- {
- if (supportedModes != null)
- {
- return supportedModes;
- }
-
- //
- ValueBinding vb = getValueBinding("supportedModes");
- if (vb != null)
- {
- return (Set)vb.getValue(getFacesContext());
- }
-
- //
- return null;
- }
-
- public void setSupportedModes(Set supportedModes)
- {
- this.supportedModes = supportedModes;
- }
-
- public Set getSupportedWindowStates()
- {
- if (supportedWindowStates != null)
- {
- return supportedWindowStates;
- }
-
- //
- ValueBinding vb = getValueBinding("supportedWindowStates");
- if (vb != null)
- {
- return (Set)vb.getValue(getFacesContext());
- }
-
- //
- return null;
- }
-
- public void setSupportedWindowStates(Set supportedWindowStates)
- {
- this.supportedWindowStates = supportedWindowStates;
- }
-
- public String getInitialWindowState()
- {
- if (initialWindowState != null)
- {
- return initialWindowState;
- }
-
- //
- ValueBinding vb = getValueBinding("initialWindowState");
- if (vb != null)
- {
- return (String)vb.getValue(getFacesContext());
- }
-
- //
- return null;
- }
-
- public void setInitialWindowState(String initialWindowState)
- {
- this.initialWindowState = initialWindowState;
- }
-
- public String getInitialMode()
- {
- if (initialMode != null)
- {
- return initialMode;
- }
-
- //
- ValueBinding vb = getValueBinding("initialMode");
- if (vb != null)
- {
- return (String)vb.getValue(getFacesContext());
- }
-
- //
- return null;
- }
-
- public void setInitialMode(String initialMode)
- {
- this.initialMode = initialMode;
- }
-
- public String getOnClick()
- {
- return onClick;
- }
-
- public void setOnClick(String onClick)
- {
- this.onClick = onClick;
- }
-
- WindowState getInternalWindowState()
- {
- if (internalWindowState == null)
- {
- if (initialWindowState != null)
- {
- return WindowState.create(initialWindowState);
- }
- else
- {
- return WindowState.NORMAL;
- }
- }
- else
- {
- return internalWindowState;
- }
- }
-
- void setInternalWindowState(WindowState windowState)
- {
- this.internalWindowState = windowState;
- }
-
- Mode getInternalMode()
- {
- if (internalMode == null)
- {
- if (initialMode != null)
- {
- return Mode.create(initialMode);
- }
- else
- {
- return Mode.VIEW;
- }
- }
- else
- {
- return internalMode;
- }
- }
-
- void setInternalMode(Mode mode)
- {
- this.internalMode = mode;
- }
-
- void setInternalNavState(PortletParameters navState)
- {
- ValueBinding vb = getValueBinding("renderParameters");
- if (vb != null)
- {
- Map renderParameters = (Map)vb.getValue(getFacesContext());
- renderParameters.clear();
- renderParameters.putAll(navState);
- }
- else
- {
- this.internalNavState = navState;
- }
- }
-
- PortletParameters getInternalNavState()
- {
- ValueBinding vb = getValueBinding("renderParameters");
- if (vb != null)
- {
- Map renderParameters = (Map)vb.getValue(getFacesContext());
- return PortletParameters.wrap(renderParameters);
- }
- else
- {
- return internalNavState;
- }
- }
-
- public String getFamily()
- {
- return "org.jboss.portal.core.Portlet";
- }
-
- public void broadcast(FacesEvent event) throws AbortProcessingException
- {
- if (event instanceof PortletEvent)
- {
- FacesContext faces = getFacesContext();
-
- //
- MethodBinding listener = getActionListener();
- if (listener != null)
- {
- try
- {
- listener.invoke(faces, new Object[] {event});
- }
- catch (EvaluationException e)
- {
- Throwable cause = e.getCause();
- if (cause != null && cause instanceof AbortProcessingException)
- {
- throw (AbortProcessingException)cause;
- }
- else
- {
- throw e;
- }
- }
- }
-
- //
- PortletEvent pevent = (PortletEvent)event;
- pevent.execute(faces);
- }
- else
- {
- super.broadcast(event);
- }
- }
-
- public Object saveState(FacesContext faces)
- {
- String opaqueValue = null;
- if (internalNavState != null)
- {
- opaqueValue = new PortletParametersStateString(internalNavState).getStringValue();
- }
-
- //
- Object values[] = new Object[11];
- values[0] = super.saveState(faces);
- values[1] = instanceId;
- values[2] = opaqueValue;
- values[3] = saveAttachedState(faces, portletListener);
- values[4] = supportedWindowStates;
- values[5] = supportedModes;
- values[6] = initialWindowState;
- values[7] = initialMode;
- values[8] = internalNavState;
- values[9] = internalMode;
- values[10] = onClick;
- return values;
- }
-
- public void restoreState(FacesContext faces, Object state)
- {
- Object values[] = (Object[])state;
- super.restoreState(faces, values[0]);
- String serializedNavState = (String)values[2];
-
- //
- instanceId = (String)values[1];
- internalNavState = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
- portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
- supportedWindowStates = (Set)values[4];
- supportedModes = (Set)values[5];
- initialWindowState = (String)values[6];
- initialMode = (String)values[7];
- internalNavState = (PortletParameters)values[8];
- internalMode = (Mode)values[9];
- onClick = (String)values[10];
- }
-
- public void decode(FacesContext faces)
- {
- String clientId = getClientId(faces);
- String clientIdValue = (String)faces.getExternalContext().getRequestParameterMap().get(clientId);
-
- // We have been targetted
- if ("jbp".equals(clientIdValue))
- {
- Map jsfParams = faces.getExternalContext().getRequestParameterValuesMap();
- Map portletParams = new HashMap();
- for (Iterator i = jsfParams.entrySet().iterator();i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String name = (String)entry.getKey();
- if (clientId.equals(name))
- {
- // Skip the client id
- }
- else
- {
- String[] values = (String[])((String[])entry.getValue()).clone();
- portletParams.put(name, values);
- }
- }
-
- // Decode the request
- PortletRequestDecoder decoder = new PortletRequestDecoder();
- decoder.decode(portletParams, null);
- Mode mode = decoder.getMode();
- WindowState windowState = decoder.getWindowState();
-
- //
- switch (decoder.getType())
- {
- case PortletRequestDecoder.RENDER_TYPE:
- PortletRenderEvent prevent = new PortletRenderEvent(
- this,
- ((PortletParametersStateString)decoder.getNavigationalState()).getParameters(),
- mode,
- windowState);
- prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
- queueEvent(prevent);
- break;
- case PortletRequestDecoder.ACTION_TYPE:
- if (mode == null)
- {
- mode = getInternalMode();
- }
- if (windowState == null)
- {
- windowState = getInternalWindowState();
- }
- PortletActionEvent paevent = new PortletActionEvent(
- this,
- ((PortletParametersStateString)decoder.getInteractionState()).getParameters(),
- mode,
- windowState);
- paevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
- queueEvent(paevent);
- break;
- }
- }
- }
-
- public void encodeBegin(FacesContext faces) throws IOException
- {
- Instance instance = null;
-
-
- // Resolve instance id
- String instanceId = getInstanceId();
-
- // Get instance
- if (instanceId != null)
- {
- InstanceContainer instanceContainer = (InstanceContainer)faces.getApplication().getVariableResolver().resolveVariable(faces, "InstanceContainer");
- instance = instanceContainer.getDefinition(instanceId);
- }
-
- //
- if (instance != null)
- {
- //
- JSFInvocation invocation = new JSFInvocation(faces, this);
-
- //
- try
- {
- PortletInvocationResponse pir = invocation.render(
- instance,
- getInternalMode(),
- getInternalWindowState(),
- getInternalNavState());
-
- //
- if (pir instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)pir;
- ResponseWriter writer = faces.getResponseWriter();
- writer.startElement("div", this);
- writer.writeAttribute("id", "bilto", null);
- writer.write(fragment.getContent());
- writer.endElement("div");
-
- //
- if (onClick != null)
- {
- writer.startElement("script", this);
- writer.write(
-
- "var isIE = /msie/i.test(navigator.userAgent);\n" +
-
- "function attachEvent(elm, eventName, eventHandler) {\n" +
- " if (isIE) {\n" +
- " elm.attachEvent(\"on\" + eventName, eventHandler);\n" +
- " } else {\n" +
- " elm.addEventListener(eventName, eventHandler, false);\n" +
- " }\n" +
- "}\n" +
-
- "function getEventTarget(event) {\n" +
- " var targetElement = isIE ? event.srcElement : event.target;\n" +
- " while (targetElement.nodeType == 3 && targetElement.parentNode != null) {\n" +
- " targetElement = targetElement.parentNode;\n" +
- " }\n" +
- " return targetElement;\n" +
- "}\n" +
-
- "\n" +
-
- "function PortletURL(url) {\n" +
- " this.params = new Array();\n" +
- " this.url = url;\n" +
- " this.setParameter = function(name, value) {;\n" +
- " this.params[name] = value;\n" +
- " return this;\n" +
- " }\n" +
- " this.toString = function() {;\n" +
- " var tmp = this.url;\n" +
- " for (var i in this.params) {\n" +
- " tmp = tmp + ('&' + i + '=' + this.params[i]);\n" +
- " };\n" +
- " return tmp;\n" +
- " }\n" +
- "}\n" +
-
- "function fx(event) {\n" +
- " var target = getEventTarget(event);\n" +
- " if (target.nodeName == 'INPUT' && target.type == 'submit') {\n" +
- " var current = target.parentNode;\n" +
- " while (current.nodeName != 'FORM' && current.nodeName != 'BODY') {\n" +
- " current = current.parentNode;\n" +
- " }\n" +
- " if (current.nodeName == 'FORM') {\n" +
- " var action = current.action;\n" +
- " var portletURL = new PortletURL(action);\n" +
- " (function(url){" + onClick + "})(portletURL);\n" +
- " current.action = portletURL.toString();\n" +
- " } else {\n" +
- " // Really can't do nothing for now\n" +
- " }\n" +
- " }\n" +
- " else if (target.nodeName == 'A') {\n" +
- " var href = target.href;\n" +
- " var portletURL = new PortletURL(href);\n" +
- " (function(url){" + onClick + "})(portletURL);\n" +
- " target.href = portletURL.toString();\n" +
- " }\n" +
- " \n" +
- "}\n" +
-
- "var elt = document.getElementById('bilto');\n" +
- "attachEvent(elt, 'click', fx);\n"
- );
- writer.endElement("script");
- }
- writer.flush();
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- System.out.println("Instance not found: " + instanceId);
- }
- }
-
- public void encodeChildren(FacesContext facesContext) throws IOException
- {
- }
-
- public void encodeEnd(FacesContext facesContext) throws IOException
- {
- }
-
- public String getRendererType()
- {
- // Returns null as we handle rendering ourselves
- return null;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,237 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.faces.scroller;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.ValueBinding;
-import javax.faces.render.Renderer;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ScrollerRenderer extends Renderer
-{
-
- private final String PREVIOUS = "Previous";
- private final String NEXT = "Next";
- private final String FIRST = "First";
- private final String LAST = "Last";
-
-
- public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
- {
- // Get Attributes
- String styleClass = (String) getAttribute(facesContext, component, "styleClass");
- String datatableId = (String) getAttribute(facesContext, component, "for");
-
- // Get Form Component
- UIComponent formComponent = component;
- while (!(formComponent instanceof UIForm))
- {
- formComponent = formComponent.getParent();
- }
- String formComponentId = formComponent.getClientId(facesContext);
-
- // Get Writer
- ResponseWriter writer = facesContext.getResponseWriter();
-
- // Get UIData
- String id = getId(datatableId, component.getClientId(facesContext));
- UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext, id);
-
- int first = data.getFirst();
- int rowCount = data.getRowCount();
- int pageSize = data.getRows();
- if (pageSize <= 0) pageSize = rowCount;
-
- int pages = rowCount / pageSize;
- if (rowCount % pageSize != 0 ) pages++;
-
- int currentPage = first / pageSize;
- if (first >= rowCount - pageSize) currentPage = pages-1;
-
- int startPage = 0;
- int endPage = pages;
-
- if (currentPage > 0)
- {
- writeLink(writer, component, formComponentId, component.getClientId(facesContext), PREVIOUS, styleClass);
- }
- if (first < rowCount - pageSize)
- {
- writeLink(writer, component, formComponentId, component.getClientId(facesContext), NEXT, styleClass);
- }
-
- writeHiddenField(writer, component, component.getClientId(facesContext));
- }
-
- public void decode(FacesContext facesContext, UIComponent component)
- {
- String id = component.getClientId(facesContext);
- Map parameters = facesContext.getExternalContext().getRequestParameterMap();
- String response = (String) parameters.get(id);
-
- String datatableId = (String) getAttribute(facesContext, component, "for");
-
- // Get UIData
- String dataId = getId(datatableId, component.getClientId(facesContext));
- UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext, dataId);
-
- int first = data.getFirst();
- int rowCount = data.getRowCount();
- int pageSize = data.getRows();
- if (pageSize <= 0) pageSize = rowCount;
-
- if (response.equals(PREVIOUS))
- {
- first -= pageSize;
- }
- else if (response.equals(NEXT))
- {
- first += pageSize;
- }
-
- if (first < 0)
- {
- first = 0;
- }
- data.setFirst(first);
- }
-
-
- private Object getAttribute(FacesContext facesContext, UIComponent component, String name)
- {
- ValueBinding vb = component.getValueBinding(name);
- if (vb != null)
- {
- return vb.getValue(facesContext);
- }
- else
- {
- return component.getAttributes().get(name);
- }
- }
-
- public String getId(String id, String base)
- {
- String separator = "" + NamingContainer.SEPARATOR_CHAR;
- String[] idSplitted = id.split(separator);
- String[] baseSplitted = base.split(separator);
- StringBuffer buffer = new StringBuffer();
- for (int i=0; i<(baseSplitted.length - idSplitted.length); i++)
- {
- buffer.append(baseSplitted[i]);
- buffer.append(separator);
- }
- buffer.append(id);
- return buffer.toString();
- }
-
- private UIComponent findComponent(UIComponent component, FacesContext facesContext, String id)
- {
- String componentId = component.getClientId(facesContext);
- if (componentId.equals(id))
- {
- return component;
- }
- Iterator it = component.getChildren().iterator();
- while (it.hasNext())
- {
- UIComponent comp = (UIComponent)it.next();
- UIComponent found = findComponent(comp, facesContext, id);
- if (found != null)
- {
- return found;
- }
-
- }
- return null;
- }
-
- private void writeHiddenField(ResponseWriter writer, UIComponent component, String id) throws IOException
- {
- writer.startElement("input", component);
- writer.writeAttribute("type", "hidden", null);
- writer.writeAttribute("name", id, null);
- writer.endElement("input");
- }
-
- private void writeLink(ResponseWriter writer, UIComponent component, String formComponentId, String id, String value, String styleClass) throws IOException
- {
- writer.writeText(" ", null);
- writer.startElement("input", component);
- writer.writeAttribute("value", value, null);
- writer.writeAttribute("type", "submit", null);
- writer.writeAttribute("onclick", onclickCode(formComponentId, id, value), null);
- if (styleClass != null)
- {
- writer.writeAttribute("class", styleClass, "styleClass");
- }
- writer.endElement("input");
-
- /*
- writer.writeText(" ", null);
- writer.startElement("a", component);
- writer.writeAttribute("href", "#", null);
- writer.writeAttribute("onclick", onclickCode(formComponentId, id, value), null);
- if (styleClass != null)
- {
- writer.writeAttribute("class", styleClass, "styleClass");
- }
- writer.writeText(value, null);
- writer.endElement("a");
- */
- }
-
- private String onclickCode(String formComponentId, String id, String value)
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("document.forms[");
- buffer.append("'");
- buffer.append(formComponentId);
- buffer.append("']");
- buffer.append(".elements['");
- buffer.append(id);
- buffer.append("'].value='");
- buffer.append(value);
- buffer.append("';");
- buffer.append(" document.forms[");
- buffer.append("'");
- buffer.append(formComponentId);
- buffer.append("'");
- buffer.append("].submit()");
- buffer.append("; return false;");
- return buffer.toString();
- }
-
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,95 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.faces.scroller;
-
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.webapp.UIComponentTag;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ScrollerTag extends UIComponentTag
-{
-
- private String _for;
- private String styleClass;
-
- public String getComponentType()
- {
- return "com.jboss.portal.Scroller";
- }
-
- public String getRendererType()
- {
- return "default";
- }
-
- public void setFor(String _for)
- {
- this._for = _for;
- }
-
- public void setStyleClass(String styleClass)
- {
- this.styleClass = styleClass;
- }
-
- public void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setString(component, "for", _for);
- setString(component, "styleClass", styleClass);
- }
-
- private void setString(UIComponent component, String attributeName, String attributeValue)
- {
- if (attributeValue == null) return;
- if (isValueReference(attributeValue))
- {
- setValueBinding(component, attributeName, attributeValue);
- }
- else
- {
- component.getAttributes().put(attributeName, attributeValue);
- }
- }
-
- private void setValueBinding(UIComponent component, String attributeName, String attributeValue)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Application app = facesContext.getApplication();
- ValueBinding vb = app.createValueBinding(attributeValue);
- component.setValueBinding(attributeName, vb);
- }
-
- public void release()
- {
- super.release();
- _for = null;
- styleClass = null;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -1,37 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.faces.scroller;
-
-import javax.faces.component.UIInput;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class UIScroller extends UIInput
-{
- public UIScroller()
- {
- setRendererType("default");
- }
-}
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -297,20 +297,20 @@
</lifecycle>
<component>
- <component-type>com.jboss.portal.Scroller</component-type>
- <component-class>org.jboss.portal.faces.scroller.UIScroller</component-class>
+ <component-type>org.jboss.portal.Scroller</component-type>
+ <component-class>org.jboss.portal.faces.component.scroller.UIScroller</component-class>
</component>
<component>
- <component-type>org.jboss.portal.core.Portlet</component-type>
- <component-class>org.jboss.portal.core.faces.UIPortlet</component-class>
+ <component-type>org.jboss.portal.Portlet</component-type>
+ <component-class>org.jboss.portal.faces.component.portlet.UIPortlet</component-class>
</component>
<render-kit>
<renderer>
<component-family>javax.faces.Input</component-family>
<renderer-type>default</renderer-type>
- <renderer-class>org.jboss.portal.faces.scroller.ScrollerRenderer</renderer-class>
+ <renderer-class>org.jboss.portal.faces.component.scroller.ScrollerRenderer</renderer-class>
</renderer>
</render-kit>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld 2007-03-13 22:24:32 UTC (rev 6656)
@@ -10,7 +10,7 @@
<tag>
<name>scroller</name>
- <tag-class>org.jboss.portal.faces.scroller.ScrollerTag</tag-class>
+ <tag-class>org.jboss.portal.faces.component.scroller.ScrollerTag</tag-class>
<attribute>
<name>for</name>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -124,7 +124,8 @@
<td class="widget">
<div style="margin-top:3em;">
<jbp:portlet
- instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
+ portletId="#{portalobjectmgr.selectedContentEditorInstance}"
+ portletInvoker="#{portalobjectmgr.portletDefinitionInvoker}"
actionListener="#{portalobjectmgr.processEvent}"
supportedModes="edit_content"
supportedWindowStates="normal"
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -13,7 +13,8 @@
<div>
<jbp:portlet
actionListener="#{portalobjectmgr.processEvent}"
- instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
+ portletId="#{portalobjectmgr.selectedContentEditorInstance}"
+ portletInvoker="#{portalobjectmgr.portletDefinitionInvoker}"
renderParameters="#{portalobjectmgr.renderParameters}"
supportedModes="edit_content"
supportedWindowStates="normal"
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -5,16 +5,16 @@
<tag>
<tag-name>scroller</tag-name>
<component>
- <component-type>com.jboss.portal.Scroller</component-type>
+ <component-type>org.jboss.portal.Scroller</component-type>
<renderer-type>default</renderer-type>
</component>
</tag>
<tag>
<tag-name>portlet</tag-name>
<component>
- <component-type>org.jboss.portal.core.Portlet</component-type>
+ <component-type>org.jboss.portal.Portlet</component-type>
<renderer-type>default</renderer-type>
- <handler-class>org.jboss.portal.core.faces.PortletHandler</handler-class>
+ <handler-class>org.jboss.portal.faces.component.portlet.PortletHandler</handler-class>
</component>
</tag>
</facelet-taglib>
\ No newline at end of file
Modified: trunk/faces/build.xml
===================================================================
--- trunk/faces/build.xml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/faces/build.xml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -102,6 +102,9 @@
<path id="dependentmodule.classpath">
<path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-common.classpath"/>
+ <path refid="jboss.portal-portlet.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
+ <path refid="jboss.portal-bridge.classpath"/>
</path>
<!--+=======================================+-->
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.EmptyAttributeResolver;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.server.impl.RequestAttributeResolver;
+import org.jboss.portal.server.impl.PrincipalAttributeResolver;
+import org.jboss.portal.server.impl.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFActionContext extends AbstractActionContext
+{
+
+ /** . */
+ private final JSFInvocation invocation;
+
+ public JSFActionContext(
+ Mode mode, WindowState
+ windowState,
+ StateString interactionState,
+ HTTPStreamInfo streamInfo,
+ JSFInvocation invocation)
+ {
+ super(mode, windowState, null, streamInfo, interactionState, null);
+
+ //
+ this.invocation = invocation;
+
+ //
+ addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return invocation.clientRequest;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return invocation.clientResponse;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return invocation.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,198 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.impl.PortletRequestEncoder;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.MediaType;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.bridge.JBossServletContextProvider;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.faces.context.FacesContext;
+import javax.faces.application.ViewHandler;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFInvocation
+{
+
+ /** . */
+ final HttpServletRequest clientRequest;
+
+ /** . */
+ final HttpServletResponse clientResponse;
+
+ /** . */
+ final FacesContext faces;
+
+ /** . */
+ final UIPortlet uiportlet;
+
+ /** . */
+ final PortalContext portalContext;
+
+ /** . */
+ final RequestContext requestContext;
+
+ /** . */
+ final SecurityContext securityContext;
+
+ /** . */
+ final UserContext userContext;
+
+ /** . */
+ final WindowContext windowContext;
+
+ public JSFInvocation(FacesContext faces, UIPortlet uiportlet)
+ {
+ // Get request and response
+ JBossServletContextProvider.BridgeInfo info = JBossServletContextProvider.get();
+ PortletInvocation portletInvocation = info.getInvocation();
+ this.clientRequest = portletInvocation.getDispatchedRequest();
+ this.clientResponse = portletInvocation.getDispatchedResponse();
+ this.faces = faces;
+ this.uiportlet = uiportlet;
+
+ //
+ this.portalContext = new JSFPortalContext(faces, uiportlet);
+ this.requestContext = new AbstractRequestContext(clientRequest, clientResponse);
+ this.securityContext = new JSFSecurityContext(faces);
+ this.userContext = new JSFUserContext(faces);
+ this.windowContext = new JSFWindowContext(faces);
+ }
+
+ String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ ViewHandler vh = faces.getApplication().getViewHandler();
+ String viewId = faces.getViewRoot().getViewId();
+ String clientId = uiportlet.getClientId(faces);
+ StringBuffer url = new StringBuffer(vh.getActionURL(faces, viewId));
+
+ //
+ url.append("&").append(clientId).append("=jbp");
+
+ //
+ PortletRequestEncoder encoder = new PortletRequestEncoder();
+ encoder.encode(portletURL);
+ for (Iterator i = encoder.getQueryParameters().entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = FastURLEncoder.DEFAULT_ENCODER.encode((String)entry.getKey());
+ String[] values = (String[])entry.getValue();
+ for (int j = 0;j < values.length;j++)
+ {
+ String value = values[j];
+ url.append("&").append(name).append('=');
+ FastURLEncoder.DEFAULT_ENCODER.encode(value, url);
+ }
+ }
+
+ //
+ return url.toString();
+ }
+
+ public PortletInvocationResponse action(
+ Portlet portlet,
+ Mode mode,
+ WindowState windowState,
+ StateString interactionState) throws PortletInvokerException
+ {
+ //
+ ActionContext actionContext = new JSFActionContext(
+ mode,
+ windowState,
+ interactionState,
+ new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
+ this);
+
+ //
+ PortletInvocation action = new ActionInvocation(actionContext);
+
+ //
+ return invoke(portlet, action);
+ }
+
+ public PortletInvocationResponse render(
+ Portlet portlet,
+ Mode mode,
+ WindowState windowState,
+ PortletParameters navState) throws PortletInvokerException
+ {
+ //
+ RenderContext renderContext = new JSFRenderContext(
+ mode,
+ windowState,
+ navState,
+ new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
+ this);
+
+ //
+ PortletInvocation render = new RenderInvocation(renderContext);
+
+ //
+ return invoke(portlet, render);
+ }
+
+ private PortletInvocationResponse invoke(
+ Portlet portlet,
+ PortletInvocation invocation) throws PortletInvokerException
+ {
+ //
+ invocation.setPortalContext(portalContext);
+ invocation.setSecurityContext(securityContext);
+ invocation.setUserContext(userContext);
+ invocation.setRequestContext(requestContext);
+ invocation.setWindowContext(windowContext);
+
+ //
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+ PortletInvoker invoker = uiportlet.getPortletInvoker();
+ return invoker.invoke(invocation);
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.spi.PortalContext;
+
+import javax.faces.context.FacesContext;
+import java.util.Set;
+import java.util.Map;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFPortalContext implements PortalContext
+{
+
+ /** . */
+ private static final Set defaultModes = Collections.unmodifiableSet(Tools.toSet(new Mode[]{Mode.VIEW,Mode.EDIT,Mode.HELP}));
+
+ /** . */
+ private static final Set defaultWindowStates = Collections.unmodifiableSet(Tools.toSet(new WindowState[]{WindowState.NORMAL,WindowState.MINIMIZED,WindowState.MAXIMIZED}));
+
+ /** . */
+ private final FacesContext faces;
+
+ /** . */
+ private final UIPortlet portlet;
+
+ /** . */
+ private Set modes;
+
+ /** . */
+ private Set windowStates;
+
+ public JSFPortalContext(FacesContext faces, UIPortlet portlet)
+ {
+ this.faces = faces;
+ this.portlet = portlet;
+ }
+
+ public Set getWindowStates()
+ {
+ if (windowStates == null)
+ {
+ Set tmp = portlet.getSupportedWindowStates();
+ if (tmp != null)
+ {
+ windowStates = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator();i.hasNext();)
+ {
+ String windowStateName = (String)i.next();
+ WindowState windowState = WindowState.create(windowStateName);
+ windowStates.add(windowState);
+ }
+ }
+ else
+ {
+ windowStates = defaultWindowStates;
+ }
+ }
+ return windowStates;
+ }
+
+ public Set getModes()
+ {
+ if (modes == null)
+ {
+ Set tmp = portlet.getSupportedModes();
+ if (tmp != null)
+ {
+ modes = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator();i.hasNext();)
+ {
+ String modeName = (String)i.next();
+ Mode windowState = Mode.create(modeName);
+ modes.add(windowState);
+ }
+ }
+ else
+ {
+ modes = defaultModes;
+ }
+ }
+ return modes;
+ }
+
+ public Map getProperties()
+ {
+ return Collections.EMPTY_MAP;
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.EmptyAttributeResolver;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.server.impl.MapAttributeResolver;
+import org.jboss.portal.server.impl.PrincipalAttributeResolver;
+import org.jboss.portal.server.impl.RequestAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFRenderContext extends AbstractRenderContext
+{
+
+ /** . */
+ private final JSFInvocation invocation;
+
+ public JSFRenderContext(
+ Mode mode, WindowState
+ windowState,
+ PortletParameters navState,
+ HTTPStreamInfo streamInfo,
+ JSFInvocation invocation)
+ {
+ super(mode, windowState, navState != null ? new PortletParametersStateString(navState) : null, streamInfo);
+
+ //
+ this.invocation = invocation;
+
+ //
+ addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return invocation.clientRequest;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return invocation.clientResponse;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return invocation.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.spi.SecurityContext;
+
+import javax.faces.context.FacesContext;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFSecurityContext implements SecurityContext
+{
+
+ /** . */
+ private final FacesContext faces;
+
+ public JSFSecurityContext(FacesContext faces)
+ {
+ this.faces = faces;
+ }
+
+ public boolean isSecure()
+ {
+ return false;
+ }
+
+ public boolean isAuthenticated()
+ {
+ return faces.getExternalContext().getRemoteUser() != null;
+ }
+
+ public String getAuthType()
+ {
+ return faces.getExternalContext().getAuthType();
+ }
+
+ public String getRemoteUser()
+ {
+ return faces.getExternalContext().getRemoteUser();
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return faces.getExternalContext().getUserPrincipal();
+ }
+
+ public boolean isUserInRole(String roleName)
+ {
+ return faces.getExternalContext().isUserInRole(roleName);
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.common.util.Tools;
+
+import javax.faces.context.FacesContext;
+import java.util.Map;
+import java.util.Locale;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFUserContext implements UserContext
+{
+
+ /** . */
+ private final FacesContext faces;
+
+ public JSFUserContext(FacesContext faces)
+ {
+ this.faces = faces;
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public Map getInformations()
+ {
+ return null;
+ }
+
+ public Locale getLocale()
+ {
+ return faces.getExternalContext().getRequestLocale();
+ }
+
+ public List getLocales()
+ {
+ return Tools.toList(faces.getExternalContext().getRequestLocales());
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.common.util.UUIDGenerator;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFWindowContext implements WindowContext
+{
+
+ /** . */
+ private static final UUIDGenerator generator = new UUIDGenerator();
+
+ /** . */
+ private final FacesContext faces;
+
+ /** . */
+ private String id;
+
+ public JSFWindowContext(FacesContext faces)
+ {
+ this.faces = faces;
+ this.id = generator.generateKey();
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,146 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletActionEvent extends PortletEvent
+{
+
+ /** . */
+ private final PortletParameters interactionState;
+
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ PortletActionEvent(UIComponent uiComponent, PortletParameters interactionState, Mode mode, WindowState windowState)
+ {
+ super(uiComponent);
+
+ //
+ if (mode == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (windowState == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.interactionState = interactionState;
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+
+ public Map getParameterMap()
+ {
+ return interactionState;
+ }
+
+ public String getMode()
+ {
+ return mode.toString();
+ }
+
+ public void setMode(String mode)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("No mode provided");
+ }
+ this.mode = Mode.create(mode);
+ }
+
+ public String getWindowState()
+ {
+ return windowState.toString();
+ }
+
+ public void setWindowState(String windowState)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("No window state provided");
+ }
+ this.windowState = WindowState.create(windowState);
+ }
+
+ void execute(FacesContext faces)
+ {
+ UIPortlet uiportlet = (UIPortlet)getComponent();
+
+ // Get portlet
+ Portlet portlet = uiportlet.getPortlet();
+
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, uiportlet);
+
+ //
+ try
+ {
+ PortletInvocationResponse pir = invocation.action(portlet, mode, windowState, new PortletParametersStateString(interactionState));
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse render = (RenderResponse)pir;
+
+ //
+ uiportlet.setInternalNavState(((PortletParametersStateString)render.getNavigationalState()).getParameters());
+
+ //
+ if (render.getWindowState() != null)
+ {
+ uiportlet.setInternalWindowState(render.getWindowState());
+ }
+
+ //
+ if (render.getMode() != null)
+ {
+ uiportlet.setInternalMode(render.getMode());
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import javax.faces.event.FacesListener;
+import javax.faces.event.ActionEvent;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletEvent extends ActionEvent
+{
+
+ public PortletEvent(UIComponent uiComponent)
+ {
+ super(uiComponent);
+ }
+
+ public boolean isAppropriateListener(FacesListener listener)
+ {
+ return listener instanceof PortletListener;
+ }
+
+ public void processListener(FacesListener listener)
+ {
+ ((PortletListener)listener).processEvent(this);
+ }
+
+ void execute(FacesContext faces)
+ {
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.FaceletContext;
+
+import java.util.Set;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletHandler extends ComponentHandler
+{
+ public PortletHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ MetaRuleset mr = super.createMetaRuleset(type);
+
+ //
+ mr.addRule(new MetaRule()
+ {
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+ {
+ if ("supportedModes".equals(name))
+ {
+ if (attribute.isLiteral())
+ {
+ String s = attribute.getValue();
+ PropertyEditor editor = PropertyEditorManager.findEditor(String[].class);
+ editor.setAsText(s);
+ String[] values = (String[])editor.getValue();
+ final Set set = Tools.toSet(values);
+ return new Metadata()
+ {
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIPortlet portlet = (UIPortlet)instance;
+ portlet.setSupportedModes(set);
+ }
+ };
+ }
+ }
+ if ("supportedWindowStates".equals(name))
+ {
+ if (attribute.isLiteral())
+ {
+ String s = attribute.getValue();
+ PropertyEditor editor = PropertyEditorManager.findEditor(String[].class);
+ editor.setAsText(s);
+ String[] values = (String[])editor.getValue();
+ final Set set = Tools.toSet(values);
+ return new Metadata()
+ {
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIPortlet portlet = (UIPortlet)instance;
+ portlet.setSupportedWindowStates(set);
+ }
+ };
+ }
+ }
+ return null;
+ }
+ });
+
+ return mr;
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortletListener extends FacesListener
+{
+ void processEvent(PortletEvent event);
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletRenderEvent extends PortletEvent
+{
+
+ /** . */
+ private final PortletParameters navState;
+
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ public PortletRenderEvent(UIComponent uiComponent, PortletParameters navState, Mode mode, WindowState windowState)
+ {
+ super(uiComponent);
+
+ //
+ this.navState = navState;
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+
+ public Map getParameterMap()
+ {
+ return navState;
+ }
+
+ public String getMode()
+ {
+ return mode != null ? mode.toString() : null;
+ }
+
+ public void setMode(String mode)
+ {
+ this.mode = mode != null ? Mode.create(mode) : null;
+ }
+
+ public String getWindowState()
+ {
+ return windowState != null ? windowState.toString() : null;
+ }
+
+ public void setWindowState(String windowState)
+ {
+ this.windowState = windowState != null ? WindowState.create(windowState) : null;
+ }
+
+ void execute(FacesContext faces)
+ {
+ UIPortlet uiportlet = (UIPortlet)getComponent();
+ uiportlet.setInternalNavState(navState);
+
+ //
+ if (windowState != null)
+ {
+
+ uiportlet.setInternalWindowState(windowState);
+ }
+
+ //
+ if (mode != null)
+ {
+ uiportlet.setInternalMode(mode);
+ }
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,631 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.impl.PortletRequestDecoder;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.faces.component.UICommand;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.EvaluationException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.PhaseId;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @todo:
+ * - add validation of initial mode and window state against the supported values
+ * - add validation of mode and window state on portlet events against the supported values
+ * - add handling of non expected results from render and process action
+ * - add handling when portlet does not exist (probably show the nested content of the tag as markup)
+ *
+ * @todo but less important:
+ * - integrate user profile
+ * - clean up the facelet portlet handler
+ * - make a JSP tag
+ *
+ * @todo later:
+ * - form rewriting so it can work in a JSF form
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UIPortlet extends UICommand
+{
+
+ /** The portlet invoker. */
+ private PortletInvoker portletInvoker;
+
+ /** The portlet id. */
+ private String portletId;
+
+ /** The event listener if not null. */
+ private MethodBinding portletListener;
+
+ /** The supported window states. */
+ private Set supportedWindowStates;
+
+ /** The supported modes. */
+ private Set supportedModes;
+
+ /** The initial window state value if not null, otherwise NORMAL is used. */
+ private String initialWindowState;
+
+ /** The initial mode value if not null, otherwise VIEW is used. */
+ private String initialMode;
+
+ /** . */
+ private String onClick;
+
+ /** The internal nav state. */
+ private PortletParameters internalNavState;
+
+ /** The internal window state value. */
+ private WindowState internalWindowState;
+
+ /** The internal mode value. */
+ private Mode internalMode;
+
+ public PortletInvoker getPortletInvoker()
+ {
+ if (portletInvoker != null)
+ {
+ return portletInvoker;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("portletInvoker");
+ if (vb != null)
+ {
+ return (PortletInvoker)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public String getPortletId()
+ {
+ if (portletId != null)
+ {
+ return portletId;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("portletId");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setPortletId(String portletId)
+ {
+ this.portletId = portletId;
+ }
+
+ public Set getSupportedModes()
+ {
+ if (supportedModes != null)
+ {
+ return supportedModes;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("supportedModes");
+ if (vb != null)
+ {
+ return (Set)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setSupportedModes(Set supportedModes)
+ {
+ this.supportedModes = supportedModes;
+ }
+
+ public Set getSupportedWindowStates()
+ {
+ if (supportedWindowStates != null)
+ {
+ return supportedWindowStates;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("supportedWindowStates");
+ if (vb != null)
+ {
+ return (Set)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setSupportedWindowStates(Set supportedWindowStates)
+ {
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public String getInitialWindowState()
+ {
+ if (initialWindowState != null)
+ {
+ return initialWindowState;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("initialWindowState");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setInitialWindowState(String initialWindowState)
+ {
+ this.initialWindowState = initialWindowState;
+ }
+
+ public String getInitialMode()
+ {
+ if (initialMode != null)
+ {
+ return initialMode;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("initialMode");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setInitialMode(String initialMode)
+ {
+ this.initialMode = initialMode;
+ }
+
+ public String getOnClick()
+ {
+ return onClick;
+ }
+
+ public void setOnClick(String onClick)
+ {
+ this.onClick = onClick;
+ }
+
+ WindowState getInternalWindowState()
+ {
+ if (internalWindowState == null)
+ {
+ if (initialWindowState != null)
+ {
+ return WindowState.create(initialWindowState);
+ }
+ else
+ {
+ return WindowState.NORMAL;
+ }
+ }
+ else
+ {
+ return internalWindowState;
+ }
+ }
+
+ void setInternalWindowState(WindowState windowState)
+ {
+ this.internalWindowState = windowState;
+ }
+
+ Mode getInternalMode()
+ {
+ if (internalMode == null)
+ {
+ if (initialMode != null)
+ {
+ return Mode.create(initialMode);
+ }
+ else
+ {
+ return Mode.VIEW;
+ }
+ }
+ else
+ {
+ return internalMode;
+ }
+ }
+
+ void setInternalMode(Mode mode)
+ {
+ this.internalMode = mode;
+ }
+
+ void setInternalNavState(PortletParameters navState)
+ {
+ ValueBinding vb = getValueBinding("renderParameters");
+ if (vb != null)
+ {
+ Map renderParameters = (Map)vb.getValue(getFacesContext());
+ renderParameters.clear();
+ renderParameters.putAll(navState);
+ }
+ else
+ {
+ this.internalNavState = navState;
+ }
+ }
+
+ PortletParameters getInternalNavState()
+ {
+ ValueBinding vb = getValueBinding("renderParameters");
+ if (vb != null)
+ {
+ Map renderParameters = (Map)vb.getValue(getFacesContext());
+ return PortletParameters.wrap(renderParameters);
+ }
+ else
+ {
+ return internalNavState;
+ }
+ }
+
+ Portlet getPortlet()
+ {
+ String portletId = getPortletId();
+
+ //
+ if (portletId != null)
+ {
+ try
+ {
+ PortletInvoker portletInvoker = getPortletInvoker();
+ return portletInvoker.getPortlet(PortletContext.createPortletContext(portletId));
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ return null;
+ }
+
+ public String getFamily()
+ {
+ return "org.jboss.portal.core.Portlet";
+ }
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException
+ {
+ if (event instanceof PortletEvent)
+ {
+ FacesContext faces = getFacesContext();
+
+ //
+ MethodBinding listener = getActionListener();
+ if (listener != null)
+ {
+ try
+ {
+ listener.invoke(faces, new Object[] {event});
+ }
+ catch (EvaluationException e)
+ {
+ Throwable cause = e.getCause();
+ if (cause != null && cause instanceof AbortProcessingException)
+ {
+ throw (AbortProcessingException)cause;
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ //
+ PortletEvent pevent = (PortletEvent)event;
+ pevent.execute(faces);
+ }
+ else
+ {
+ super.broadcast(event);
+ }
+ }
+
+ public Object saveState(FacesContext faces)
+ {
+ String opaqueValue = null;
+ if (internalNavState != null)
+ {
+ opaqueValue = new PortletParametersStateString(internalNavState).getStringValue();
+ }
+
+ //
+ Object values[] = new Object[11];
+ values[0] = super.saveState(faces);
+ values[1] = portletId;
+ values[2] = opaqueValue;
+ values[3] = saveAttachedState(faces, portletListener);
+ values[4] = supportedWindowStates;
+ values[5] = supportedModes;
+ values[6] = initialWindowState;
+ values[7] = initialMode;
+ values[8] = internalNavState;
+ values[9] = internalMode;
+ values[10] = onClick;
+ return values;
+ }
+
+ public void restoreState(FacesContext faces, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(faces, values[0]);
+ String serializedNavState = (String)values[2];
+
+ //
+ portletId = (String)values[1];
+ internalNavState = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
+ portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
+ supportedWindowStates = (Set)values[4];
+ supportedModes = (Set)values[5];
+ initialWindowState = (String)values[6];
+ initialMode = (String)values[7];
+ internalNavState = (PortletParameters)values[8];
+ internalMode = (Mode)values[9];
+ onClick = (String)values[10];
+ }
+
+ public void decode(FacesContext faces)
+ {
+ String clientId = getClientId(faces);
+ String clientIdValue = (String)faces.getExternalContext().getRequestParameterMap().get(clientId);
+
+ // We have been targetted
+ if ("jbp".equals(clientIdValue))
+ {
+ Map jsfParams = faces.getExternalContext().getRequestParameterValuesMap();
+ Map portletParams = new HashMap();
+ for (Iterator i = jsfParams.entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ if (clientId.equals(name))
+ {
+ // Skip the client id
+ }
+ else
+ {
+ String[] values = (String[])((String[])entry.getValue()).clone();
+ portletParams.put(name, values);
+ }
+ }
+
+ // Decode the request
+ PortletRequestDecoder decoder = new PortletRequestDecoder();
+ decoder.decode(portletParams, null);
+ Mode mode = decoder.getMode();
+ WindowState windowState = decoder.getWindowState();
+
+ //
+ switch (decoder.getType())
+ {
+ case PortletRequestDecoder.RENDER_TYPE:
+ PortletRenderEvent prevent = new PortletRenderEvent(
+ this,
+ ((PortletParametersStateString)decoder.getNavigationalState()).getParameters(),
+ mode,
+ windowState);
+ prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ queueEvent(prevent);
+ break;
+ case PortletRequestDecoder.ACTION_TYPE:
+ if (mode == null)
+ {
+ mode = getInternalMode();
+ }
+ if (windowState == null)
+ {
+ windowState = getInternalWindowState();
+ }
+ PortletActionEvent paevent = new PortletActionEvent(
+ this,
+ ((PortletParametersStateString)decoder.getInteractionState()).getParameters(),
+ mode,
+ windowState);
+ paevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ queueEvent(paevent);
+ break;
+ }
+ }
+ }
+
+ public void encodeBegin(FacesContext faces) throws IOException
+ {
+ Portlet portlet = getPortlet();
+
+ //
+ if (portlet != null)
+ {
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, this);
+
+ //
+ try
+ {
+ PortletInvocationResponse pir = invocation.render(
+ portlet,
+ getInternalMode(),
+ getInternalWindowState(),
+ getInternalNavState());
+
+ //
+ if (pir instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)pir;
+ ResponseWriter writer = faces.getResponseWriter();
+ writer.startElement("div", this);
+ writer.writeAttribute("id", "bilto", null);
+ writer.write(fragment.getContent());
+ writer.endElement("div");
+
+ //
+ if (onClick != null)
+ {
+ writer.startElement("script", this);
+ writer.write(
+
+ "var isIE = /msie/i.test(navigator.userAgent);\n" +
+
+ "function attachEvent(elm, eventName, eventHandler) {\n" +
+ " if (isIE) {\n" +
+ " elm.attachEvent(\"on\" + eventName, eventHandler);\n" +
+ " } else {\n" +
+ " elm.addEventListener(eventName, eventHandler, false);\n" +
+ " }\n" +
+ "}\n" +
+
+ "function getEventTarget(event) {\n" +
+ " var targetElement = isIE ? event.srcElement : event.target;\n" +
+ " while (targetElement.nodeType == 3 && targetElement.parentNode != null) {\n" +
+ " targetElement = targetElement.parentNode;\n" +
+ " }\n" +
+ " return targetElement;\n" +
+ "}\n" +
+
+ "\n" +
+
+ "function PortletURL(url) {\n" +
+ " this.params = new Array();\n" +
+ " this.url = url;\n" +
+ " this.setParameter = function(name, value) {;\n" +
+ " this.params[name] = value;\n" +
+ " return this;\n" +
+ " }\n" +
+ " this.toString = function() {;\n" +
+ " var tmp = this.url;\n" +
+ " for (var i in this.params) {\n" +
+ " tmp = tmp + ('&' + i + '=' + this.params[i]);\n" +
+ " };\n" +
+ " return tmp;\n" +
+ " }\n" +
+ "}\n" +
+
+ "function fx(event) {\n" +
+ " var target = getEventTarget(event);\n" +
+ " if (target.nodeName == 'INPUT' && target.type == 'submit') {\n" +
+ " var current = target.parentNode;\n" +
+ " while (current.nodeName != 'FORM' && current.nodeName != 'BODY') {\n" +
+ " current = current.parentNode;\n" +
+ " }\n" +
+ " if (current.nodeName == 'FORM') {\n" +
+ " var action = current.action;\n" +
+ " var portletURL = new PortletURL(action);\n" +
+ " (function(url){" + onClick + "})(portletURL);\n" +
+ " current.action = portletURL.toString();\n" +
+ " } else {\n" +
+ " // Really can't do nothing for now\n" +
+ " }\n" +
+ " }\n" +
+ " else if (target.nodeName == 'A') {\n" +
+ " var href = target.href;\n" +
+ " var portletURL = new PortletURL(href);\n" +
+ " (function(url){" + onClick + "})(portletURL);\n" +
+ " target.href = portletURL.toString();\n" +
+ " }\n" +
+ " \n" +
+ "}\n" +
+
+ "var elt = document.getElementById('bilto');\n" +
+ "attachEvent(elt, 'click', fx);\n"
+ );
+ writer.endElement("script");
+ }
+ writer.flush();
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ System.out.println("Portlet not found: " + portletId);
+ }
+ }
+
+ public void encodeChildren(FacesContext facesContext) throws IOException
+ {
+ }
+
+ public void encodeEnd(FacesContext facesContext) throws IOException
+ {
+ }
+
+ public String getRendererType()
+ {
+ // Returns null as we handle rendering ourselves
+ return null;
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,237 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.scroller;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
+import javax.faces.render.Renderer;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ScrollerRenderer extends Renderer
+{
+
+ private final String PREVIOUS = "Previous";
+ private final String NEXT = "Next";
+ private final String FIRST = "First";
+ private final String LAST = "Last";
+
+
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
+ {
+ // Get Attributes
+ String styleClass = (String) getAttribute(facesContext, component, "styleClass");
+ String datatableId = (String) getAttribute(facesContext, component, "for");
+
+ // Get Form Component
+ UIComponent formComponent = component;
+ while (!(formComponent instanceof UIForm))
+ {
+ formComponent = formComponent.getParent();
+ }
+ String formComponentId = formComponent.getClientId(facesContext);
+
+ // Get Writer
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ // Get UIData
+ String id = getId(datatableId, component.getClientId(facesContext));
+ UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext, id);
+
+ int first = data.getFirst();
+ int rowCount = data.getRowCount();
+ int pageSize = data.getRows();
+ if (pageSize <= 0) pageSize = rowCount;
+
+ int pages = rowCount / pageSize;
+ if (rowCount % pageSize != 0 ) pages++;
+
+ int currentPage = first / pageSize;
+ if (first >= rowCount - pageSize) currentPage = pages-1;
+
+ int startPage = 0;
+ int endPage = pages;
+
+ if (currentPage > 0)
+ {
+ writeLink(writer, component, formComponentId, component.getClientId(facesContext), PREVIOUS, styleClass);
+ }
+ if (first < rowCount - pageSize)
+ {
+ writeLink(writer, component, formComponentId, component.getClientId(facesContext), NEXT, styleClass);
+ }
+
+ writeHiddenField(writer, component, component.getClientId(facesContext));
+ }
+
+ public void decode(FacesContext facesContext, UIComponent component)
+ {
+ String id = component.getClientId(facesContext);
+ Map parameters = facesContext.getExternalContext().getRequestParameterMap();
+ String response = (String) parameters.get(id);
+
+ String datatableId = (String) getAttribute(facesContext, component, "for");
+
+ // Get UIData
+ String dataId = getId(datatableId, component.getClientId(facesContext));
+ UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext, dataId);
+
+ int first = data.getFirst();
+ int rowCount = data.getRowCount();
+ int pageSize = data.getRows();
+ if (pageSize <= 0) pageSize = rowCount;
+
+ if (response.equals(PREVIOUS))
+ {
+ first -= pageSize;
+ }
+ else if (response.equals(NEXT))
+ {
+ first += pageSize;
+ }
+
+ if (first < 0)
+ {
+ first = 0;
+ }
+ data.setFirst(first);
+ }
+
+
+ private Object getAttribute(FacesContext facesContext, UIComponent component, String name)
+ {
+ ValueBinding vb = component.getValueBinding(name);
+ if (vb != null)
+ {
+ return vb.getValue(facesContext);
+ }
+ else
+ {
+ return component.getAttributes().get(name);
+ }
+ }
+
+ public String getId(String id, String base)
+ {
+ String separator = "" + NamingContainer.SEPARATOR_CHAR;
+ String[] idSplitted = id.split(separator);
+ String[] baseSplitted = base.split(separator);
+ StringBuffer buffer = new StringBuffer();
+ for (int i=0; i<(baseSplitted.length - idSplitted.length); i++)
+ {
+ buffer.append(baseSplitted[i]);
+ buffer.append(separator);
+ }
+ buffer.append(id);
+ return buffer.toString();
+ }
+
+ private UIComponent findComponent(UIComponent component, FacesContext facesContext, String id)
+ {
+ String componentId = component.getClientId(facesContext);
+ if (componentId.equals(id))
+ {
+ return component;
+ }
+ Iterator it = component.getChildren().iterator();
+ while (it.hasNext())
+ {
+ UIComponent comp = (UIComponent)it.next();
+ UIComponent found = findComponent(comp, facesContext, id);
+ if (found != null)
+ {
+ return found;
+ }
+
+ }
+ return null;
+ }
+
+ private void writeHiddenField(ResponseWriter writer, UIComponent component, String id) throws IOException
+ {
+ writer.startElement("input", component);
+ writer.writeAttribute("type", "hidden", null);
+ writer.writeAttribute("name", id, null);
+ writer.endElement("input");
+ }
+
+ private void writeLink(ResponseWriter writer, UIComponent component, String formComponentId, String id, String value, String styleClass) throws IOException
+ {
+ writer.writeText(" ", null);
+ writer.startElement("input", component);
+ writer.writeAttribute("value", value, null);
+ writer.writeAttribute("type", "submit", null);
+ writer.writeAttribute("onclick", onclickCode(formComponentId, id, value), null);
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, "styleClass");
+ }
+ writer.endElement("input");
+
+ /*
+ writer.writeText(" ", null);
+ writer.startElement("a", component);
+ writer.writeAttribute("href", "#", null);
+ writer.writeAttribute("onclick", onclickCode(formComponentId, id, value), null);
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, "styleClass");
+ }
+ writer.writeText(value, null);
+ writer.endElement("a");
+ */
+ }
+
+ private String onclickCode(String formComponentId, String id, String value)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("document.forms[");
+ buffer.append("'");
+ buffer.append(formComponentId);
+ buffer.append("']");
+ buffer.append(".elements['");
+ buffer.append(id);
+ buffer.append("'].value='");
+ buffer.append(value);
+ buffer.append("';");
+ buffer.append(" document.forms[");
+ buffer.append("'");
+ buffer.append(formComponentId);
+ buffer.append("'");
+ buffer.append("].submit()");
+ buffer.append("; return false;");
+ return buffer.toString();
+ }
+
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.scroller;
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ScrollerTag extends UIComponentTag
+{
+
+ private String _for;
+ private String styleClass;
+
+ public String getComponentType()
+ {
+ return "com.jboss.portal.Scroller";
+ }
+
+ public String getRendererType()
+ {
+ return "default";
+ }
+
+ public void setFor(String _for)
+ {
+ this._for = _for;
+ }
+
+ public void setStyleClass(String styleClass)
+ {
+ this.styleClass = styleClass;
+ }
+
+ public void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setString(component, "for", _for);
+ setString(component, "styleClass", styleClass);
+ }
+
+ private void setString(UIComponent component, String attributeName, String attributeValue)
+ {
+ if (attributeValue == null) return;
+ if (isValueReference(attributeValue))
+ {
+ setValueBinding(component, attributeName, attributeValue);
+ }
+ else
+ {
+ component.getAttributes().put(attributeName, attributeValue);
+ }
+ }
+
+ private void setValueBinding(UIComponent component, String attributeName, String attributeValue)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application app = facesContext.getApplication();
+ ValueBinding vb = app.createValueBinding(attributeValue);
+ component.setValueBinding(attributeName, vb);
+ }
+
+ public void release()
+ {
+ super.release();
+ _for = null;
+ styleClass = null;
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java 2007-03-13 22:24:32 UTC (rev 6656)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.component.scroller;
+
+import javax.faces.component.UIInput;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class UIScroller extends UIInput
+{
+ public UIScroller()
+ {
+ setRendererType("default");
+ }
+}
17 years, 6 months