I've written a simple custom component (tag class, component class, renderer class), that works fine as long as the page where it's used is being "called" obeying a navigation rule. If no navigation rule is found, i.e. the general "go to where you came from" rule applies, it fails.
Normally, the tag's setProperties() will be called to pass the tag's attribute values to the component (that is in turn being used by the renderer). However, without a navigation rule, setProperties() isn't called.
I'm not 100% sure why this happens, but this is what I've come up so far: (my tag is a direct child of <f:view>)
In the case where a navigation rule is found:
1. A new instance of UIViewRoot is created through TreeStructureManager.internalRestoreTreeStructure()
2. A number of instances of my component class are created by the same method
3. A new instance of UIViewRoot is created through ApplicationImpl.createComponent()
4. doStartTag() is called on my tag
- the parent component is that created in step 3
5. An instances of my component class is created in findComponent() and setProperties() is called with that component as the parameter.
Note, the objects created in step 1. and 2. don't seem to be used. That looks a bit odd to me.
In the case where no navigation rule is found, I get:
1. as above, 2. as above
3. doStartTag() is called on my tag
- now the parent component is that created in step 1
4. findComponent() now finds the component instance created in step 2. and doesn't call setProperties() anymore.
I can fix this with the attached patch. It basically just calls setProperties() always regardless of if the component has just been created or not. I'm not sure though, if setProperties() is allowed to be called more than once and if all component implementations can deal with that.
Regards, Nicolas
Index: src/jsfapi/javax/faces/webapp/UIComponentTag.java
===================================================================
RCS file: /home/cvspublic/incubator-myfaces/src/jsfapi/javax/faces/webapp/UIComponentTag.java,v
retrieving revision 1.25
diff -u -r1.25 UIComponentTag.java
--- src/jsfapi/javax/faces/webapp/UIComponentTag.java 12 Mar 2005 02:17:52 -0000 1.25
+++ src/jsfapi/javax/faces/webapp/UIComponentTag.java 15 Mar 2005 15:42:48 -0000
@@ -423,7 +423,6 @@
if (_componentInstance == null)
{
_componentInstance = createComponentInstance(context, id);
- setProperties(_componentInstance);
int index = getAddedChildrenCount(parentTag);
List children = parent.getChildren();
if (index <= children.size())
@@ -437,6 +436,7 @@
+getPathToComponent(_componentInstance)+" to its parent component. This might be a problem due to duplicate ids.");
}
}
+ setProperties(_componentInstance);
addChildIdToParentTag(parentTag, id);
return _componentInstance;
}

