Author: tan_pham_dinh
Date: 2009-10-30 05:43:53 -0400 (Fri, 30 Oct 2009)
New Revision: 456
Modified:
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_en.properties
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_fr.properties
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_ru.properties
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_uk.properties
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
Log:
GTNPORTAL-101: Make localization Portlet Description, GTNPORTAL-89: Limit character when
edit label of dashboard, integrate validator
Modified:
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
===================================================================
---
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2009-10-30
09:39:55 UTC (rev 455)
+++
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2009-10-30
09:43:53 UTC (rev 456)
@@ -38,6 +38,7 @@
import org.exoplatform.webui.core.UIContainer;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.exception.MessageException;
import java.util.ArrayList;
import java.util.List;
@@ -209,6 +210,25 @@
}
}
+ private boolean validateName(String label)
+ {
+ label = label.trim();
+ if (Character.isDigit(label.charAt(0)) || label.charAt(0) == '-')
+ {
+ return false;
+ }
+ for (int i = 0; i < label.length(); i++)
+ {
+ char c = label.charAt(i);
+ if (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c ==
'-' || Character.isSpaceChar(c))
+ {
+ continue;
+ }
+ return false;
+ }
+ return true;
+ }
+
private boolean nameExisted(String nodeName)
{
for (PageNode node : pageNavigation.getNodes())
@@ -313,6 +333,11 @@
UITabPaneDashboard tabPane = event.getSource();
WebuiRequestContext context = event.getRequestContext();
String newTabLabel = context.getRequestParameter(UIComponent.OBJECTID);
+ if (!tabPane.validateName(newTabLabel))
+ {
+ context.getUIApplication().addMessage(new
ApplicationMessage("UITabPaneDashboard.msg.wrongTabName", null));
+ return;
+ }
String newNodeName = tabPane.createNewPageNode(newTabLabel);
//If new node is created with success, then redirect to it
@@ -342,6 +367,11 @@
WebuiRequestContext context = event.getRequestContext();
int nodeIndex =
Integer.parseInt(context.getRequestParameter(UIComponent.OBJECTID));
String newTabLabel = context.getRequestParameter(RENAMED_TAB_LABEL_PARAMETER);
+ if (!tabPane.validateName(newTabLabel))
+ {
+ context.getUIApplication().addMessage(new
ApplicationMessage("UITabPaneDashboard.msg.wrongTabName", null));
+ return;
+ }
String newNodeName = tabPane.renamePageNode(nodeIndex, newTabLabel);
//If page node is renamed with success, then redirect to new URL
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_en.properties
===================================================================
---
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_en.properties 2009-10-30
09:39:55 UTC (rev 455)
+++
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_en.properties 2009-10-30
09:43:53 UTC (rev 456)
@@ -20,4 +20,5 @@
UITabPaneDashboard.action.addNewDashboard=Add Dashboard
UITabPaneDashboard.action.switchShowRange=Switch Range
UITabPaneDashboard.msg.deleteTab=Really want to remove this dashboard?
-UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
\ No newline at end of file
+UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
+UITabPaneDashboard.msg.wrongTabName=Only alpha, digit, underscore, dash and space
characters allowed.
\ No newline at end of file
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_fr.properties
===================================================================
---
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_fr.properties 2009-10-30
09:39:55 UTC (rev 455)
+++
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_fr.properties 2009-10-30
09:43:53 UTC (rev 456)
@@ -20,4 +20,5 @@
UITabPaneDashboard.action.addNewDashboard =Ajoute Dashboard
UITabPaneDashboard.action.switchShowRange =Decale
UITabPaneDashboard.msg.deleteTab=Really want to remove this dashboard?
-UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
\ No newline at end of file
+UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
+UITabPaneDashboard.msg.wrongTabName=Only alpha, digit, underscore, dash and space
characters allowed.
\ No newline at end of file
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_ru.properties
===================================================================
---
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_ru.properties 2009-10-30
09:39:55 UTC (rev 455)
+++
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_ru.properties 2009-10-30
09:43:53 UTC (rev 456)
@@ -20,4 +20,5 @@
UITabPaneDashboard.action.addNewDashboard=Добавить доску
UITabPaneDashboard.action.switchShowRange=Изменить область
UITabPaneDashboard.msg.deleteTab=Вы действительно хотите удалить эту доску?
-UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
\ No newline at end of file
+UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
+UITabPaneDashboard.msg.wrongTabName=Only alpha, digit, underscore, dash and space
characters allowed.
\ No newline at end of file
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_uk.properties
===================================================================
---
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_uk.properties 2009-10-30
09:39:55 UTC (rev 455)
+++
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/classes/locale/portlet/dashboard/TabbedDashboardPortlet_uk.properties 2009-10-30
09:43:53 UTC (rev 456)
@@ -20,4 +20,5 @@
UITabPaneDashboard.action.addNewDashboard =Додати панель інструментів
UITabPaneDashboard.action.switchShowRange =Перемикач діапазону
UITabPaneDashboard.msg.deleteTab=Really want to remove this dashboard?
-UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
\ No newline at end of file
+UITabPaneDashboard.msg.cannotDeleteLastTab=Can not delete the last tab.
+UITabPaneDashboard.msg.wrongTabName=Only alpha, digit, underscore, dash and space
characters allowed.
\ No newline at end of file
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js 2009-10-30
09:39:55 UTC (rev 455)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UITabbedDashboard.js 2009-10-30
09:43:53 UTC (rev 456)
@@ -51,7 +51,7 @@
href += "&uicomponent=UITabPaneDashboard";
href += "&op=RenameTabLabel";
href += "&objectId=" + nodeIndex;
- href += "&newTabLabel=" + newTabLabel;
+ href += "&newTabLabel=" + encodeURIComponent(newTabLabel);
window.location = href;
return;
}
@@ -83,6 +83,7 @@
inputElement.style.border = "1px solid #b7b7b7";
inputElement.style.width = "95px";
inputElement.onkeypress = eXo.webui.UITabbedDashboard.renameTabLabel;
+ inputElement.setAttribute('maxLength', 50);
inputElement.onblur = function() {
prNode.replaceChild(eXo.webui.UITabbedDashboard.backupElement, inputElement);
};
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2009-10-30
09:39:55 UTC (rev 455)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2009-10-30
09:43:53 UTC (rev 456)
@@ -37,7 +37,6 @@
<div class="id"><%=uicomponent.getId();%></div>
<div
class="title"><%=_ctx.appRes("UIPortlet.label.title");%></div>
<div class="description">
-
<%if(uicomponent.getDescription() != null) {%>
<%=uicomponent.getDescription();%>
<%} else {%>
@@ -67,22 +66,12 @@
<div class="CenterBackground">
<div class="GardientBackground">
<%
- String displayName = uicomponent.getDisplayName();
- if(displayName != null) {
- String htmlDisplayName = ""; int count = 1;
- for(c in displayName){
- if(c=="\n"){
- c="<br/>";
- count++;
- }
- htmlDisplayName+=c;
- if(count>5) break;
- }
- %>
- <%=htmlDisplayName;%>
- <%} else {%>
- <%= _ctx.appRes("UIPortlet.label.portletContent");
%>
- <%}%>
+ try {
+ String portletName =
uicomponent.getProducedOfferedPortlet().getInfo().getName();
+ print
_ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description."
+ portletName);
+ } catch(Exception e){
+ print uicomponent.getDisplayName();
+ }%>
</div>
</div>
</div>