You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Daniele Bernardini <da...@intranetstandard.com> on 2006/07/07 18:01:28 UTC

af:table and dynamic content

Hi people,

I run into a funny behavior of <af:table>

I have a setActionListener that triggers a method initTable() which then
changes the columns of the table in question. the table is defined in
the jsp without columns. Inside the dynamically generated columns i
placed CoreInputText elements. value bindings and method bindings are in
place.

Everything works fine except when i try to save the data. My input is
just ignored. However if I go and reload the jsp page without closing
the browser then everything works as intended.
I think I am missing something about the jsf life cycle here

Any clue?

thanks a lot

Daniele

Here the relevant code:


public void initTable(){
System.out.println(" ---------------- Reinit Table");
if (entityTable != null && entityType != null){
refreshEntities();
for (Iterator it = entityTable.getChildren().iterator(); it.hasNext();){
Object child = it.next();
if (child.getClass().equals(CoreColumn.class)) {
it.remove();
}
}
addTableColumn(entityTable,"name","#{entity.name}","string","name");
addTableColumn(entityTable,"description","#{entity.description}","string","description");
for (Iterator it = entityType.getAttributes().iterator();
it.hasNext();){
String attributeName = (String)it.next();
addTableColumn(entityTable,attributeName,"#{entity.attributeValues['" +
attributeName + "']}","string");
}
}
}
        
}
    

<af:menuBar binding="#{entityTableView.entityTypesMenu}">
<af:forEach items="#{entityTableView.rootEntityTypes}" var="rootType">
<af:commandMenuItem immediate="true" text="#{rootType.name}"
action="#{entityTableView.initTable}">
<af:setActionListener from="#{rootType}"
to="#{entityTableView.entityType}"/>
</af:commandMenuItem>
</af:forEach>
</af:menuBar>

<af:table rendered="#{entityTableView.entityType != null}"
binding="#{entityTableView.entityTable}"
value="#{entityTableView.entities}" var="entity" rows="10"
banding="row">
<f:facet name="selection">
<af:tableSelectOne>
<af:commandButton text="delete"
action="#{entityTableView.deleteEntity}"/>
</af:tableSelectOne>
</f:facet>
</af:table>



Re: af:table and dynamic content

Posted by Daniele Bernardini <da...@intranetstandard.com>.
For now I am forcing a reload on the page every time I change the table
structure. Ugly but it works. I also posted about it here:
http://notonlyjava.blogspot.com/2006/07/dynamic-inputs-in-adf-tables.html

On Fri, 2006-07-07 at 18:01 +0200, Daniele Bernardini wrote:
> Hi people,
> 
> I run into a funny behavior of <af:table>
> 
> I have a setActionListener that triggers a method initTable() which then
> changes the columns of the table in question. the table is defined in
> the jsp without columns. Inside the dynamically generated columns i
> placed CoreInputText elements. value bindings and method bindings are in
> place.
> 
> Everything works fine except when i try to save the data. My input is
> just ignored. However if I go and reload the jsp page without closing
> the browser then everything works as intended.
> I think I am missing something about the jsf life cycle here
> 
> Any clue?
> 
> thanks a lot
> 
> Daniele
> 
> Here the relevant code:
> 
> 
> public void initTable(){
> System.out.println(" ---------------- Reinit Table");
> if (entityTable != null && entityType != null){
> refreshEntities();
> for (Iterator it = entityTable.getChildren().iterator(); it.hasNext();){
> Object child = it.next();
> if (child.getClass().equals(CoreColumn.class)) {
> it.remove();
> }
> }
> addTableColumn(entityTable,"name","#{entity.name}","string","name");
> addTableColumn(entityTable,"description","#{entity.description}","string","description");
> for (Iterator it = entityType.getAttributes().iterator();
> it.hasNext();){
> String attributeName = (String)it.next();
> addTableColumn(entityTable,attributeName,"#{entity.attributeValues['" +
> attributeName + "']}","string");
> }
> }
> }
>         
> }
>     
> 
> <af:menuBar binding="#{entityTableView.entityTypesMenu}">
> <af:forEach items="#{entityTableView.rootEntityTypes}" var="rootType">
> <af:commandMenuItem immediate="true" text="#{rootType.name}"
> action="#{entityTableView.initTable}">
> <af:setActionListener from="#{rootType}"
> to="#{entityTableView.entityType}"/>
> </af:commandMenuItem>
> </af:forEach>
> </af:menuBar>
> 
> <af:table rendered="#{entityTableView.entityType != null}"
> binding="#{entityTableView.entityTable}"
> value="#{entityTableView.entities}" var="entity" rows="10"
> banding="row">
> <f:facet name="selection">
> <af:tableSelectOne>
> <af:commandButton text="delete"
> action="#{entityTableView.deleteEntity}"/>
> </af:tableSelectOne>
> </f:facet>
> </af:table>
> 
>