Author: julien(a)jboss.com
Date: 2007-02-22 18:12:44 -0500 (Thu, 22 Feb 2007)
New Revision: 6380
Added:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/ContentTypeConverter.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/content/ContentEditorTagHandler.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/plugins/manager.xhtml
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/core-cms/src/resources/portal-cms-sar/content/editor.xhtml
Log:
- added ContentType JSF converter
- when creating content allow to chose the content type based on the available plugins
Added:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/ContentTypeConverter.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/ContentTypeConverter.java
(rev 0)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/ContentTypeConverter.java 2007-02-22
23:12:44 UTC (rev 6380)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import org.jboss.portal.core.model.content.ContentType;
+
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContentTypeConverter implements Converter
+{
+ public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String
string) throws ConverterException
+ {
+ return string == null ? null : ContentType.create(string);
+ }
+
+ public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object
object) throws ConverterException
+ {
+ return object == null ? null : object.toString();
+ }
+}
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java 2007-02-22
19:23:35 UTC (rev 6379)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java 2007-02-22
23:12:44 UTC (rev 6380)
@@ -61,6 +61,7 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.faces.el.DelegatingPropertyResolver;
import org.jboss.portal.faces.el.PropertyDef;
import org.jboss.portal.faces.el.TypeDef;
@@ -201,6 +202,12 @@
/** . */
private HtmlTree _tree;
+ /** The selected type for content. */
+ private ContentType selectedContentType = ContentType.PORTLET;
+
+ /** The uri value for content. */
+ private String selectedContentURI;
+
/** Compares two windows according to their order. */
private static final Comparator comparator = new Comparator()
{
@@ -219,6 +226,26 @@
}
};
+ public ContentType getSelectedContentType()
+ {
+ return selectedContentType;
+ }
+
+ public void setSelectedContentType(ContentType selectedContentType)
+ {
+ this.selectedContentType = selectedContentType;
+ }
+
+ public String getSelectedContentURI()
+ {
+ return selectedContentURI;
+ }
+
+ public void setSelectedContentURI(String selectedContentURI)
+ {
+ this.selectedContentURI = selectedContentURI;
+ }
+
public RoleModule getRoleModule()
{
return roleModule;
@@ -339,6 +366,14 @@
selectedPlugin = (String)pmap.get("plugin");
}
+ /**
+ *
+ */
+ public void udpateContentType()
+ {
+ // Do nothing
+ }
+
/** Proceed to an object selection. */
public void selectObject()
{
@@ -347,6 +382,8 @@
// Clear state
selectedId = null;
selectedPlugin = null;
+ selectedContentType = ContentType.PORTLET;
+ selectedContentURI = null;
// Get id
Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java 2007-02-22
19:23:35 UTC (rev 6379)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java 2007-02-22
23:12:44 UTC (rev 6380)
@@ -45,9 +45,6 @@
private PortalObjectManagerBean pomgr;
/** . */
- private String instanceId;
-
- /** . */
private String windowName;
public PortalObjectManagerBean getPortalObjectManager()
@@ -70,16 +67,6 @@
this.windowName = windowName;
}
- public String getInstanceId()
- {
- return instanceId;
- }
-
- public void setInstanceId(String instanceId)
- {
- this.instanceId = instanceId;
- }
-
/**
* Checks for duplicate window names on the page. Blank window names are not allowed
and are controlled by the
* required attribute in the presentation page.
@@ -120,7 +107,11 @@
Page page = (Page)pomgr.getSelectedObject();
//
- Window window = page.createWindow(windowName, ContentType.PORTLET, instanceId);
+ ContentType contentType = pomgr.getSelectedContentType();
+ String contentURI = pomgr.getSelectedContentURI();
+
+ //
+ Window window = page.createWindow(windowName, contentType, contentURI);
window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, region);
window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" +
Integer.MAX_VALUE);
}
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/content/ContentEditorTagHandler.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/content/ContentEditorTagHandler.java 2007-02-22
19:23:35 UTC (rev 6379)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/content/ContentEditorTagHandler.java 2007-02-22
23:12:44 UTC (rev 6380)
@@ -52,9 +52,6 @@
private ContentEditorRegistry registry;
/** . */
- private final TagAttribute src;
-
- /** . */
private final TagAttribute contentType;
/** . */
@@ -65,7 +62,6 @@
super(tagConfig);
//
- this.src = this.getRequiredAttribute("src");
this.contentURI = this.getRequiredAttribute("contentURI");
this.contentType = this.getRequiredAttribute("contentType");
}
@@ -89,32 +85,40 @@
// Get content type value
ValueExpression contentTypeValue = contentType.getValueExpression(ctx,
Object.class);
- String contentTypeString = (String)contentTypeValue.getValue(ctx);
- ContentType ct = ContentType.create(contentTypeString);
+ ContentType contentType = (ContentType)contentTypeValue.getValue(ctx);
// Get editor
- FaceletContentEditor editor = (FaceletContentEditor)registry.getEditor(ct);
+ FaceletContentEditor editor = null;
+ if (contentType != null)
+ {
+ editor = (FaceletContentEditor)registry.getEditor(contentType);
+ }
- // Get editor URL
- URL url = editor.getFaceletURL();
-
- // Do the include stuff
- VariableMapper orig = ctx.getVariableMapper();
- ctx.setVariableMapper(new VariableMapperWrapper(orig));
- try
+ // Only perform inclusion if content type is not null
+ if (editor != null)
{
- nextHandler.apply(ctx, null);
- //
- ValueExpression valueVE = contentURI.getValueExpression(ctx, Object.class);
- ctx.getVariableMapper().setVariable(contentURI.getLocalName(), valueVE);
+ // Get editor URL
+ URL url = editor.getFaceletURL();
- //
- ctx.includeFacelet(parent, url);
+ // Do the include stuff
+ VariableMapper orig = ctx.getVariableMapper();
+ ctx.setVariableMapper(new VariableMapperWrapper(orig));
+ try
+ {
+ nextHandler.apply(ctx, null);
+
+ //
+ ValueExpression valueVE = contentURI.getValueExpression(ctx, Object.class);
+ ctx.getVariableMapper().setVariable(contentURI.getLocalName(), valueVE);
+
+ //
+ ctx.includeFacelet(parent, url);
+ }
+ finally
+ {
+ ctx.setVariableMapper(orig);
+ }
}
- finally
- {
- ctx.setVariableMapper(orig);
- }
}
}
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-02-22
19:23:35 UTC (rev 6379)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-02-22
23:12:44 UTC (rev 6380)
@@ -32,6 +32,11 @@
<view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
</application>
+ <converter>
+
<converter-for-class>org.jboss.portal.core.model.content.ContentType</converter-for-class>
+
<converter-class>org.jboss.portal.core.portlet.management.ContentTypeConverter</converter-class>
+ </converter>
+
<!-- The portal object manager bean -->
<managed-bean>
<managed-bean-name>portalobjectmgr</managed-bean-name>
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/plugins/manager.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/plugins/manager.xhtml 2007-02-22
19:23:35 UTC (rev 6379)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/plugins/manager.xhtml 2007-02-22
23:12:44 UTC (rev 6380)
@@ -98,6 +98,7 @@
</h:commandLink>
</t:columns>
</t:dataTable>
+
</h:form>
<h:form id="page_form_3">
<t:dataTable
@@ -111,15 +112,22 @@
</t:columns>
</t:dataTable>
+ <h:selectOneMenu
+ value="#{portalobjectmgr.selectedContentType}">
+ <f:selectItems value="#{registry.availableTypes}"/>
+ </h:selectOneMenu>
+ <h:commandButton
+ value="Change content type"/>
+ <ct:content
+ contentType="#{portalobjectmgr.selectedContentType}"
+ contentURI="#{portalobjectmgr.selectedContentURI}"/>
+ <br/>
+
<h:messages style="color: red"/>
<h:panelGroup>
<h:inputText value="#{addWindowAction.windowName}"
validator="#{addWindowAction.validateWindowName}"
required="true"/>
-  
- <h:selectOneMenu value="#{addWindowAction.instanceId}">
- <f:selectItems value="#{portalobjectmgr.instanceItems}"/>
- </h:selectOneMenu>
</h:panelGroup>
</h:form>
@@ -148,18 +156,9 @@
<h:outputText style="font-weight:bold;" value="Type: "/>
<f:verbatim>Window<br/></f:verbatim>
- <h:form id="content_type_form">
- <h:selectOneMenu
- value="#{registry.selectedType}">
- <f:selectItems value="#{registry.availableTypes}"/>
- </h:selectOneMenu>
- <h:commandButton value="Change content type"/>
- </h:form>
-
<h:form id="window_form">
<ct:content
- src="bilto_src"
- contentType="#{registry.selectedType}"
+ contentType="#{portalobjectmgr.selectedObject.type==3 ?
portalobjectmgr.selectedObject.contentType : null}"
contentURI="#{portalobjectmgr.selectedObject.instanceRef}"/>
<br/>
<h:commandButton value="Change instance"/>
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java 2007-02-22
19:23:35 UTC (rev 6379)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java 2007-02-22
23:12:44 UTC (rev 6380)
@@ -23,11 +23,50 @@
package org.jboss.portal.core.cms.content;
import org.jboss.portal.core.portlet.management.content.AbstractFaceletContentEditor;
+import org.jboss.portal.cms.CMS;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.cms.model.File;
+import javax.faces.model.SelectItem;
+import java.util.List;
+import java.util.ArrayList;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public class CMSFaceletContentEditor extends AbstractFaceletContentEditor
{
+
+ /** . */
+ private CMS cms;
+
+ public CMS getCMS()
+ {
+ return cms;
+ }
+
+ public void setCMS(CMS cms)
+ {
+ this.cms = cms;
+ }
+
+ public List getFiles()
+ {
+ Command listCMD =
cms.getCommandFactory().createFolderGetListCommand("/default");
+ Folder folder = (Folder)cms.execute(listCMD);
+ List files = folder.getFiles();
+ List items = new ArrayList(files.size());
+ for (int i = 0; i < files.size(); i++)
+ {
+ File file = (File)files.get(i);
+ SelectItem item = new SelectItem();
+ item.setValue(file.getBasePath());
+ item.setDescription("blah");
+ item.setLabel(file.getName());
+ items.add(item);
+ }
+ return items;
+ }
}
Modified: trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-02-22
19:23:35 UTC (rev 6379)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-02-22
23:12:44 UTC (rev 6380)
@@ -697,6 +697,9 @@
<depends
optional-attribute-name="Registry"
proxy-type="attribute">portal:service=ContentEditorRegistry2</depends>
+ <depends
+ optional-attribute-name="CMS"
+ proxy-type="attribute">portal:service=CMS</depends>
</mbean>
<!-- Content renderer integration -->
Modified: trunk/core-cms/src/resources/portal-cms-sar/content/editor.xhtml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/content/editor.xhtml 2007-02-22 19:23:35
UTC (rev 6379)
+++ trunk/core-cms/src/resources/portal-cms-sar/content/editor.xhtml 2007-02-22 23:12:44
UTC (rev 6380)
@@ -4,6 +4,9 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
- <h:outputText value="TOTO"/>
+ <h:selectOneListbox
+ value="#{contentURI}">
+ <f:selectItems value="#{registry.editors.cms.files}"/>
+ </h:selectOneListbox>
</div>
\ No newline at end of file