[portal-commits] JBoss Portal SVN: r9161 - in branches/JBoss_Portal_Branch_2_6/core-admin/src: resources/portal-admin-war/WEB-INF/jsf and 1 other directory.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Nov 28 06:43:37 EST 2007


Author: thomas.heute at jboss.com
Date: 2007-11-28 06:43:37 -0500 (Wed, 28 Nov 2007)
New Revision: 9161

Modified:
   branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java
   branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/displayNameObject.xhtml
Log:
JBPORTAL-1805  Let a user define multiple display-name for a portal object in the admin portlet
Delete i10n value

Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java	2007-11-28 11:41:44 UTC (rev 9160)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java	2007-11-28 11:43:37 UTC (rev 9161)
@@ -149,13 +149,37 @@
             Map.Entry pairs = (Map.Entry) it.next();
             Locale thisLocale = (Locale)pairs.getKey();
             Locale requestedLocale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
-            currentLocales.add(new Value(convertLocaleDisplayName(thisLocale.getDisplayLanguage(requestedLocale)),getDisplayNameByLocale(thisLocale)));
+            currentLocales.add(new Value(thisLocale, convertLocaleDisplayName(thisLocale.getDisplayLanguage(requestedLocale)),getDisplayNameByLocale(thisLocale)));
             
          }
          return currentLocales;
       }
       return null;
    }
+   
+   public void removeDisplayName()
+   {
+      String locale = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("locale");
+
+      PortalObject portalObject = getSelectedObject();
+      LocalizedString displayName = portalObject.getDisplayName();
+      Map<Locale, String> map = new HashMap<Locale, String>();
+      if (displayName != null)
+      {
+         Map<Locale, LocalizedString.Value> oldMap = displayName.getValues();
+         Collection<LocalizedString.Value> values = oldMap.values();
+         for (LocalizedString.Value value : values)
+         {
+            if (!value.getLocale().toString().equals(locale.toString()))
+            {
+               map.put(value.getLocale(), value.getString());
+            }
+         }
+      }
+      LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
+      selectedObject.setDisplayName(newLocalizedString);
+   }
+   
 /*
    public void setCurrentLocales(Map currentLocales)
    {
@@ -192,11 +216,14 @@
    {
       private String localeDisplayName;
       
+      private Locale locale;
+      
       private String text;
       
-      public Value(String localeDisplayName, String text)
+      public Value(Locale locale, String localeDisplayName, String text)
       {
          this.localeDisplayName = localeDisplayName;
+         this.locale = locale;
          this.text = text;
       }
 
@@ -219,6 +246,16 @@
       {
          this.text = text;
       }
+
+      public Locale getLocale()
+      {
+         return locale;
+      }
+
+      public void setLocale(Locale locale)
+      {
+         this.locale = locale;
+      }
       
       
    }

Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/displayNameObject.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/displayNameObject.xhtml	2007-11-28 11:41:44 UTC (rev 9160)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/displayNameObject.xhtml	2007-11-28 11:43:37 UTC (rev 9161)
@@ -8,7 +8,8 @@
       <ui:param name="portalObjectScreen" value="Rename"/>
       <ui:define name="content">
          <h3>Add Display Name</h3>
-         <h:form id="displayNameForm">
+         
+         <h:form>
 
             <p class="portlet-area-header">Current Display Names</p>
             <div class="portlet-area-body">
@@ -16,10 +17,15 @@
             <c:forEach items="#{addDisplayNameAction.currentLocales}" var="value">
                <!--We should be able to do something like with el,
                 but it's not working so I printed out all languages :)-->
-               <li>#{value.localeDisplayName} - #{value.text}</li>
+               <li>#{value.localeDisplayName} - #{value.text} <h:commandLink action="#{addDisplayNameAction.removeDisplayName}">
+                           <h:outputText styleClass="actionDelete" value="Delete"/>
+                           <f:param name="locale" value="#{value.locale}"/>
+                        </h:commandLink></li>
             </c:forEach>
             </ul>
             </div>
+         </h:form>
+         <h:form id="displayNameForm">
             <p class="portlet-area-header">Add Display Names</p>
             <div class="portlet-area-body">
                <h:inputText id="newName" value="#{addDisplayNameAction.newText}" required="true"/>




More information about the portal-commits mailing list