Pessou estou sofrendo para usar Spring+JSF.
Estou com problemas quanto tendo saber qual row eu selecionei para poder excluir (categoryM.delete) em um HTMLDataTable atraves do getRowData()
Parece que o spring não esta injetando (HtmlDataTable dataTable) do meu BackingBean.
Alguem já teve este problema???
Olhem as configurações:
Meu BackingBean: CategoryManaged.java
import...
public class CategoryManaged {
private CategoryBusiness categoryBusiness = null;
private Category category = new Category();
private HtmlDataTable dataTable;
/** Creates a new instance of CategoryManaged */
public CategoryManaged() {
}
public CategoryBusiness getCategoryBusiness() {
return categoryBusiness;
}
public void setCategoryBusiness(CategoryBusiness categoryBusiness) {
this.categoryBusiness = categoryBusiness;
}
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
/* Actions -----------------------------------------*/
public String save(){
categoryBusiness.createCategory(category);
return SUCESS;
}
public String cancel(){
return CANCEL;
}
public String delete(){
System.out.println("Executou delete");
if (dataTable == null){
System.out.println("dataTable é nulo");
}else{
category categ = (category) dataTable.getRowData();
categoryBusiness.deleteCategory(categ);
}
return SUCESS;
}
public List<Category> getCategories(){
if (categoryBusiness == null){
return null;
}else{
return categoryBusiness.listAllCategory();
}
}
public HtmlDataTable getDataTable() {
return dataTable;
}
public void setDataTable(HtmlDataTable dataTable) {
System.out.println("setDataTable");
this.dataTable = dataTable;
}
}
faces-config.xml
...
<faces-config>
<application>
<variable-resolver>
org.springframework.web.jsf.DelegatingVariableResolver
</variable-resolver>
</application>
<!-- Backing Beans -->
<managed-bean>
<managed-bean-name>categoryM</managed-bean-name>
<managed-bean-class>yourblog.backing.CategoryManaged</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>categoryBusiness</property-name>
<value>#{categoryBusiness}</value>
</managed-property>
</managed-bean>
<!-- Navegation Rules -->
<navigation-rule>
<from-view-id>/blogmanager.jsp</from-view-id>
<navigation-case>
<from-outcome>SUCESS</from-outcome>
<to-view-id>index.jsp</to-view-id>
</navigation-case>
</navigation-rule>
....
blogmanager.jsp
...
<h:form>
<h:messages/>
<h:dataTable value="#{categoryM.categories}" binding="#{categoryM.dataTable}" border="1" cellspacing="2" var="category" rows="50" >
<f:facet name="header">
<h:outputText value="Categorias"/>
</f:facet>
<h:column>
<f:facet name="header">
<h:outputText value="Titulos"/>
</f:facet>
<h:outputText value="#{category.label}" />
</h:column>
<h:column>
<h:commandButton action="editCategory" value="Editar"/>
</h:column>
<h:column>
<h:commandButton action="#{categoryM.delete}" value="Excluir"/>
</h:column>
<f:facet name="footer">
<h:panelGroup>
<h:commandButton action="createCategory" value="Criar"/>
</h:panelGroup>
</f:facet>
</h:dataTable>
</h:form>
....