M src/javax/faces/webapp/UIComponentTag.java
Fix ClassCastExcpetion that happens when two JSF portlets are deployed
in the same page.
Here is why the exception happens. One portlet(webapp) stores a
UIComponent instance in request and dispatches the request to another
portlet(webapp),that tries to retrieve it from the request. Since each
portlet bundles its own JSF jar, the classloaders are different. So when
the second portlet tries to cast the instance set by the first portlet
to UIComponent,ClassCastException is thrown.If the webapps already
sharing a JSF jar that is bundles in the container, this problem will
not occur. The fix is to get UIViewRoot from FacesContext instead of
looking up request scope. API, RI unit tests and demos run.
Index: src/javax/faces/webapp/UIComponentTag.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/webapp/UIComponentTag.java,v
retrieving revision 1.51
diff -u -r1.51 UIComponentTag.java
--- src/javax/faces/webapp/UIComponentTag.java 31 Aug 2004 19:50:19 -0000 1.51
+++ src/javax/faces/webapp/UIComponentTag.java 12 Oct 2004 18:01:01 -0000
@@ -692,39 +692,30 @@
if (parentTag != null) {
parentComponent = parentTag.getComponentInstance();
} else {
- //
// Special case. The component to be found is the
// UIViewRoot.
- //
-
// see if this is the first time this tag instance is trying
// to be bound to the UIViewRoot
- if (null == (parentComponent = (UIComponent)
- pageContext.getAttribute(CURRENT_VIEW_ROOT,
- PageContext.REQUEST_SCOPE))){
- parentComponent = context.getViewRoot();
- pageContext.setAttribute(CURRENT_VIEW_ROOT, parentComponent,
- PageContext.REQUEST_SCOPE);
- // Has this UIViewRoot instance had a tag bound to it
- // before?
- if (null ==
- parentComponent.getAttributes().get(CURRENT_VIEW_ROOT)) {
- // No it hasn't.
-
- // make sure setProperties() and setId() are called
- // once per UIViewRoot instance.
- setProperties(parentComponent);
- if (null != this.id) {
- parentComponent.setId(this.id);
- }
- parentComponent.getAttributes().put(CURRENT_VIEW_ROOT,
- CURRENT_VIEW_ROOT);
- }
- else if (binding == null) {
- setProperties(parentComponent);
- }
+ parentComponent = context.getViewRoot();
+ // Has this UIViewRoot instance had a tag bound to it
+ // before?
+ if (null ==
+ parentComponent.getAttributes().get(CURRENT_VIEW_ROOT)) {
+ // No it hasn't.
+
+ // make sure setProperties() and setId() are called
+ // once per UIViewRoot instance.
+ setProperties(parentComponent);
+ if (null != this.id) {
+ parentComponent.setId(this.id);
+ }
+ parentComponent.getAttributes().put(CURRENT_VIEW_ROOT,
+ CURRENT_VIEW_ROOT);
+ }
+ else if (binding == null) {
+ setProperties(parentComponent);
+ }
- }
// this is not the first time this tag instance is trying to
// be bound to this UIViewRoot, take no extra action.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net