I have a page with a datatable on (it's actually an openfaces datatable, but I don't think that matters in this instance.)
The table is backed by a viewscoped bean that provides an ArrayList of objects for data. If the datatable tags are directly in the xhtml page being called, the viewscope works fine - that is, fo subsequent posts that result in void or null methods being called, and therefore return to the same page, no new instance of the bean is created.
However, if I extract the datatable in to a composite component, and pass in the List of objects that the table should display as a parameter instead, the backing bean is instantiated every time.
e.g. The following works fine - testBean is only instantiated the first time. Clicking the button does not create a new testBean instance.
However, putting the datatable in a composite component and have tableItems as a parameter, the following doesn't work:
Try moving your call to cc:customTable inside the form and take out the <h:form>
tags from the composite component. I've hit a number of problems with using h:form
inside a cc. Theoretically it should work, and sometimes it does, but sometimes it
doesn't. Are you using ui:component tags for the cc? Which mojarra version?
It's a little unusual to put the datatable outside the form. Another thing to consider
is that when you have a commandButton with a child ajax tag it will by default only
submit (albeit partially) @this, i.e. the commandButton component itself. If you had:
...then the inputText data wouldn't get submitted unless you had:
In fact looking at it again your form (excerpt) doesn't make sense. You have an outputText,
a commandButton with a child ajax tag which updates the outputText component, and then a
dataTable which is outside the form. What are you expecting to happen? where's the input?
Joined: Nov 03, 2008
Thanks for the suggestions. I'm fairly sure I've tried this with everything within one form (I don't have any form tags withing the cc)
I'm not using the ui:component tag. I'm using
<composite:interface> and <composite:implementation> to define my component, add calling it from the using page in the usual way, referencing the namespace.
So if my component was in a file customTable.xhtml, I would call it using
Kevin: Did you ever find a solution to this problem? I'm battling with this issue now. It looks like the view scope breaks when I pass an el expression into an attribute of a composite component.
Joined: May 12, 2009
Louis Jordaan wrote:Kevin: Did you ever find a solution to this problem? I'm battling with this issue now. It looks like the view scope breaks when I pass an el expression into an attribute of a composite component.
Hi, can you post up a code example of your issue?
Joined: Nov 03, 2008
Further news - this appears to only happen when one of the composite:attributes has required="xxx" in the tag...
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Composite Components with ViewScoped bean