j'ai essayé de créer un nouveau inputtext à chaque fois que je clique sur un bouton voila mon code :
mon managed bean
page xhtml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 private HtmlPanelGrid dynamicPanelGrid ; public String addQuestion(){ Random rnd=new Random(); Application app = FacesContext.getCurrentInstance().getApplication(); HtmlInputText text = (HtmlInputText) app.createComponent(HtmlInputText.COMPONENT_TYPE); text.setValue("some text"); text.setId("text"+rnd.nextInt(2000)); dynamicPanelGrid.getChildren().add(text); return null; }
pour la première fois le ça marche et pour la deuxième je reçoie le massage suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <h:panelGrid columns="2"> <h:commandLink value="Ajouter une Nouvelle Question " action="#{principalBean.questbean.addQuestion()}" /> <h:commandLink value=" Se deconnecter" /> </h:panelGrid> <h:panelGrid binding="#{principalBean.questbean.dynamicPanelGrid}"/>
javax.servlet.ServletException: L’ID de composant «j_idt5:text1369» a déjà été détecté dans la vue.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
Partager