salut à tous,

J'aimerais faire une pagination en JSF.Pour la premiere page c'est bon,elle s'affiche bien mais deja un truc bisard,je suis obligé de mettre ca dans ProspectKaboDao (if(numeropage==0){ return Listprospects();}alors qu'avec le texte de la contrainte,ca ne marche pas imédiatement si j'enleve cette condition.
Sinon,autre prbl que je n'arrive pas a resoudre,lorsque l'on appuie sur le bouton suivant ou inf,il me met une erreur(voir erreur).Je recupere les differents beans que je me a jour,et je renvoie sur la meme page

Je suppose que c'est une erreur de cycle de vie en jsf mais si c'est bien le cas,comment resoudre ce prbl

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
57
58
59
60
61
62
63
64
65
66
67
68
69
 
<%@page contentType="text/html"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="html"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="core"%>
 
<style type="text/css">
<!--
.titre{
background-color:#000000;
color:#FFFFFF;
}
.paire{
background-color:#EFEFEF;
}
.imapaire{
background-color:#CECECE;
}
-->
</style>
 
<html>
<head><title>Pagination Prospect</title></head>
<body>
<core:view>
<html:form>
<center>
    <html:outputText style="color:red" value="Liste Des Prospects"/>
    <br><br><br><br>
	<html:dataTable value="#{pkd.listprospect}" var="prospect" cellspacing="4" width="60%" rowClasses="paire,impaire" headerClass="titre">
  	 <html:column>
  	    <core:facet name="header">
  	                <html:commandLink><core:param name="contraintes" value="sysid"/><html:outputText value="Sysid :"/></html:commandLink>
  	    </core:facet>
  	                <html:outputText value="#{prospect.sysid}"}/>  	 
  	 </html:column>
 
     <html:column>
	    <core:facet name="header">
	                <html:commandLink action="#{pkd.listprospect}"><core:param name="contraintes" value="name"/><html:outputText value="Nom :"/></html:commandLink>
	    </core:facet>
	                <html:outputText value="#{prospect.nom}"/>
	 </html:column>
 
	 <html:column>
	     <core:facet name="header">
	     			<html:commandLink action="#{pkd.listprospect}"><core:param name="contraintes" value="surname"/><html:outputText value="Prénom :"/></html:commandLink>
	     </core:facet>
	     			<html:outputText value="#{prospect.prenom}"/>
	 </html:column>
 
	  <html:column>
	     <core:facet name="header">
	     			<html:commandLink action="#{pkd.listprospect}"><core:param name="contraintes" value="raison_sociale"/><html:outputText value="Raison sociale :"/></html:commandLink>
	     </core:facet>
	     			<html:outputText value="#{prospect.raisonsocial}"/>
	 </html:column>
	</html:dataTable>
	<br><br>	
 
	<html:commandLink action="#{pkb.Clique}"><core:param name="symbole" value="inf"/><html:graphicImage value="images/inferieur.bmp"/></html:commandLink> 
	<html:outputText value="Numero de page :"/><html:outputText value="#{pagination.page}"/><html:outputText value="/"/><html:outputText value="#{pkd.nbpage}"/>
	<html:commandLink action="#{pkb.Clique}"><core:param name="symbole" value="sup"/><html:graphicImage value="images/superieur.bmp"/></html:commandLink>	 
 
 
</center>
</html:form>
</core:view>
</body>
</html>

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<?xml version='1.0'?><!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
 
<faces-config>	
 
	<managed-bean>
		<managed-bean-name>pkd</managed-bean-name>
		<managed-bean-class>dao/ProspectsKaboDao</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
 
    <managed-bean>
		<managed-bean-name>pk</managed-bean-name>
		<managed-bean-class>bean/Prospects_kabo</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
 
 
	<managed-bean>
		<managed-bean-name>pkb</managed-bean-name>
		<managed-bean-class>binding/Prospects_Kabo_Binding</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
 
 
	<managed-bean>
		<managed-bean-name>pagination</managed-bean-name>
		<managed-bean-class>bean/Pagination</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
 
   <navigation-rule>
     <from-view-id>/pagination.jsp</from-view-id>
     <navigation-case>
         <from-outcome>clique</from-outcome>
         <to-view-id>/pagination.jsp</to-view-id>
     </navigation-case>
   </navigation-rule>
 
 
 
 
</faces-config>

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
package dao;
 
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
import javax.faces.context.FacesContext;
 
import bean.Pagination;
import bean.Prospects_kabo;
import binding.Prospects_Kabo_Binding;
 
 
 
public class ProspectsKaboDao implements Serializable {
 
	private List Listprospect=new ArrayList();
	private FacesContext context = FacesContext.getCurrentInstance(); 
	private Map map = context.getExternalContext().getRequestParameterMap();
	private Pagination pagination;
	private int numeropage=0;
	private String contrainte="sysid";
 
	public List getListprospect() throws SQLException {	
		String aveccontrainte = (String) map.get("contraintes");	
		System.err.println("size "+Listprospect.size()+"contrainte? "+aveccontrainte);
		if(numeropage==0){;
		 return Listprospects();
		}
		else
		{
		 if((aveccontrainte.equals(null))||(aveccontrainte.equals(""))){
			  System.out.println("avec");
				return Listprospectcritere();
		 }
		 else{ 
			 System.out.println("sans");
			 contrainte="sysid";
			 return Listprospects();
		 }
		}
	}	
 
