Author: chris.laprun(a)jboss.com
Date: 2007-06-21 18:12:43 -0400 (Thu, 21 Jun 2007)
New Revision: 7509
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/JSFBeanContext.java
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
Log:
- Delegated error handling and parameter retrieval methods from ConsumerBean to new
BeanContext class to allow behavior to be JSF-independent. This allows for testing of JSF
managed beans outside of a JSF environment.
- Improved ConsumerBean handling of modified state. Correct handling will require a new
value change event listener which might not be the right way to go (i.e. is that level of
complexity required in terms of 80/20).
- Added JSFBeanContext to implement BeanContext in a JSF context.
- Updated faces-config to use BeanContext.
- Added ConsumerBeanTestCase.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-06-21 18:09:48 UTC (rev 7508)
+++ trunk/wsrp/build.xml 2007-06-21 22:12:43 UTC (rev 7509)
@@ -821,7 +821,8 @@
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.UserContextConverterTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.RegistrationPropertyDescriptionTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.ConsumerBeanTestCase"/>
</x-test>
<x-sysproperty>
<!--<jvmarg value="-Xdebug"/>
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-06-21
18:09:48 UTC (rev 7508)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-06-21
22:12:43 UTC (rev 7509)
@@ -45,16 +45,23 @@
private Map consumers = new HashMap(3);
public static final String MOCK_SERVICE_DESCRIPTION =
"mock-service-description";
public static final String MOCK_MARKUP = "mock-markup";
+ public static final String CONSUMER1 = "inDB";
+ public static final String CONSUMER2 = "inDB2";
+ /**
+ * Creates a ConsumerRegistry containing 2 consumers with id '{@link
#CONSUMER1}' and '{@link #CONSUMER2}'
+ * respectively. CONSUMER2 is active and has a service description URL set to {@link
#MOCK_SERVICE_DESCRIPTION} and a
+ * markup URL set to {@link #MOCK_MARKUP}
+ */
public MockConsumerRegistry()
{
- consumers.put("inDB", new MockWSRPConsumer("inDB"));
- MockWSRPConsumer consumer = new MockWSRPConsumer("inDB2");
+ consumers.put(CONSUMER1, new MockWSRPConsumer(CONSUMER1));
+ MockWSRPConsumer consumer = new MockWSRPConsumer(CONSUMER2);
consumer.getProducerInfo().setActive(true);
EndpointConfigurationInfo info =
consumer.getProducerInfo().getEndpointConfigurationInfo();
info.setServiceDescriptionURL(MOCK_SERVICE_DESCRIPTION);
info.setMarkupURL(MOCK_MARKUP);
- consumers.put("inDB2", consumer);
+ consumers.put(CONSUMER2, consumer);
}
public Collection getConfiguredConsumers()
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java 2007-06-21
22:12:43 UTC (rev 7509)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.jboss.portal.test.wsrp.other;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
+import org.jboss.portal.wsrp.admin.ui.BeanContext;
+import org.jboss.portal.wsrp.admin.ui.ConsumerBean;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerBeanTestCase extends TestCase
+{
+ private ConsumerBean bean;
+
+ protected void setUp() throws Exception
+ {
+ bean = new ConsumerBean();
+ bean.setRegistry(new MockConsumerRegistry());
+
+ // consumer associated with bean is null at this point so it should be loaded from
the registry
+ bean.setId(MockConsumerRegistry.CONSUMER2);
+ }
+
+ public void testInitialState()
+ {
+ assertEquals(MockConsumerRegistry.CONSUMER2, bean.getId());
+ assertEquals(MockConsumerRegistry.MOCK_MARKUP, bean.getMarkup());
+ assertEquals(MockConsumerRegistry.MOCK_SERVICE_DESCRIPTION,
bean.getServiceDescription());
+ assertFalse(bean.isModified());
+ }
+
+ public void testSetId()
+ {
+ String newId = "newId";
+ bean.setId(newId);
+ assertEquals(newId, bean.getId());
+ assertTrue(bean.isModified());
+ }
+
+ public void testSetCache()
+ {
+ bean.setCache(new Integer(300));
+ assertEquals(300, bean.getCache().intValue());
+ assertTrue(bean.isModified());
+ }
+
+ private static class TestBeanContext extends BeanContext
+ {
+ protected String getParameter(String key)
+ {
+ throw new NotYetImplemented();
+ }
+
+ protected void createMessage(String target, String message, Object severity)
+ {
+ // ignore for tests
+ }
+
+ protected Object getErrorSeverity()
+ {
+ return null;
+ }
+
+ protected Object getInfoSeverity()
+ {
+ return null;
+ }
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java
(rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java 2007-06-21
22:12:43 UTC (rev 7509)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.jboss.portal.wsrp.admin.ui;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public abstract class BeanContext
+{
+ protected abstract String getParameter(String key);
+
+ protected abstract void createMessage(String target, String message, Object
severity);
+
+ protected abstract Object getErrorSeverity();
+
+ protected abstract Object getInfoSeverity();
+
+ protected void createErrorMessage(String message)
+ {
+ createMessage(null, message, getErrorSeverity());
+ }
+
+ protected void createErrorMessage(String target, String message)
+ {
+ createMessage(target, message, getErrorSeverity());
+ }
+
+ protected void createErrorMessageFrom(Exception e)
+ {
+ createErrorMessageFrom(null, e);
+ }
+
+ protected void createErrorMessageFrom(String target, Exception e)
+ {
+ Throwable cause = e.getCause();
+ String localizedMessage = getLocalizedMessageOrExceptionName(e);
+ String message = localizedMessage + (cause != null ? "\nCause: " +
getLocalizedMessageOrExceptionName(cause) : "");
+ createErrorMessage(target, message);
+ }
+
+ private String getLocalizedMessageOrExceptionName(Throwable e)
+ {
+ String localizedMessage = e.getLocalizedMessage();
+ if (localizedMessage == null)
+ {
+ localizedMessage = "An unexpected error occured: " +
e.getClass().getName();
+ }
+ return localizedMessage;
+ }
+
+ protected void createInfoMessage(String target, String message)
+ {
+ createMessage(target, message, getInfoSeverity());
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-06-21
18:09:48 UTC (rev 7508)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-06-21
22:12:43 UTC (rev 7509)
@@ -67,7 +67,7 @@
public boolean isModified()
{
- return modified;
+ return modified || registrationModified;
}
public boolean isUseWSDL()
@@ -99,16 +99,19 @@
{
if (consumer != null)
{
- getProducerInfo().setId(id);
+ ProducerInfo info = getProducerInfo();
+ String oldId = info.getId();
+ info.setId((String)modifyIfNeeded(oldId, id, "id", false));
}
else
{
consumer = registry.getConsumer(id);
- serviceDescription =
getProducerInfo().getEndpointConfigurationInfo().getServiceDescriptionURL();
- markup = getProducerInfo().getEndpointConfigurationInfo().getMarkupURL();
- portletManagement =
getProducerInfo().getEndpointConfigurationInfo().getPortletManagementURL();
- registration =
getProducerInfo().getEndpointConfigurationInfo().getRegistrationURL();
- wsdl = getProducerInfo().getEndpointConfigurationInfo().getWsdlDefinitionURL();
+ EndpointConfigurationInfo endpoint =
getProducerInfo().getEndpointConfigurationInfo();
+ serviceDescription = endpoint.getServiceDescriptionURL();
+ markup = endpoint.getMarkupURL();
+ portletManagement = endpoint.getPortletManagementURL();
+ registration = endpoint.getRegistrationURL();
+ wsdl = endpoint.getWsdlDefinitionURL();
}
}
@@ -119,7 +122,7 @@
public void setCache(Integer cache)
{
- getProducerInfo().setExpirationCacheSeconds(cache);
+ getProducerInfo().setExpirationCacheSeconds((Integer)modifyIfNeeded(getCache(),
cache, "cache", false));
}
public String getServiceDescription()
@@ -129,7 +132,7 @@
public void setServiceDescription(String sdURL)
{
- serviceDescription = modifyIfNeeded(serviceDescription, sdURL, "sd");
+ serviceDescription = (String)modifyIfNeeded(serviceDescription, sdURL,
"sd", true);
}
public String getMarkup()
@@ -139,7 +142,7 @@
public void setMarkup(String markupURL)
{
- markup = modifyIfNeeded(markup, markupURL, "m");
+ markup = (String)modifyIfNeeded(markup, markupURL, "m", true);
}
public String getPortletManagement()
@@ -149,7 +152,7 @@
public void setPortletManagement(String pmURL)
{
- portletManagement = modifyIfNeeded(portletManagement, pmURL, "pm");
+ portletManagement = (String)modifyIfNeeded(portletManagement, pmURL,
"pm", true);
}
public String getRegistration()
@@ -159,7 +162,7 @@
public void setRegistration(String rURL)
{
- registration = modifyIfNeeded(registration, rURL, "r");
+ registration = (String)modifyIfNeeded(registration, rURL, "r", true);
}
public String getWsdl()
@@ -169,7 +172,7 @@
public void setWsdl(String wsdlURL)
{
- wsdl = modifyIfNeeded(wsdl, wsdlURL, "wsdl");
+ wsdl = (String)modifyIfNeeded(wsdl, wsdlURL, "wsdl", true);
}
private void internalSetWsdl(String wsdlURL)
@@ -181,7 +184,7 @@
catch (Exception e)
{
registry.deactivateConsumerWith(getId());
- createErrorMessageFrom("wsdl", e);
+ beanContext.createErrorMessageFrom("wsdl", e);
}
}
@@ -269,14 +272,14 @@
}
catch (Exception e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
return null;
}
return manager.listConsumers();
}
- createErrorMessage("Couldn't update Consumer!");
+ beanContext.createErrorMessage("Couldn't update Consumer!");
return null;
}
@@ -298,31 +301,31 @@
{
if (consumer != null)
{
- String param = getParameter("mergeLocalInfo");
+ String param = beanContext.getParameter("mergeLocalInfo");
boolean mergeLocalInfo = Boolean.valueOf(param).booleanValue();
try
{
RefreshResult result =
getProducerInfo().refreshRegistrationInfo(mergeLocalInfo);
if (result.hasIssues())
{
- createErrorMessage(result.getStatus());
+ beanContext.createErrorMessage(result.getStatus());
}
else
{
- createInfoMessage(null, result.getStatus());
+ beanContext.createInfoMessage(null, result.getStatus());
}
registrationModified = false;
}
catch (Exception e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
return null;
}
return null;
}
- createErrorMessage("Couldn't refresh Registration info!");
+ beanContext.createErrorMessage("Couldn't refresh Registration
info!");
return null;
}
@@ -333,42 +336,40 @@
try
{
getProducerInfo().modifyRegistration();
- createInfoMessage(null, "Successfully modified Registration!");
+ beanContext.createInfoMessage(null, "Successfully modified
Registration!");
registrationModified = false;
}
catch (Exception e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
return null;
}
return null;
}
- createErrorMessage("Couldn't modify Registration!");
+ beanContext.createErrorMessage("Couldn't modify Registration!");
return null;
}
- private String modifyIfNeeded(String oldValue, String newValue, String target)
+ private Object modifyIfNeeded(Object oldValue, Object newValue, String target, boolean
checkURL)
{
if ((oldValue != null && !oldValue.equals(newValue)) || (oldValue == null
&& newValue != null))
{
- URL url;
- try
+ if (checkURL)
{
- // check that the new value is a valid URL
- url = new URL(newValue);
+ try
+ {
+ // check that the new value is a valid URL
+ new URL(newValue.toString());
+ }
+ catch (MalformedURLException e)
+ {
+ beanContext.createErrorMessage(target, "'" + newValue +
"' is not a valid URL: " + e.getLocalizedMessage());
+ }
+ }
- oldValue = newValue;
- modified = true;
- }
- catch (MalformedURLException e)
- {
- createErrorMessage(target, "'" + newValue + "' is not
a valid URL: " + e.getLocalizedMessage());
- }
- finally
- {
- url = null;
- }
+ oldValue = newValue;
+ modified = true;
}
return oldValue;
@@ -378,7 +379,7 @@
public void useWSDLListener(ValueChangeEvent event)
{
- useWSDL = (Boolean)event.getNewValue();
+ useWSDL = (Boolean)modifyIfNeeded(useWSDL, event.getNewValue(), "wsdl",
false);
// bypass the rest of the life cycle and re-display page
FacesContext.getCurrentInstance().renderResponse();
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-06-21
18:09:48 UTC (rev 7508)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-06-21
22:12:43 UTC (rev 7509)
@@ -82,7 +82,7 @@
{
if (refreshConsumerId() != null)
{
- boolean activate =
Boolean.valueOf(getParameter("activate")).booleanValue();
+ boolean activate =
Boolean.valueOf(beanContext.getParameter("activate")).booleanValue();
try
{
if (activate)
@@ -108,7 +108,7 @@
}
catch (Exception e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
}
return listConsumers();
@@ -124,7 +124,7 @@
{
if (refreshConsumerId() != null)
{
- boolean register =
Boolean.valueOf(getParameter("register")).booleanValue();
+ boolean register =
Boolean.valueOf(beanContext.getParameter("register")).booleanValue();
try
{
@@ -135,7 +135,7 @@
}
catch (Exception e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
return null;
}
}
@@ -158,13 +158,13 @@
}
catch (Exception e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
return null;
}
}
else
{
- createErrorMessage("Need a non-null, non-empty name for the new
Consumer");
+ beanContext.createErrorMessage("Need a non-null, non-empty name for the new
Consumer");
return null;
}
}
@@ -180,7 +180,7 @@
}
catch (Exception e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
return null;
}
}
@@ -227,17 +227,17 @@
RefreshResult result = consumer.refresh(true);
if (result.hasIssues())
{
- createErrorMessage(result.getStatus());
+ beanContext.createErrorMessage(result.getStatus());
}
else
{
- createInfoMessage(null, result.getStatus());
+ beanContext.createInfoMessage(null, result.getStatus());
}
return result;
}
catch (PortletInvokerException e)
{
- createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom(e);
return null;
}
}
@@ -251,7 +251,7 @@
private String refreshConsumerId()
{
- selectedId = getParameter("id");
+ selectedId = beanContext.getParameter("id");
return selectedId;
}
@@ -273,6 +273,6 @@
private void noSelectedConsumerError()
{
- createErrorMessage("No Consumer was selected!");
+ beanContext.createErrorMessage("No Consumer was selected!");
}
}
\ No newline at end of file
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/JSFBeanContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/JSFBeanContext.java
(rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/JSFBeanContext.java 2007-06-21
22:12:43 UTC (rev 7509)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.jboss.portal.wsrp.admin.ui;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class JSFBeanContext extends BeanContext
+{
+ protected String getParameter(String key)
+ {
+ Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ return (String)pmap.get(key);
+ }
+
+ protected void createMessage(String target, String message, Object severity)
+ {
+ FacesMessage.Severity jsfSeverity;
+ if (severity instanceof FacesMessage.Severity)
+ {
+ jsfSeverity = (FacesMessage.Severity)severity;
+ }
+ else
+ {
+ jsfSeverity = FacesMessage.SEVERITY_ERROR;
+ }
+
+ FacesMessage msg = new FacesMessage(jsfSeverity, message, message);
+ FacesContext.getCurrentInstance().addMessage(target, msg);
+ }
+
+ protected Object getErrorSeverity()
+ {
+ return FacesMessage.SEVERITY_ERROR;
+ }
+
+ protected Object getInfoSeverity()
+ {
+ return FacesMessage.SEVERITY_INFO;
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/JSFBeanContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java 2007-06-21
18:09:48 UTC (rev 7508)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java 2007-06-21
22:12:43 UTC (rev 7509)
@@ -23,10 +23,6 @@
package org.jboss.portal.wsrp.admin.ui;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-import java.util.Map;
-
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
@@ -34,53 +30,10 @@
*/
public class ManagedBean
{
- protected String getParameter(String key)
- {
- Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
- return (String)pmap.get(key);
- }
+ protected BeanContext beanContext;
- protected void createErrorMessage(String message)
+ public void setBeanContext(BeanContext beanContext)
{
- createMessage(null, message, FacesMessage.SEVERITY_ERROR);
+ this.beanContext = beanContext;
}
-
- protected void createErrorMessage(String target, String message)
- {
- createMessage(target, message, FacesMessage.SEVERITY_ERROR);
- }
-
- protected void createMessage(String target, String message, FacesMessage.Severity
severity)
- {
- FacesMessage msg = new FacesMessage(severity, message, message);
- FacesContext.getCurrentInstance().addMessage(target, msg);
- }
-
- protected void createErrorMessageFrom(Exception e)
- {
- createErrorMessageFrom(null, e);
- }
-
- protected void createErrorMessageFrom(String target, Exception e)
- {
- Throwable cause = e.getCause();
- String localizedMessage = getLocalizedMessageOrExceptionName(e);
- String message = localizedMessage + (cause != null ? "\nCause: " +
getLocalizedMessageOrExceptionName(cause) : "");
- createErrorMessage(target, message);
- }
-
- private String getLocalizedMessageOrExceptionName(Throwable e)
- {
- String localizedMessage = e.getLocalizedMessage();
- if (localizedMessage == null)
- {
- localizedMessage = "An unexpected error occured: " +
e.getClass().getName();
- }
- return localizedMessage;
- }
-
- protected void createInfoMessage(String target, String message)
- {
- createMessage(target, message, FacesMessage.SEVERITY_INFO);
- }
}
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml 2007-06-21 18:09:48
UTC (rev 7508)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml 2007-06-21 22:12:43
UTC (rev 7509)
@@ -33,6 +33,11 @@
</application>
<managed-bean>
+ <managed-bean-name>beanContext</managed-bean-name>
+
<managed-bean-class>org.jboss.portal.wsrp.admin.ui.JSFBeanContext</managed-bean-class>
+ <managed-bean-scope>application</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>consumersMgr</managed-bean-name>
<managed-bean-class>org.jboss.portal.wsrp.admin.ui.ConsumerManagerBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
@@ -41,6 +46,11 @@
<property-class>org.jboss.portal.wsrp.consumer.ConsumerRegistry</property-class>
<value>#{applicationScope.ConsumerRegistry}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+
<property-class>org.jboss.portal.wsrp.admin.ui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>consumer</managed-bean-name>
@@ -59,6 +69,11 @@
<property-name>manager</property-name>
<value>#{consumersMgr}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+
<property-class>org.jboss.portal.wsrp.admin.ui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
<navigation-rule>