dataTable and method on items

My problem is the following :

I have an object which contain a collection. Each item of this collection contains a collection. I want to delete, edit, save each of these items. But I can't. Please help me.

I read it was possible to call directly methods on the items on this website :

http://turbomanage.wordpress.com/200...n-a-datatable/

But I have this error : "#{renderer.saveRenderer}: javax.faces.el.MethodNotFoundException: saveRenderer"

Here is the first code :

<h:dataTable id="layers"

styleClass="list-background" value="#{layerList.layers}" var="layer">

<h:column>

<h:graphicImage url="./images/galigeo/new_ana.gif"

onclick="openJsp('rendererassistant.jsf?layer=#{layer.name}')"

alt="#{msg.new_renderer}" />

<h:outputText value="#{layer.aliasName}" style="padding-left:5px;" />

<h:dataTable id="layers" styleClass="list-background"

value="#{layer.renderers}" var="renderer" style="left:20px">

<h:column>

<h:commandLink action="#{renderer.saveRenderer}">

<h:graphicImage url="./images/galigeo/save_2.gif"

alt="#{msg.save}" />

</h:commandLink>

</h:column>

<h:column>

<h:graphicImage url="./images/galigeo/sup.gif" onclick=""

alt="#{msg.delete}" />

</h:column>

<h:column>

<h:graphicImage url="./images/galigeo/iconCategManage.gif"

onclick="" alt="#{msg.edit}" />

</h:column>

<h:column>

<h:outputText value="#{renderer.label}" />

</h:column>

</h:dataTable>

</h:column>

</h:dataTable>

I tried with binding and this is what I'm interested :

http://balusc.xs4all.nl/srv/dev-jep-dat.html

But it doesn't work too; I have this error : "Error setting property 'myDataTable' in bean of type null"

Here is the second code :

<h:dataTable id="layers"

styleClass="list-background" value="#{layerList.layers}" var="layer">

<h:column>

<h:graphicImage url="./images/galigeo/new_ana.gif"

onclick="openJsp('rendererassistant.jsf?layer=#{layer.name}')"

alt="#{msg.new_renderer}" />

<h:outputText value="#{layer.aliasName}" style="padding-left:5px;" />

<h:dataTable id="layers" styleClass="list-background"

value="#{layer.renderers}" var="renderer" binding="#{layer.myDataTable}" style="left:20px">

<h:column>

<h:commandLink action="#{layer.saveRenderer}">

<h:graphicImage url="./images/galigeo/save_2.gif"

alt="#{msg.save}" />

</h:commandLink>

</h:column>

<h:column>

<h:graphicImage url="./images/galigeo/sup.gif" onclick=""

alt="#{msg.delete}" />

</h:column>

<h:column>

<h:graphicImage url="./images/galigeo/iconCategManage.gif"

onclick="" alt="#{msg.edit}" />

</h:column>

<h:column>

<h:outputText value="#{renderer.label}" />

</h:column>

</h:dataTable>

[4425 byte] By [Baltaara] at [2007-11-26 22:57:52]
# 1
action="#{renderer.saveRenderer}"Why is this bound to the DTO? Just bind it to the backing bean. You can retrieve the corresponding row object where this button is clicked by HtmlDataTable#getRowData().
BalusCa at 2007-7-10 12:23:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

action="#{renderer.saveRenderer}"

renderer is not the bean containing my collection, it is one item of the collection containing by layer.

What I want is call a method from layer. By example I want to delete an item (renderer) from the collection containing by layer.

Baltaara at 2007-7-10 12:23:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
You have to bind it to the backing bean. This action is invisible until the data is loaded, that's why this exception is thrown. I am not sure if this is a bug or feature however. I guess it's the last.
BalusCa at 2007-7-10 12:23:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

This is a problem because this means I have to bind layers or this is not on layers I want to call my method this is on layer which is an item from the collection layers. I want to delete... items from collection containing in layer itseld contained in collection of layers.

Layers -> layers -> renderer.

Baltaara at 2007-7-10 12:23:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I understand you. But I repeat: put the action in the backing bean and use getRowData() to retrieve the selected row object.
BalusCa at 2007-7-10 12:23:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

layer is the backing bean of renderer and layerList is the backing bean of layer. I want to get renderer with the getRowData. If I put the binding on layerList the getRowData will return me a layer.

Code of layerList is :

public class WebigeoLayerList

{

private ArrayList<WebigeoLayer> layers = new ArrayList<WebigeoLayer>();

public ArrayList<WebigeoLayer> getLayers()

{

return layers;

}

public void setLayers(ArrayList<WebigeoLayer> layers)

{

this.layers = layers;

}

Code of Layer is :

public class WebigeoLayer

{

private String aliasName;

private String name;

private ArrayList<RendererAssistant> renderers = new ArrayList<RendererAssistant>();

private HtmlDataTable myDataTable;

private RendererAssistant renderer;

public WebigeoLayer(String aliasName, String name)

{

this.aliasName = aliasName;

this.name = name;

}

public String getName()

{

return name;

}

public void setName(String name)

{

this.name = name;

}

public String getAliasName()

{

return aliasName;

}

public void setAliasName(String aliasName)

{

this.aliasName = aliasName;

}

public ArrayList<RendererAssistant> getRenderers()

{

return renderers;

}

public void setRenderers(ArrayList<RendererAssistant> renderers)

{

this.renderers = renderers;

}

public HtmlDataTable getMyDataTable()

{

return myDataTable;

}

public void setMyDataTable(HtmlDataTable myDataTable)

{

this.myDataTable = myDataTable;

}

public RendererAssistant getRenderer()

{

return renderer;

}

public void setRenderer(RendererAssistant renderer)

{

this.renderer = renderer;

}

public void saveRenderer()

{

//Get selected MyData item to be edited.

renderer = (RendererAssistant) myDataTable.getRowData();

...

}

}

Baltaara at 2007-7-10 12:23:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...