Domanda

We are facing a problem with dynamic columns. We have a table where columns depend on some filters previouosly selected. When you enter the page you can select year and some other criteria, and with these values we render the table. Our problem is that columns may vary when you select different criteria, and this is a problem because c:forEach is not so much dynamic.

If you look at the example provided in IceSoft Wiki you can see something similar to what we have in our code (but our code is much more complicated): http://www.icesoft.org/wiki/display/ICE/DataTable+Dynamic+Columns

The problem comes with this sentence:

<c:forEach items="#{backing.columns}" var="colModel">

backing.columns is static. But if you change its number of elements (in this example it makes no sense because values in "columns" List match to properties in Task class, but if you are printing a List instead of List) you have a problem, as described here: http://drewdev.blogspot.com.es/2008/08/cforeach-with-jsf-could-ruin-your-day.html

We've tried to recreate component list when we change columns with:

component.getChildren().clear(); //component is of UIComponent type

But didn't work. Also we've tried restoring view from context in a PhaseListener, and no positive results. And we've run out of ideas.

Any idea (or solution :D) would be appreciated. And if someone need more specific code, just ask.

TIA.

PS: This question is also posted in ICEFaces Forum (http://www.icesoft.org/JForum/posts/list/0/21842.page#76787), and I will update with solution (if any) both places.

È stato utile?

Soluzione

We've solved the problem, as we've been suggested at IceSoft Forum, redirecting navigation to the same page in order to get a completely new component tree. For this you need your state to be in a bean that will survive that, but since our backing beans are usually viewscoped this is not a problem. To achieve this, we've changd valueChangeListener method that was changing the list behind the c:foreach and used an action method, and in this action method we're returning null as navigation rule to get the page reload.

See more at: http://www.icesoft.org/JForum/posts/list/21842.page#sthash.sXtPazmS.dpuf

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top