You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marko Asplund <ma...@gmail.com> on 2007/03/08 10:44:00 UTC

Composite components and programmatic component creation

I'm working on a use case where users will browse a tree structure
that represents a kind stored seaches. When a user clicks on a stored
search node in the tree, a search form with predefined search criteria
is presented. Each search will have their own set of search criteria
that are stored in the database. There's basically three types of
criteria that a search can contain:
- text (text field)
- text with select list (text field + select list)
- date (text field + date selection)

I've created a custom tag that represents the set of search criteria
for a search. I've also written a component corresponding to the tag
that programmatically creates the search criteria component tree. Text
field and select list are combined in another composite component.

The search criteria set component is a composite component that is a
UIComponentBase subclass and doesn't hold any properties of it's own.
There are some problems with the component creation currently. When I
create the child components in the composite component's constructor
everything works fine during the initial request but during postback I
get the following error:

java.lang.ArrayIndexOutOfBoundsException: 1
	at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1040)
	at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1044)
	at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1044)
	at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:336)
	at oracle.adfinternal.view.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:258)
	at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:250)
	at oracle.adfinternal.view.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:232)


When I create the components in encodeEnd (unconditionally), I get the
following error on postback:

javax.servlet.jsp.JspException: Duplicate component ID '_id0:id200'
found in view.
	at com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:191)
	at _jsp._reportParameters_jspx._jspService(_reportParameters_jspx.java:93)
	[/jsp/reportParameters.jspx]
	at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.1.1)
].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)

How and where should the components be created?

What's the correct way to render composite components? Currently the
composite returns true in getRendersChildren and in encodeEnd calls
encode/Begin/Children/End for top level child components. Is this the
correct way to do it?