Author: thomas.heute(a)jboss.com
Date: 2007-03-26 12:25:49 -0400 (Mon, 26 Mar 2007)
New Revision: 6831
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml
Log:
Add some error message if the object name is already used
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2007-03-26
16:13:39 UTC (rev 6830)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2007-03-26
16:25:49 UTC (rev 6831)
@@ -24,6 +24,9 @@
import java.util.Set;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
@@ -78,7 +81,10 @@
{
PortalObject portalObject = (PortalObject)portalObjectManager.getSelectedObject();
PortalObject parent = portalObject.getParent();
- try {
+ try
+ {
+ // TODO: Should be in a tx
+
// Clone portal object
PortalObject newObject = portalObject.copy(parent, newName, true);
@@ -88,15 +94,20 @@
// Destroy previous object
parent.destroyChild(portalObject.getName());
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
+ }
+ catch (IllegalArgumentException e)
+ {
e.printStackTrace();
- } catch (DuplicatePortalObjectException e) {
- // TODO Auto-generated catch block
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ String message = "The name \"" + newName + "\" is
already used, please choose a different one";
+ FacesContext.getCurrentInstance().addMessage("renameForm:newName", new
FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
+ return null;
+ }
+ catch (NoSuchPortalObjectException e)
+ {
e.printStackTrace();
- } catch (NoSuchPortalObjectException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
portalObjectManager.selectObject(parent);
return "objects";
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-26
16:13:39 UTC (rev 6830)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-26
16:25:49 UTC (rev 6831)
@@ -255,6 +255,21 @@
</managed-property>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>renameAction</managed-bean-name>
+
<managed-bean-class>org.jboss.portal.core.admin.ui.actions.RenameAction</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>portalObjectManager</property-name>
+ <value>#{sessionScope.portalobjectmgr}</value>
+ </managed-property>
+ <managed-property>
+ <property-name>domainConfigurator</property-name>
+
<value>#{applicationScope.AuthorizationDomainRegistry.portalobject.configurator}</value>
+ </managed-property>
+
+ </managed-bean>
+
<navigation-rule>
<navigation-case>
<from-outcome>index</from-outcome>
@@ -297,6 +312,11 @@
<to-view-id>/WEB-INF/jsf/editWindowSecurity.xhtml</to-view-id>
</navigation-case>
<navigation-case>
+ <from-outcome>renameObject</from-outcome>
+ <to-view-id>/WEB-INF/jsf/renameObject.xhtml</to-view-id>
+ </navigation-case>
+
+ <navigation-case>
<from-outcome>editWindowTheme</from-outcome>
<to-view-id>/WEB-INF/jsf/editWindowTheme.xhtml</to-view-id>
</navigation-case>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml 2007-03-26
16:13:39 UTC (rev 6830)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml 2007-03-26
16:25:49 UTC (rev 6831)
@@ -7,8 +7,10 @@
<ui:composition template="/WEB-INF/jsf/objectTemplate.xhtml">
<ui:define name="content">
<h3>Renaming:</h3>
- <h:form>
- <h:inputText value="#{renameAction.newName}"/>
+ <h:form id="renameForm">
+ <h:inputText id="newName"
value="#{renameAction.newName}"/>
+ <h:message for="newName"/>
+ <br />
<h:commandButton value="Update"
action="#{renameAction.execute}"
styleClass="portlet-form-button"/>
</h:form>
</ui:define>