(JSF,primefaces) faire apparaître un composant avec ajax
oui, je n'arrive pas à le faire.
voici mes 2 fichiers :
index.xhtml
---------------
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<p:panel header="Hello From">
<p:linkButton href="http://www.primefaces.org/labs" value="Prime Faces"/>
</p:panel>
<br/>
<h:form id="form1">
<h:commandButton id="cb1" value="cliquez-moi!">
<p:ajax actionListener="#{bean.magie}" update="form1:it1"/>
</h:commandButton>
<h:outputText id="it1" rendered="#{bean.ok}" value="ça marche"></h:outputText>
</h:form>
</h:body>
</html> |
et Bean.java
-----------------
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beans;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
/**
*
* @author lolveley
*/
@Named(value="bean")
@SessionScoped
public class Bean implements Serializable{
/** Creates a new instance of Bean */
public Bean() {
ok=false;
}
boolean ok;
public boolean isOk() {
return ok;
}
public void setOk(boolean ok) {
this.ok = ok;
}
public String magie(){
ok=true;
return("");
} |
pouvez-vous m'aider à faire ça?
olivier
ps : j'utilise netbeans avec JSF 2.0 et primefaces 2.1