<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="New categorie"></h:outputText>
<h:inputText value="${categorieBean.categorie.name}"></h:inputText>
<h:commandButton value="Add categorie" action="#{categorieBean.dodajKategoriju}">
<f:ajax render="@form" execute="@form"></f:ajax>
</h:commandButton>
</h:panelGrid>
<h:dataTable value="${categorieBean.categories}" var="categor">
<h:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="${categor.name}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">DELETE</f:facet>
<h:commandButton value="Delete-${categor.id}" action="#{categorieBean.obrisiKategoriju()}"
style="width: 64px;background-color: green;color: white;border: none;height: 27px;border-radius:
5px;">
<f:ajax render="@form" execute="@form"></f:ajax>
<f:param value="${categor.id}" name="id"></f:param>
</h:commandButton>
</h:column>
</h:dataTable>
</h:form>
</ui:composition>
</html>
@ManagedBean(name="categorieBean")
@SessionScoped
public class CategorieBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7281388938441323040L;
private List<Categorie> categories=new ArrayList<Categorie>();
private Categorie categorie=new Categorie();
public CategorieBean() {
// TODO Auto-generated constructor stub
}
public List<Categorie> getCategories() {
categories=CategorieDAO.readAll();
return categories;
}
public void setCategories(List<Categorie> categories) {
this.categories = categories;
}
public Categorie getCategorie() {
return categorie;
}
public void setCategorie(Categorie categorie) {
this.categorie = categorie;
}
public String obrisiKategoriju() {
System.out.println("hocu da obrisem kategoriju");
HttpServletRequest req=(HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
System.out.println(req.getParameter("id"));
Map<String,String> mapa=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
for(Entry<String,String>pom:mapa.entrySet()) {
System.out.println(pom.getKey()+" "+pom.getValue());
}
if(mapa.containsKey("id")) {
System.out.println("Usao sam");
int id=Integer.parseInt(mapa.get("id"));
CategorieDAO.delete(id);
}
return "";
}
public String dodajKategoriju() {
CategorieDAO.insert(categorie);
return "";
}
}
Я не отправляю параметр param для Бина в методе obrisiKategoriju (), когда я печатаю значение requestparammap, я получаю только j_idt6 j_idt6 j_idt6: j_idt9 j_idt6: j_idt11: 0: j_idt17 Delete-1 javax.faces.710107103105106181818310631614831031031031063108183103103103103103103103103103103103103103103103103103103103103103103103103_1483_14831031033031031031063_1483103103103103103103_1 063 663 663 663 6103 610 6103 6 бы были зарегестрированы, чтобы получить доступ к данным. *1000* *1001*. -2255221033905007338 у кого есть идеи? У меня есть другой Боб, но он отлично работает, с этим нет, я попробовал все