Author: chris.laprun(a)jboss.com
Date: 2009-06-23 18:41:14 -0400 (Tue, 23 Jun 2009)
New Revision: 13494
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
Log:
- JBPORTAL-2428: Now properly validates inputs (including WSDL URL that wasn't
properly validated by URL constructor due to a Java bug).
- JSFBeanContext now provides renderResponseImmediately method to bypass further
processing in case of an error.
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2009-06-23
22:11:58 UTC (rev 13493)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2009-06-23
22:41:14 UTC (rev 13494)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.admin.ui;
+import org.jboss.portal.faces.gui.JSFBeanContext;
import org.jboss.portal.faces.gui.ManagedBean;
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
@@ -32,10 +33,9 @@
import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.portal.wsrp.consumer.RegistrationProperty;
-import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -139,6 +139,10 @@
// we're not using modifyIfNeeded here to avoid double equality check,
so we need to set modified manually
modified = true;
}
+ else
+ {
+ JSFBeanContext.renderResponseImmediately();
+ }
}
}
else
@@ -527,6 +531,9 @@
private Object modifyIfNeeded(Object oldValue, Object newValue, String target, boolean
checkURL)
{
+ // prepend form id to target
+ target = "edit-cons-form:" + target;
+
if (isOldAndNewDifferent(oldValue, newValue))
{
if (checkURL)
@@ -534,13 +541,22 @@
try
{
// check that the new value is a valid URL
- new URL(newValue.toString());
+ new URI(newValue.toString());
}
- catch (MalformedURLException e)
+ catch (URISyntaxException e)
{
beanContext.createTargetedErrorMessage(target, MALFORMED_URL, newValue,
e.getLocalizedMessage());
+ JSFBeanContext.renderResponseImmediately();
}
}
+ else
+ {
+ String newStringValue = checkValidity(newValue.toString(), target);
+ if (newStringValue == null)
+ {
+ JSFBeanContext.renderResponseImmediately();
+ }
+ }
oldValue = newValue;
modified = true;
@@ -555,8 +571,7 @@
{
useWSDL = (Boolean)modifyIfNeeded(useWSDL, event.getNewValue(), "wsdl",
false);
- // bypass the rest of the life cycle and re-display page
- FacesContext.getCurrentInstance().renderResponse();
+ JSFBeanContext.renderResponseImmediately();
}
// todo: valueChangeListener not needed anymore when events on RegistrationProperties
work
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java 2009-06-23
22:11:58 UTC (rev 13493)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java 2009-06-23
22:41:14 UTC (rev 13494)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.admin.ui;
+import org.jboss.portal.faces.gui.JSFBeanContext;
import org.jboss.portal.faces.gui.ManagedBean;
import org.jboss.portal.registration.RegistrationPolicy;
import org.jboss.portal.registration.policies.DefaultRegistrationPolicy;
@@ -31,7 +32,6 @@
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
-import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
@@ -281,8 +281,7 @@
{
setRegistrationRequired((Boolean)event.getNewValue());
- // bypass the rest of the life cycle and re-display page
- FacesContext.getCurrentInstance().renderResponse();
+ JSFBeanContext.renderResponseImmediately();
}
public void selectProperty(ActionEvent event)
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-06-23
22:11:58 UTC (rev 13493)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-06-23
22:41:14 UTC (rev 13494)
@@ -147,4 +147,10 @@
{
return FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
}
+
+ /** Bypasses the rest of the life cycle and re-displays page immediately. Useful for
error reporting. */
+ public static void renderResponseImmediately()
+ {
+ FacesContext.getCurrentInstance().renderResponse();
+ }
}
Show replies by date