Author: phuong_vu
Date: 2011-10-25 22:47:15 -0400 (Tue, 25 Oct 2011)
New Revision: 7877
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UICaptcha.java
Removed:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java
Modified:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
portal/trunk/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UIDashboardPortlet.gtmpl
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetPortlet.gtmpl
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationForm.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java
portal/trunk/testsuite/webuibasedsamples/src/main/java/org/exoplatform/sample/webui/component/UISamplePopupMessage.java
portal/trunk/testsuite/webuibasedsamples/src/main/webapp/groovy/webui/component/UISamplePortlet.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIFormLifecycle.java
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIGroupSelector.java
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java
Log:
GTNPORTAL-2205 All WebUI portlets should send messages to Portal instead of handling by
themselves
Modified:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -19,7 +19,13 @@
package org.exoplatform.web.application;
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
import java.io.Serializable;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
/**
* Created by The eXo Platform SARL
@@ -29,11 +35,15 @@
*/
public class ApplicationMessage implements Serializable
{
+ private static Log log = ExoLogger.getLogger(ApplicationMessage.class);
+
final public static int ERROR = 0, WARNING = 1, INFO = 2;
private int type_ = INFO;
-
+
private String messageKey_;
+
+ private ResourceBundle resourceBundle;
private Object[] messageArgs_;
@@ -51,6 +61,30 @@
type_ = type;
}
+ public String getMessage()
+ {
+ String msg = resolveMessage(messageKey_);
+ if (msg != null && messageArgs_ != null)
+ {
+ for(int i = 0; i < messageArgs_.length; i++)
+ {
+ String arg = messageArgs_ [i].toString();
+ if (isArgsLocalized())
+ {
+ arg = resolveMessage(arg);
+ }
+ msg = msg.replace("{" + i + "}", arg);
+ }
+ }
+
+ return msg;
+ }
+
+ public void setResourceBundle(ResourceBundle resourceBundle)
+ {
+ this.resourceBundle = resourceBundle;
+ }
+
public String getMessageKey()
{
return messageKey_;
@@ -81,4 +115,26 @@
return argsLocalized;
}
+ private String resolveMessage(String key)
+ {
+ if (key == null && resourceBundle == null)
+ {
+ return key;
+ }
+
+ String value;
+ try
+ {
+ value = resourceBundle.getString(key);
+ }
+ catch (MissingResourceException ex)
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.warn("Can not find resource bundle for key : " + key);
+ }
+ value = key.substring(key.lastIndexOf('.') + 1);
+ }
+ return value;
+ }
}
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UIDashboardPortlet.gtmpl
===================================================================
---
portal/trunk/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UIDashboardPortlet.gtmpl 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UIDashboardPortlet.gtmpl 2011-10-26
02:47:15 UTC (rev 7877)
@@ -5,7 +5,6 @@
import org.exoplatform.dashboard.webui.component.UIDashboardEditForm;
def rcontext = _ctx.getRequestContext() ;
- def popupMsgs = uicomponent.getUIPopupMessages();
%>
<div id="$uicomponent.id" class="UIDashboardPortlet">
<% if(rcontext.getApplicationMode() == PortletMode.VIEW) {
@@ -15,6 +14,5 @@
uiEditForm.getUIStringInput(UIDashboardEditForm.TOTAL_COLUMNS).setValue(uicomponent.getNumberOfCols()
+ "");
uicomponent.renderUIComponent(uiEditForm) ;
}
- if(popupMsgs != null) popupMsgs.processRender(rcontext);
%>
</div>
\ No newline at end of file
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetPortlet.gtmpl
===================================================================
---
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetPortlet.gtmpl 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetPortlet.gtmpl 2011-10-26
02:47:15 UTC (rev 7877)
@@ -1,7 +1,6 @@
<% import javax.portlet.PortletMode ;
import org.exoplatform.gadget.webui.component.UIGadgetViewMode;
def rcontext = _ctx.getRequestContext() ;
- def popupMsgs = uicomponent.getUIPopupMessages();
%>
<div class="UIGadgetPortlet" id="$uicomponent.id">
<%
@@ -9,5 +8,5 @@
uicomponent.renderChild(UIGadgetViewMode.class) ;
}
- if(popupMsgs != null) popupMsgs.processRender(rcontext); %>
+%>
</div>
\ No newline at end of file
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UICaptcha.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UICaptcha.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UICaptcha.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss by Red Hat *
+ * Copyright 2010, 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.exoplatform.account.webui.component;
+
+import java.util.Calendar;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.form.UIFormStringInput;
+
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceURL;
+
+/**
+ * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class UICaptcha extends UIFormStringInput
+{
+
+ public UICaptcha(String name, String bindingExpression, String value)
+ {
+ super(name, bindingExpression, value);
+ }
+
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+
+ RenderResponse resp = context.getResponse();
+
+ //
+ ResourceURL url = resp.createResourceURL();
+
+ // context.getPortalContextPath() + "/captcha?v=" +
Calendar.getInstance().getTimeInMillis()
+
+ String random = "&v=" + Calendar.getInstance().getTimeInMillis();
+
+ context.getWriter().write("<div id='" + getId() +
"'><img src=\"" + url.toString() + random + "\"
/><br/>");
+ super.processRender(context);
+ context.getWriter().write("</div>");
+ }
+
+}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -19,7 +19,6 @@
package org.exoplatform.account.webui.component;
import org.exoplatform.portal.webui.CaptchaValidator;
-import org.exoplatform.portal.webui.UICaptcha;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -18,6 +18,9 @@
*/
package org.exoplatform.account.webui.component;
+
+import java.util.ArrayList;
+import java.util.List;
import nl.captcha.Captcha;
@@ -29,7 +32,6 @@
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIPopupMessages;
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.Event.Phase;
@@ -41,9 +43,6 @@
import org.exoplatform.webui.form.UIFormStringInput;
import org.exoplatform.webui.form.validator.Validator;
-import java.util.ArrayList;
-import java.util.List;
-
/**
*
* @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
@@ -87,9 +86,7 @@
{
super.processAction(context);
- UIApplication uiApp = context.getUIApplication();
- UIPopupMessages popupMessages = uiApp.getUIPopupMessages();
- if(popupMessages.getWarnings().size() > 0 || popupMessages.getErrors().size()
> 0)
+ if(context.getProcessRender())
{
//Invalidate the capcha
if (context instanceof PortletRequestContext)
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -22,7 +22,6 @@
import org.exoplatform.portal.pom.config.Utils;
import org.exoplatform.portal.webui.CaptchaValidator;
-import org.exoplatform.portal.webui.UICaptcha;
import org.exoplatform.services.organization.Query;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserHandler;
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -238,7 +238,6 @@
{
UIApplication uiApp = event.getRequestContext().getUIApplication();
uiApp.addMessage(new
ApplicationMessage("UIAddApplicationForm.msg.typeNoApps", null));
-
event.getRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
uiForm.getChild(UIFormTableIteratorInputSet.class).setRendered(false);
}
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationForm.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationForm.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationForm.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -101,7 +101,6 @@
uiOrganizer.reload();
uiOrganizer.setSelectedCategory(application.getCategoryName());
ctx.addUIComponentToUpdateByAjax(uiOrganizer);
- ctx.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
return;
}
uiForm.invokeSetBindingBean(application);
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -733,7 +733,6 @@
if (existPage != null)
{
uiPortalApp.addMessage(new
ApplicationMessage("UIPageForm.msg.sameName", null));
- pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
return;
}
Modified:
portal/trunk/testsuite/webuibasedsamples/src/main/java/org/exoplatform/sample/webui/component/UISamplePopupMessage.java
===================================================================
---
portal/trunk/testsuite/webuibasedsamples/src/main/java/org/exoplatform/sample/webui/component/UISamplePopupMessage.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/testsuite/webuibasedsamples/src/main/java/org/exoplatform/sample/webui/component/UISamplePopupMessage.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -5,8 +5,8 @@
import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
import org.exoplatform.webui.core.UIContainer;
-import org.exoplatform.webui.core.UIPopupMessages;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
@@ -21,10 +21,9 @@
{
int popupType =
Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID));
- UIPopupMessages uiPopupMessages =
-
((PortletRequestContext)WebuiRequestContext.getCurrentInstance()).getUIApplication().getUIPopupMessages();
- uiPopupMessages.addMessage(new ApplicationMessage("Test Message",
null, popupType));
- uiPopupMessages.setShow(true);
+ UIApplication uiApp =
+
((PortletRequestContext)WebuiRequestContext.getCurrentInstance()).getUIApplication();
+ uiApp.addMessage(new ApplicationMessage("Test Message", null,
popupType));
}
}
Modified:
portal/trunk/testsuite/webuibasedsamples/src/main/webapp/groovy/webui/component/UISamplePortlet.gtmpl
===================================================================
---
portal/trunk/testsuite/webuibasedsamples/src/main/webapp/groovy/webui/component/UISamplePortlet.gtmpl 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/testsuite/webuibasedsamples/src/main/webapp/groovy/webui/component/UISamplePortlet.gtmpl 2011-10-26
02:47:15 UTC (rev 7877)
@@ -23,8 +23,4 @@
</td>
</tr>
</table>
- <%
- UIPopupMessages uiPopupMessages = uicomponent.getUIPopupMessages();
- uiPopupMessages.processRender(_ctx.getRequestContext());
- %>
</div>
Modified: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl 2011-10-26
02:47:15 UTC (rev 7877)
@@ -51,31 +51,17 @@
}
println " <ul class=\"UITabContent PopupMessageBox $messType\"
$style>";
for(mess in messages) {
- if(mess.messageKey == null) continue;
- println " <li class=\"MessageContainer\">";
- println " <span class=\"PopupIcon
${messType}Icon\">";
- String msgValue = _ctx.appRes(mess.messageKey);
- Object[] msgArguments = mess.getMessageAruments();
- if(msgArguments != null && msgArguments.length > 0) {
- if (mess.isArgsLocalized()) {
- for(i in 0..msgArguments.length-1) {
- msgValue = msgValue.replace("{" + i + "}",
_ctx.appRes(msgArguments [i]));
- }
- } else {
- for(i in 0..msgArguments.length-1) {
- msgValue = msgValue.replace("{" + i + "}", msgArguments [i]);
- }
- }
- }
- EntityEncoder encoder = HTMLEntityEncoder.getInstance();
- msgValue = encoder.encode(msgValue);
- println msgValue;
-
- println " </span>";
- println " </li>";
- }
- println " </ul>";
- return isSelected;
+ if(mess.messageKey == null) continue;
+ println " <li class=\"MessageContainer\">";
+ println " <span class=\"PopupIcon
${messType}Icon\">";
+ String msgValue = mess.getMessage();
+ EntityEncoder entityEncoder = EntityEncoder.FULL;
+ println entityEncoder.encode(msgValue);
+ println " </span>";
+ println " </li>";
+ }
+ println " </ul>";
+ return isSelected;
}
%>
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIFormLifecycle.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIFormLifecycle.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIFormLifecycle.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -117,7 +117,6 @@
if (context.getProcessRender())
{
- context.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
return;
}
event.broadcast();
Modified:
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java
===================================================================
---
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -51,11 +51,13 @@
public static String GADGET_POPUP_ID = "UIAddGadgetPopup";
+ public static String APP_NOT_EXIST = "APP_NOT_EXIT";
+
private boolean isShowSelectPopup = false;
private String aggregatorId;
- private UIGadget maximizedGadget;
+ private UIGadget maximizedGadget;
public UIDashboard() throws Exception
{
@@ -70,14 +72,10 @@
UIGadget uiGadget = this.getMaximizedGadget();
if (uiGadget != null)
{
- UIPopupMessages uiPopupMessages =
getAncestorOfType(UIPortletApplication.class).getUIPopupMessages();
- for (ApplicationMessage msg : uiPopupMessages.getErrors())
+ if (context.getAttribute(APP_NOT_EXIST) != null ||
+ context.getAttribute(UIGadget.SAVE_PREF_FAIL) != null)
{
- if
(msg.getMessageKey().equals("UIDashboard.msg.ApplicationNotExisted"))
- {
- this.setMaximizedGadget(null);
- break;
- }
+ this.setMaximizedGadget(null);
}
}
@@ -168,13 +166,14 @@
{
UIPortalApplication uiApp = Util.getUIPortalApplication();
uiApp.addMessage(new
ApplicationMessage("UIDashboard.msg.ApplicationNotExisted", null));
+ context.setAttribute(APP_NOT_EXIST, true);
context.addUIComponentToUpdateByAjax(uiDashboard);
}
else
{
uiGadget.getProperties().setProperty("minimized", minimized);
uiDashboardCont.save();
- if
(uiDashboard.getAncestorOfType(UIPortletApplication.class).getUIPopupMessages().hasMessage())
+ if (context.getAttribute(UIDashboardContainer.SAVE_FAIL) != null)
{
return;
}
@@ -197,6 +196,7 @@
{
UIPortalApplication uiApp = Util.getUIPortalApplication();
uiApp.addMessage(new
ApplicationMessage("UIDashboard.msg.ApplicationNotExisted", null));
+ context.setAttribute(APP_NOT_EXIST, true);
context.addUIComponentToUpdateByAjax(uiDashboard);
return;
}
@@ -207,9 +207,8 @@
uiGadget.getProperties().setProperty("minimized", "false");
uiDashboardCont.save();
- UIPortletApplication uiDashboarPortlet =
uiDashboard.getAncestorOfType(UIPortletApplication.class);
if (maximize.equals("maximize")
- && !uiDashboarPortlet.getUIPopupMessages().hasMessage())
+ && context.getAttribute(UIDashboardContainer.SAVE_FAIL) == null)
{
uiGadget.setView(UIGadget.CANVAS_VIEW);
uiDashboard.setMaximizedGadget(uiGadget);
Modified:
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java
===================================================================
---
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -92,6 +92,8 @@
public static final String COLINDEX = "colIndex";
public static final String ROWINDEX = "rowIndex";
+
+ public static String SAVE_FAIL = "UIDashboardContainer.saveFail";
/**
* Constructs new UIDashboardContainer which belongs to a UIDashboardPortlet
@@ -490,8 +492,10 @@
}
catch (StaleModelException e)
{
- getAncestorOfType(UIPortletApplication.class).addMessage(
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ context.getUIApplication().addMessage(
new ApplicationMessage("UIDashboard.msg.StaleData", null,
ApplicationMessage.ERROR));
+ context.setAttribute(SAVE_FAIL, true);
}
}
}
@@ -517,6 +521,7 @@
{
UIApplication uiApplication = context.getUIApplication();
uiApplication.addMessage(new
ApplicationMessage("UIDashboard.msg.ApplicationNotExisted", null));
+ context.setAttribute(UIDashboard.APP_NOT_EXIST, true);
return;
}
UIGadget uiGadget = event.getSource().createUIComponent(context, UIGadget.class,
null, null);
@@ -546,7 +551,7 @@
uiDashboardContainer.moveUIGadget(objectId, col, row);
uiDashboardContainer.save();
- if
(uiDashboard.getAncestorOfType(UIPortletApplication.class).getUIPopupMessages().hasMessage())
+ if (context.getAttribute(SAVE_FAIL) != null)
{
return;
}
@@ -577,9 +582,7 @@
isMaximized = true;
}
uiDashboardContainer.save();
- UIPopupMessages uiPopupMessages =
-
uiDashboard.getAncestorOfType(UIPortletApplication.class).getUIPopupMessages();
- if (!isMaximized && !uiPopupMessages.hasMessage())
+ if (!isMaximized && context.getAttribute(SAVE_FAIL) == null)
{
Util.getPortalRequestContext().setResponseComplete(true);
}
Modified:
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIGroupSelector.java
===================================================================
---
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIGroupSelector.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIGroupSelector.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -197,7 +197,6 @@
{
UIApplication uiApp = pcontext.getUIApplication();
uiApp.addMessage(new
ApplicationMessage("UIGroupSelector.msg.selectGroup", null));
- pcontext.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
uiPopup.setShow(true);
return;
}
Modified:
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java
===================================================================
---
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -336,7 +336,6 @@
{
UIApplication uiApp = uiForm.getAncestorOfType(UIApplication.class);
uiApp.addMessage(new
ApplicationMessage("UIUserSelector.msg.user-required", null));
-
event.getRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
return;
}
String[] arrItems = items.toArray(new String[items.size()]);
Modified:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -46,9 +46,7 @@
private static final String UIAPPLICATION = "uiapplication";
public UIApplication() throws Exception
- {
- uiPopupMessages_ = createUIComponent(UIPopupMessages.class, null, null);
- uiPopupMessages_.setId("_" + uiPopupMessages_.hashCode());
+ {
}
//TODO this looks like not to be used anymore
@@ -65,11 +63,22 @@
/**
* Return the common UIPopupMessages
- * UIPortletApplication will override this method an return difference UIPopupMessage
for difference Portlet modes
* @return UIPopupMessages
*/
public UIPopupMessages getUIPopupMessages()
{
+ if (uiPopupMessages_ == null)
+ {
+ try
+ {
+ uiPopupMessages_ = createUIComponent(UIPopupMessages.class, null, null);
+ uiPopupMessages_.setId("_" + uiPopupMessages_.hashCode());
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
return uiPopupMessages_;
}
@@ -123,13 +132,13 @@
}
catch (MessageException ex)
{
- getUIPopupMessages().addMessage(ex.getDetailMessage());
+ addMessage(ex.getDetailMessage());
}
catch (Throwable t)
{
ApplicationMessage msg =
new ApplicationMessage("UIApplication.msg.unknown-error", null,
ApplicationMessage.ERROR);
- uiPopupMessages_.addMessage(msg);
+ addMessage(msg);
log.error("Error during the processAction phase", t);
}
}
Modified:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -20,6 +20,7 @@
package org.exoplatform.webui.core;
import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.web.application.RequestContext;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -29,6 +30,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.ResourceBundle;
/**
* Created by The eXo Platform SARL
@@ -104,6 +106,7 @@
public void addMessage(ApplicationMessage msg)
{
+ msg.setResourceBundle(getResourceBundle());
switch (msg.getType())
{
case ApplicationMessage.ERROR :
@@ -116,6 +119,16 @@
infos_.add(msg);
}
}
+
+ private ResourceBundle getResourceBundle()
+ {
+ RequestContext context = RequestContext.getCurrentInstance();
+ if (context == null)
+ {
+ return null;
+ }
+ return context.getApplicationResourceBundle();
+ }
public boolean hasMessage()
{
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -1,62 +0,0 @@
-/******************************************************************************
- * JBoss by Red Hat *
- * Copyright 2010, 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.exoplatform.portal.webui;
-
-import java.util.Calendar;
-
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.form.UIFormStringInput;
-
-import javax.portlet.RenderResponse;
-import javax.portlet.ResourceURL;
-
-/**
- * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
- * @version $Revision$
- */
-public class UICaptcha extends UIFormStringInput
-{
-
- public UICaptcha(String name, String bindingExpression, String value)
- {
- super(name, bindingExpression, value);
- }
-
- public void processRender(WebuiRequestContext context) throws Exception
- {
-
- RenderResponse resp = context.getResponse();
-
- //
- ResourceURL url = resp.createResourceURL();
-
- // context.getPortalContextPath() + "/captcha?v=" +
Calendar.getInstance().getTimeInMillis()
-
- String random = "&v=" + Calendar.getInstance().getTimeInMillis();
-
- context.getWriter().write("<div id='" + getId() +
"'><img src=\"" + url.toString() + random + "\"
/><br/>");
- super.processRender(context);
- context.getWriter().write("</div>");
- }
-
-}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -105,6 +105,8 @@
public static final String METADATA_USERPREFS_TYPE_LIST = "list";
public String view = HOME_VIEW;
+
+ public static String SAVE_PREF_FAIL = "UIGadget.savePrefFail";
/**
* Initializes a newly created <code>UIGadget</code> object
@@ -438,6 +440,7 @@
{
UIPortletApplication uiPortlet =
uiGadget.getAncestorOfType(UIPortletApplication.class);
context.addUIComponentToUpdateByAjax(uiPortlet);
+ context.setAttribute(UIGadget.SAVE_PREF_FAIL, true);
throw new MessageException(new
ApplicationMessage("UIDashboard.msg.ApplicationNotExisted", null,
ApplicationMessage.ERROR));
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -203,7 +203,6 @@
{
UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
uiApp.addMessage(new ApplicationMessage("UISearchForm.msg.empty",
null));
-
Util.getPortalRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
}
public void quickSearch(UIFormInputSet quickSearchInput) throws Exception
@@ -270,7 +269,6 @@
if (service.getPage(id) == null)
{
uiApp.addMessage(new
ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{id}, 1));
- context.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
return;
}
Page page = service.getPage(id, context.getRemoteUser());
@@ -279,7 +277,6 @@
(page.getOwnerType().equals(SiteType.USER.getName()) &&
!page.getOwnerId().equals(context.getRemoteUser())))
{
uiApp.addMessage(new
ApplicationMessage("UIPageBrowser.msg.delete.NotDelete", new String[]{id}, 1));
- context.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
return;
}
@@ -396,7 +393,6 @@
if (page == null)
{
uiPortalApp.addMessage(new
ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{id}, 1));
- context.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
return;
}
@@ -405,7 +401,6 @@
if (!userACL.hasEditPermission(page))
{
uiPortalApp.addMessage(new
ApplicationMessage("UIPageBrowser.msg.edit.NotEditPage", new String[]{id}, 1));
- context.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
return;
}
@@ -464,7 +459,6 @@
if (existPage != null)
{
uiPortalApp.addMessage(new
ApplicationMessage("UIPageForm.msg.sameName", null));
- pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
return;
}
page.setModifiable(true);
Modified:
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java
===================================================================
---
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java 2011-10-26
02:46:46 UTC (rev 7876)
+++
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java 2011-10-26
02:47:15 UTC (rev 7877)
@@ -19,28 +19,24 @@
package org.exoplatform.webui.core;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.application.WebuiApplication;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
+
import java.io.Writer;
-import java.util.Map;
import java.util.Set;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.WindowState;
-import org.apache.commons.collections.map.HashedMap;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.exoplatform.webui.application.WebuiApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.application.portlet.PortletRequestContext;
-
@Serialized
abstract public class UIPortletApplication extends UIApplication
{
private int minWidth = 300;
- private int minHeight = 300;
-
- private Map<String, UIPopupMessages> _uiPopupMessages;
+ private int minHeight = 300;
static public String VIEW_MODE = "ViewMode";
@@ -52,29 +48,14 @@
public UIPortletApplication() throws Exception
{
- _uiPopupMessages = new HashedMap();
}
@Override
public UIPopupMessages getUIPopupMessages()
{
- PortletRequestContext pContext =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
- String currMode = pContext.getApplicationMode().toString();
-
- if (!_uiPopupMessages.containsKey(currMode)) {
- try
- {
- UIPopupMessages popMsg = createUIComponent(UIPopupMessages.class, null,
null);
- popMsg.setId("_" + popMsg.hashCode());
- _uiPopupMessages.put(currMode, popMsg);
- }
- catch (Exception e)
- {
- return null;
- }
- }
-
- return _uiPopupMessages.get(currMode);
+ WebuiRequestContext context = PortletRequestContext.getCurrentInstance();
+ WebuiRequestContext portalContext =
(WebuiRequestContext)context.getParentAppRequestContext();
+ return portalContext.getUIApplication().getUIPopupMessages();
}
@Deprecated
@@ -101,6 +82,14 @@
this.minHeight = minHeight;
}
+ //
+ @Override
+ public void renderChildren() throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ super.renderChildren(context);
+ }
+
/**
* The default processRender for an UIPortletApplication does nothing if the current
WindowState in the
* render request is MINIMIZED. Otherwise, it handles two cases:
@@ -136,8 +125,6 @@
// if(list == null) list = app.getDefaultUIComponentToUpdateByAjax(context)
;
if (list != null)
{
- if (getUIPopupMessages().hasMessage())
- context.addUIComponentToUpdateByAjax(getUIPopupMessages());
for (UIComponent uicomponent : list)
{
renderBlockToUpdate(uicomponent, context, w);