Author: chris.laprun(a)jboss.com
Date: 2009-02-24 05:26:12 -0500 (Tue, 24 Feb 2009)
New Revision: 12875
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java
Log:
- JBPORTAL-2317: Fixed name validation for page layout.
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2009-02-24
08:59:12 UTC (rev 12874)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2009-02-24
10:26:12 UTC (rev 12875)
@@ -20,6 +20,7 @@
* 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;
import org.jboss.portal.api.content.SelectedContent;
@@ -674,7 +675,9 @@
{
if (pageManager == null)
{
+ // it'd be better if propertyAction was injected in faces-config.xml so
that we can also inject the shared beanContext
pageManager = new PageManagerBean(layoutService, portletDefinitionInvoker);
+ pageManager.setBeanContext(new JSFBeanContext());
}
pageManager.page = (Page)selectedObject;
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2009-02-24
08:59:12 UTC (rev 12874)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2009-02-24
10:26:12 UTC (rev 12875)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -39,18 +39,18 @@
import org.jboss.portal.faces.component.portlet.PortletRenderEvent;
import org.jboss.portal.faces.el.PropertyValue;
import org.jboss.portal.faces.el.dynamic.DynamicBean;
+import org.jboss.portal.faces.gui.ManagedBean;
import org.jboss.portal.portlet.PortletInvoker;
import
org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse.Event;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
-import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
-import javax.faces.component.UIInput;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.Collection;
@@ -68,7 +68,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class PageManagerBean
+public class PageManagerBean extends ManagedBean
{
private static final QName CONTENT_SELECT = new
QName("urn:jboss:portal:content", "select");
@@ -84,7 +84,6 @@
/** . */
private static final int ADD_ACTION = 'a';
- private static final String VIEW_ROOT = ":_viewRoot";
public PageManagerBean(LayoutService layoutService, PortletInvoker portletInvoker)
{
@@ -113,7 +112,7 @@
public String selectedContentURI;
/** . */
- private Map<String,String> selectedContentParameters;
+ private Map<String, String> selectedContentParameters;
/** . */
public Map selectedRenderParameters;
@@ -136,7 +135,7 @@
}
public List getContentTypeItems()
- {
+ {
LinkedList<SelectItem> types = new LinkedList<SelectItem>();
for (Object o : ContentProviderRegistryService.getInstance().getContentTypes())
{
@@ -158,7 +157,7 @@
public ContentType getSelectedContentType()
{
- return selectedContentType;
+ return selectedContentType;
}
public void setSelectedContentType(ContentType selectedContentType)
@@ -275,7 +274,7 @@
{
//
String selectedContentURI = this.selectedContentURI;
- Map<String,String> selectedContentParams =
this.selectedContentParameters;
+ Map<String, String> selectedContentParams =
this.selectedContentParameters;
// Reset to new state
this.selectedContentURI = null;
@@ -283,23 +282,23 @@
this.selectedRenderParameters = new HashMap();
// Obtain a window name
- String windowName =
(String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("blah");
- if (windowName.trim().length() == 0)
+ String windowName =
(String)normalizeStringIfNeeded(beanContext.getParameter("blah"));
+ if (windowName == null)
{
+ // no specified name in the UI, generate one
windowName = createWindowName(selectedContentType.toString(),
selectedContentURI, false);
while (page.getWindow(windowName) != null)
{
windowName = createWindowName(selectedContentType.toString(),
selectedContentURI, true);
}
}
-
- // Check for duplicate window name
- if (page.getWindow(windowName) != null)
+ else
{
- FacesContext faces = FacesContext.getCurrentInstance();
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Duplicate window name found on this page!", null);
- faces.addMessage("windowName", message);
- throw new AbortProcessingException();
+ windowName = checkNameValidity(windowName,
"windowForm:windowName");
+ if (windowName == null)
+ {
+ throw new AbortProcessingException("Duplicate window
name!");
+ }
}
//
@@ -311,7 +310,7 @@
{
for (Object o : selectedContentParams.entrySet())
{
- Map.Entry<String,String> entry =
(Map.Entry<String,String>)o;
+ Map.Entry<String, String> entry = (Map.Entry<String,
String>)o;
String paramName = entry.getKey();
String paramValue = entry.getValue();
content.setParameter(paramName, paramValue);
@@ -344,10 +343,7 @@
}
else
{
- FacesContext faces = FacesContext.getCurrentInstance();
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"No content was selected!", null);
- faces.addMessage("layoutForm", message);
-// throw new AbortProcessingException();
+ beanContext.createTargetedErrorMessage("layoutForm",
"COMMON_NO_SELECTED_CONTENT");
}
}
else if (direction == MOVE_LEFT)
@@ -403,12 +399,12 @@
Event portletEvent = eventEvent.getEvent();
QName name = portletEvent.getName();
// only react to content selection events
- if(CONTENT_SELECT.equals(name))
+ if (CONTENT_SELECT.equals(name))
{
if (portletEvent.getPayload() instanceof String)
{
String uri = (String)portletEvent.getPayload();
- this.selectedContentURI = uri;
+ this.selectedContentURI = uri;
this.selectedContentParameters = null;
}
else if (portletEvent.getPayload() instanceof SelectedContent)
@@ -556,4 +552,14 @@
return true;
}
}
+
+ protected String getObjectTypeName()
+ {
+ return "WINDOW_TYPE";
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return page.getWindow(objectName) != null;
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java 2009-02-24
08:59:12 UTC (rev 12874)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java 2009-02-24
10:26:12 UTC (rev 12875)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -34,6 +34,7 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPath;
+import org.jboss.portal.faces.gui.JSFBeanContext;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
@@ -115,7 +116,9 @@
// Create page manager if it does not exit
if (pageManager == null)
{
+ // it'd be better if propertyAction was injected in faces-config.xml so that
we can also inject the shared beanContext
pageManager = new PageManagerBean(layoutService, new
PortletDefinitionInvoker(instanceContainer));
+ pageManager.setBeanContext(new JSFBeanContext());
}
// Get user name
@@ -147,7 +150,7 @@
defaultPageName = PortalObject.DEFAULT_OBJECT_NAME;
}
selectePageIsDefault = selectedPageName.equals(defaultPageName);
-
+
//
Collection pages = userPortal.getChildren(PortalObject.PAGE_MASK);
pageItems = new SelectItem[pages.size()];
@@ -199,7 +202,7 @@
try
{
userPortal.destroyChild(selectedPageName);
-
+
// Fallback to default page
String defaultPageName =
pageManager.page.getProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME);
if (defaultPageName == null)