Sélection dans un dataTable
Bonjour,
je n'arrive pas a récupérer la ligne active d'une dataTable et afficher continue de cette ligne sur <h:inputText id="myInput"></h:inputText> en cliquan sur le bouton
J'ai essayer de comprendre les 3 méthode de la FAQ mais sans succès.
Merci de votre aide !!
je vous montre
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
<rich:dataTable value="#{beansearch.perInfoAll}" var="item" rows="5" width="600px" style=" width : 408px;" >
<f:facet name="header">
<h:outputText value="Sorting Example"/>
</f:facet>
<rich:column >
<f:facet name="header">Name</f:facet>
<h:outputText value="#{item.username}"/>
</rich:column>
<rich:column >
<f:facet name="header">Surname</f:facet>
<h:outputText value="#{item.jobposition}"/>
</rich:column>
</rich:dataTable>
<a4j:commandButton action="plus" value="++++++" ></a4j:commandButton>
<h:inputText id="myInput"></h:inputText> |
et mon bean
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Beansearch extends HttpServlet {
private List<perInfo> perInfoAll = new ArrayList();
public List<perInfo> getPerInfoAll() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String serverName = "localhost";
String mydatabase = "test";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String user = "root";
String pass = "mus";
java.sql.Connection connection = DriverManager.getConnection(url, user, pass);
Statement instruction = (com.mysql.jdbc.Statement) ((java.sql.Connection) connection).createStatement();
String sql = " select * from test.departement " ;
ResultSet resultat = (ResultSet) instruction.executeQuery(sql);
while(resultat.next()){
String num=resultat.getString("nom").toString();
perInfoAll.add(new perInfo(resultat.getString(1),resultat.getString(2)));
}
//session.close();
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return perInfoAll;
}
public void setPerInfoAll(List<perInfo> perInfoAll) {
this.perInfoAll = perInfoAll;
}
} |
et
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
|
public class perInfo {
private String username;
private String jobposition;
public perInfo(String username,String jobposition) {
this.username = username;
this.jobposition = jobposition;
}
public String getusername() {
return username;
}
public String getjobposition() {
return jobposition;
}
public void setJobposition(java.lang.String jobposition) {
this.jobposition = jobposition;
}
public void setUsername(java.lang.String username) {
this.username = username;
}
} |