I'm new to this forum, so I'm sorry if I miss anything.
I'm trying to use a selectOneMenu inside a dataGrid, but I can't figure out how to persist a change made in the selectOneMeny. I'm trying to do it without any buttons, just some action that automatic saves the post after changing.
The scenario is the following:
I have a manageBean here called "bean", which has an array of "Posts". In my page I have a datatable which iterates all the posts of this array, in a var called "post". For every Post I want to show a selectOneMenu with a "Categoria". After user selects one "Categoria" I want the post to be persisted.
My code:
Code: Select all
<p:scrollPanel style="width:70%;" id="scrollPnl">
<p:dataGrid var="post" value="#{bean.posts}" columns="1"
id="postsGrid">
<p:column>
....
<h:panelGrid>
<p:selectOneMenu value="#{post.categoria}" converter="#{categoriaConverter}" style="font-size:80%" >
<f:selectItem itemLabel="#{bean.categoriaDefault.nome}" itemValue="#{bean.categoriaDefault}" />
<f:selectItems value="#{bean.categorias}" var="categoria" itemLabel="#{categoria.nome}" itemValue="#{categoria}" />
<p:ajax listener="#{bean.savePost}">
<f:setPropertyActionListener target="#{bean.selectedPost}" value="#{post}"/>
</p:ajax>
</p:selectOneMenu>
</h:panelGrid>
...
//closes things later
Maybe any one have a better idea to do this?
Thanks in advance
Murilo