	public List Listprospects()throws SQLException{
		 Prospects_Kabo_Binding pkbinding=(Prospects_Kabo_Binding)context.getApplication().createValueBinding("#{pkb}").getValue(context);	
		 pagination=(Pagination)context.getApplication().createValueBinding("#{pagination}").getValue(context);	
		 numeropage=((pagination.getPage())-1);
		 System.err.println("Numero page "+numeropage+" symbole "+pkbinding.getSymboleclique());
	   if(Listprospect.size()==0){ 
			    Listprospect.add(ProspectsKaboDao2.getInstance().getProspect(numeropage,contrainte));			   
	   }
		 else if((pkbinding.getSymboleclique()== 2) && ((numeropage+1)>Listprospect.size())){			    
			    int nbmax=getMaxSysid();
			   	Listprospect=(ArrayList)ProspectsKaboDao2.getInstance().getProspect(nbmax,contrainte);
	   }	
	   pkbinding.setSymboleclique(0);
		 context.getApplication().createValueBinding("#{pkb}").setValue(context, pkbinding);		
		 return (List)Listprospect.get(numeropage);
	}
 
	public List Listprospectcritere() throws SQLException{		
		 System.out.println("avec contrainte");
		 contrainte = (String) map.get("contrainte");		
  	 Listprospect=(ArrayList)ProspectsKaboDao2.getInstance().getProspect(0,contrainte);	
		 Pagination pagination=(Pagination)context.getApplication().createValueBinding("#{pagination}").getValue(context);
		 pagination.setPage(1);
		 context.getApplication().createValueBinding("#{pagination}").setValue(context, pagination);
		 Prospects_Kabo_Binding pkbinding=(Prospects_Kabo_Binding)context.getApplication().createValueBinding("#{pkb}").getValue(context);		
		 pkbinding.setSymboleclique(0);
		 context.getApplication().createValueBinding("#{pkb}").setValue(context, pkbinding);	
		 return (List)Listprospect.get(0);
	}
 
	public int getMaxSysid(){
		 List Listpkbo=(List)Listprospect.get(numeropage);		
		 Prospects_kabo pkbo=(Prospects_kabo)Listpkbo.get(Listpkbo.size()-1);
		 int maxsysid=Integer.parseInt(pkbo.getSysid());	
		 System.out.println("MAX"+maxsysid);
		 return maxsysid;		
	}
 
	public int getNbpage() throws SQLException {
		 int nbpage=(int)ProspectsKaboDao2.getInstance().getNbpage();
		 return nbpage;
	}	
 
	public void setListprospect(List listprospect) {
		 Listprospect = listprospect;
	}	
 
 
 
}

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
package binding;
import java.io.Serializable;
import java.util.Map;
 
import javax.faces.context.FacesContext;
 
import bean.Pagination;
 
public class Prospects_Kabo_Binding  implements Serializable{
 
	private int symboleclique=0;
	private FacesContext fc=FacesContext.getCurrentInstance();
	private Map map = fc.getExternalContext().getRequestParameterMap();
	private int numeropage;
 
 
	public int getSymboleclique() {
		return symboleclique;
	}
 
	public void setSymboleclique(int symboleclique) {
		this.symboleclique = symboleclique;
	}
 
	public String Clique(){
		Pagination pagination=(Pagination)fc.getApplication().createValueBinding("#{pagination}").getValue(fc);		
		String symbole = (String) map.get("symbole");	
		if(symbole.equals("inf")){
			this.symboleclique=1;
			if(pagination.getPage()!=1)
			{
				numeropage=pagination.getPage()-1;
			}
		}
		else{
			this.symboleclique=2;
			numeropage=pagination.getPage()+1;
		}
	  pagination.setPage(numeropage);
		fc.getApplication().createValueBinding("#{pagination}").setValue(fc, pagination);
		return "clique";
	}
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
[06/08/07 11:56:11:531 CEST] 0000001c jsf           E com.sun.faces.lifecycle.ApplyRequestValuesPhase execute javax.faces.el.EvaluationException: Error getting property 'listprospect' from bean of type dao.ProspectsKaboDao: java.lang.IllegalStateException
                                 javax.faces.el.EvaluationException: javax.faces.el.EvaluationException: Error getting property 'listprospect' from bean of type dao.ProspectsKaboDao: java.lang.IllegalStateException
	at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:186)
	at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:137)
	at javax.faces.component.UIData.getValue(UIData.java:527)
	at javax.faces.component.UIData.getDataModel(UIData.java:856)
	at javax.faces.component.UIData.setRowIndex(UIData.java:379)
	at javax.faces.component.UIData.iterate(UIData.java:898)
	at javax.faces.component.UIData.processDecodes(UIData.java:737)
	at javax.faces.component.UIForm.processDecodes(UIForm.java:139)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:922)
	at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:341)
	at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:81)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:239)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1572)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:762)
	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3071)
	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:236)
	at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:89)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
	at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:619)
	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
	at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1471)
Caused by: javax.faces.el.EvaluationException: Error getting property 'listprospect' from bean of type dao.ProspectsKaboDao: java.lang.IllegalStateException
	at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:90)
	at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:167)
	at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:151)
	at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
	at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:156)
	... 28 more
Caused by: java.lang.IllegalStateException
	at com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:408)
	at com.sun.faces.context.FacesContextImpl.getApplication(FacesContextImpl.java:122)
	at dao.ProspectsKaboDao.Listprospects(ProspectsKaboDao.java:47)
	at dao.ProspectsKaboDao.getListprospect(ProspectsKaboDao.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
	at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
	at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:80)
	... 32 more