IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Struts 1 Java Discussion :

No collection found


Sujet :

Struts 1 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 200
    Par défaut No collection found
    Bonjour a tous,

    Je suis debutant dans struts...

    Je suis confronté a un probleme d'affichage de données a vec struts.
    Je reçois une erreur 'No collection found' au niveau de la .jsp

    je ne vois ou alimenter la request pour recuperer les donnés au niveau de .jsp
    merci pour votre aide

    voici une partie de ma .jsp:
    l'objet govBean semble vide au de la jsp semble vide, c'est la cause de l'erreure.

    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
    <table border="0" cellspacing="0" cellpadding="1" width="600">
    	<tr>
    		<td width="5"><br>
    		<li>
    	</tr>
    	<td colspan="4" valign="bottom"><span
    		style="font-family: Verdana, sans-serif; font-size: xx-small; color: #990033; font-weight: bold">
    	<bean:message key="safb" /> </span></td>
    	</tr>
     
    	<tr>
    			<td width="5">&nbsp;
     
    		</tr>
    		<td><logic:iterate id="i" name="govBean" property="fspID" scope="request"> <bean:write name="i" />
    			<br />
    		</logic:iterate></td>
    		</tr>
     
    	<tr style="line-height: 0pt">
    		<td width="5">&nbsp;
    	</tr>
    	<td style="background-color: #000000"></td>
    	</tr>
    </table>
    <br />
     
     
    <jsp:include page="Footer.jsp" />
    <!--
    --------------------------------------------------------------------------
    voici mon action:
    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
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    package ca.uottawa.faidselfserv.actions;
     
    import java.util.ArrayList;
     
    import javax.mail.Session;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.util.MessageResources;
     
    import ca.uottawa.faidselfserv.model.ApplDataAccess;
    import ca.uottawa.faidselfserv.model.ApplGovFinAidBean;
    import ca.uottawa.faidselfserv.model.GovFinAidBean;
    //import ca.uottawa.faidselfserv.model.DataAccess;
    //import ca.uottawa.faidselfserv.model.StudentBean;
    import ca.uottawa.struts.BaseAction;
    import ca.uottawa.struts.BeanContext;
    import ca.uottawa.struts.Logger;
     
    /*
     * FSMS Financial Aid Self Serve - Display Financial Aid Action
     * 
     * This class gets the data for the Display Financial Aid web page which 
     * shows student information and for each semester: registration;
     * scholarship, bursary, & award; government financial aid; and course
     * information. 
     */	
    public class DisplayFinAidActionGov extends BaseAction {
    	static Logger logger = Logger.getLogger("WEN191", DisplayFinAidActionGov.class);
     
    	public ActionForward dbExecute(
    		ActionMapping mapping,
    		ActionForm form,
    		HttpServletRequest request,
    		HttpServletResponse response,
    		BeanContext ctx)
    		throws Exception {
     
    			boolean allSessions = false;
    			if (request.getParameter("sessions") != null &&
    				request.getParameter("sessions").equalsIgnoreCase("all")) {
    				allSessions = true;
    				request.setAttribute("allSessions", "yes");
    			} else {
    				allSessions = false;
    				request.setAttribute("allSessions", null);
    			}
     
     
    			/*
    			 * obtain user type (Student, Employee, Other) and populate the attribute (S, E, O)
    			 */
    			String userType = ctx.getUserType().substring(0,1).toUpperCase();
    			request.setAttribute("userType", userType);
     
     
    			// if there is a session value sn_rtyui (student number) then take this value 
    			// (the value sn_rtyui is named this way so that a student cannot use it
    			// to check the information of another student). 
    			int stuNum = 0;
    			String sn = (String)request.getSession().getAttribute("sn_rtyui");
    			if (sn != null) {
    				stuNum = Integer.valueOf(sn).intValue();
    			}
     
    			/*
    			 * obtain student number and instantiate the student bean
    			 */
    			if (userType.equals("S")) {
    				stuNum = Integer.valueOf(ctx.getUserId()).intValue();
    			} else if (userType.equals("E") && request.getParameter("studentNum") != null) {
    				stuNum = Integer.valueOf(request.getParameter("studentNum")).intValue();
    			}
     
    			System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");					
    //			StudentBean	stuBean	= new StudentBean(stuNum);
    			ApplGovFinAidBean govBean	= new ApplGovFinAidBean(stuNum);
     
    			/*
    			 * obtain the financial aid data for a student
    			*/
    			ApplDataAccess dataAccess = new ApplDataAccess(ctx);
    			ArrayList semList = new ArrayList(0);
     
    System.out.println(stuNum + "   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
     
    			if (stuNum != 0) {
    				semList = dataAccess.getFinAidGov(govBean, userType, allSessions, ctx.getLanguage());
    			}	
     
    			if (semList.size() > 0) {
    				request.setAttribute("semList", semList);
    				System.out.println("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");	
    			}
     
    			request.setAttribute("govBean", govBean);
     
     
    //////////	ApplGovFinAidBean ApplGovBean = (ApplGovFinAidBean)request.getAttribute("ApplGovFinAidBean");
    //////////	String fspID = (String)request.getAttribute("fspID");
     
     
    System.out.println( "  -  " + semList.size() + " /// " + govBean.getSession()+ "  -  " + govBean.getApplicationSeq()+ "  -  " + govBean.getDesc());			
     
    		return mapping.findForward("displayGov");
     
    	}
    }
    --------------------------------------------------------------------
    voici mon JavaBean:

    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
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    package ca.uottawa.faidselfserv.model;
     
    import java.math.BigDecimal;
    import java.util.ArrayList;
     */
    public class ApplGovFinAidBean {
    //	private String	personID 		= "";
    	private int		applicationSeq	= 0;  	
    	private String	fspID			= "";  	
    	private String	session			= "";  	
    	private String	applicationDT	= "";  	
    	private String	groupST			= "";  	
    	private String	desc			= "";  	
    	private String	provinceCD		= "";  	
    	private String  receivedDT 		= "";
    	/*
    	 * student number constructor
    	 */
    	public ApplGovFinAidBean(int sN) {
    		applicationSeq	= 0;  	// 
    		fspID			= "";  	// 
    		session			= "";  	// 
    		applicationDT	= "";  	// 
    		groupST			= "";  	// 
    		desc			= "";  	// 
    		provinceCD		= "";  	// 
    		receivedDT 		= "";
    	}
    	/**
             * @return
             */
     
    	/**
             * @return
             */
    	public String getDesc() {
    		return desc;
    	}
    	/**
                     * @return
                     */
    	public String getFspID() {
    			return fspID;
    		}
    	/**
             * @return
             */
    	public String getProvinceCD() {
    		return provinceCD;
    	}
    	/**
             * @return
             */
    	public String getSession() {
    		return session;
    	}
    	/**
             * @return
             */
    	public String getApplicationDT() {
    		return applicationDT;
    	}
    	/**
             * @return
             */
    	public int getApplicationSeq() {
    		return applicationSeq;
    	}
    	/**
            * @return
            */
    	public String getGroupST() {
    			return groupST;
    	}
    	/**
            * @return
            */
    	public String getReceivedDT() {
    		return receivedDT;
    	}
    	/**
             * @param d
             */
     
    	/**
             * @return
             */
    	public void setFspID(String s) {
    		fspID = s;
    	}
    	/**
            * @return
             */
    	public void setDesc(String s) {
    			desc = s;
    		}
    	/**
             * @return
             */
    	public void setProvinceCD(String s) {
    		 provinceCD = s;
    	}
    	/**
             * @return
             */
    	public void setSession(String s ) {
    		 session = s;
    	}
    	/**
             * @return
             */
    	public void setApplicationDT(String s) {
    		 applicationDT = s;
    	}
    	/**
             * @return
             */
    	public void setApplicationSeq(int a) {
    		 applicationSeq = a;
    	}
    	/**
                     * @return
                     */
    	public void setGroupST(String s) {
    		groupST = s;
    		}
    		/**
                     * @return
                     */
    	public void setReceivedDT(String s) {
    		receivedDT = s;
    		}
    }
    -------------------------------------------------------------------------
    et finalement le 'Access data' :

    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
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    package ca.uottawa.faidselfserv.model;
     
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Types;
    import java.util.ArrayList;
     
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
     
    import ca.uottawa.struts.BeanContext;
    import ca.uottawa.struts.DataBaseBroker;
    import ca.uottawa.struts.Logger;
     
    /*
     * FSMS Financial Aid Self Serve Data Access
     * 
     * This class contains the methods used to access stored procedures
     *   DataAccess		- constructor to establish DB connection
     *   getFinAid		- get a list of online courses for a professor
     */
    public class ApplDataAccess extends DataBaseBroker {
    	static Logger logger = Logger.getLogger("WEN191", ApplDataAccess.class);
     
    	/*
    	 * connection constructor
    	 */
    	public ApplDataAccess(BeanContext c) {
    		super(c);
    	}
     
    	/*
    	 * The getFinAid method ...
    	 */
    	public ArrayList getFinAidGov(
    		ApplGovFinAidBean govBean,
    		String userType,
    		boolean allSessions,
    		String language)
    		throws Exception {
     
    		Connection workStudyCon = ctx.getConnection();
     
    		if (!System.getProperty("env.db2").equalsIgnoreCase("DB2D")) {			
    			InitialContext workStudyCtx = new InitialContext();
    			DataSource workStudyDS = (DataSource) workStudyCtx.lookup("java:comp/env/jdbc/WorkStudy");
    			workStudyCon = workStudyDS.getConnection();
    		}
     
     
    		ctx.setMethodName("getFinAidGov");
    		ctx.setStoredProcedureName("SIS.GOVT_AID_APPL_GET");
     
    		CallableStatement callStmt = con.prepareCall("CALL SIS.GOVT_AID_APPL_GET(?,?,?,?,?,?,?)");
     
    		callStmt.registerOutParameter(1,  	Types.INTEGER); 	// application sequence
    		callStmt.registerOutParameter(2,  	Types.CHAR); 		// fsp id
    		callStmt.registerOutParameter(3,  	Types.CHAR); 		// session id
    		callStmt.registerOutParameter(4,  	Types.CHAR);		// group status
    		callStmt.registerOutParameter(5,  	Types.CHAR); 		// english description
    		callStmt.registerOutParameter(6, 	Types.CHAR); 		// province code
    		callStmt.registerOutParameter(7, 	Types.INTEGER); 	// error number
     
    		callStmt.execute();
     
     
    		if (callStmt.getInt(7) != 0) {
    			throw new Exception(
    				"SIS.GOVT_AID_APPL_GET error:" + callStmt.getInt(7));
    		}
     
    			//load stuBean
    			govBean.setApplicationSeq(callStmt.getInt(1));					
    			govBean.setFspID(callStmt.getString(2));
    			govBean.setSession(callStmt.getString(3));
    			govBean.setGroupST(callStmt.getString(4));
    			govBean.setDesc(callStmt.getString(5));
    			govBean.setProvinceCD(callStmt.getString(6));
     
    		ApplGovFinAidBean GovBean = new ApplGovFinAidBean();
     
    				ArrayList semList = new ArrayList();
    				ResultSet rs = callStmt.getResultSet();
     
    			//	for (int i = 0;i < MysemList.size();i++){
    					int i =0;
     
    					while (rs.next()) {
    						//rs.getStatement();
     
    						govBean = new ApplGovFinAidBean();
     
    						govBean.setApplicationSeq(rs.getInt(1));
    						govBean.setFspID(rs.getString(2));
    						govBean.setSession(rs.getString(3));
    						govBean.setGroupST(rs.getString(4));
     
    						govBean.setDesc(rs.getString(5));
    						govBean.setProvinceCD(rs.getString(6));
     
    						semList.add(govBean);
    						i++;
    					}
     
     
    System.out.println("  *  " + govBean.getSession()+ "  *  " + govBean.getApplicationSeq()+ "  *  " + govBean.getDesc());
     
    		return semList;
    	}
     
     
    }
    ---------------------------------------------------------------

  2. #2
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Pour que ceci fonctionne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <logic:iterate id="i" name="govBean" property="fspID" scope="request">
    il faudrait que fspID soit une collection, ce qui n'est pas le cas.

    La collection de beans de type ApplGovFinAidBean que tu as mis dans le scope request s'appelle semList et la propriété que tu sembles vouloir afficher est fspID.

    Il faut donc coder ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <logic:iterate id="item" name="semList" scope="request">
       <bean:write name="item" property="fspID" />
    </logic:iterate>

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 200
    Par défaut No collection found
    Citation Envoyé par c_nvy
    Pour que ceci fonctionne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <logic:iterate id="i" name="govBean" property="fspID" scope="request">
    il faudrait que fspID soit une collection, ce qui n'est pas le cas.

    La collection de beans de type ApplGovFinAidBean que tu as mis dans le scope request s'appelle semList et la propriété que tu sembles vouloir afficher est fspID.

    Il faut donc coder ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <logic:iterate id="item" name="semList" scope="request">
       <bean:write name="item" property="fspID" />
    </logic:iterate>

    merci c_nvy, ça fonctionne bien...
    Dans mon esprit c'est pas semList que je dois utilisé dans ma .jsp mais par contre c'est govBean
    Pourquoi ça marche avec semList mais pas avec govBean?

  4. #4
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    parce que semList est une ArrayList d'objets de type ApplGovFinAidBean et govBean seulement une instance de ApplGovFinAidBean.

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 200
    Par défaut
    Citation Envoyé par c_nvy
    parce que semList est une ArrayList d'objets de type ApplGovFinAidBean et govBean seulement une instance de ApplGovFinAidBean.
    Ta reponse est tres logique, mais dans ce cas c'est quoi le role de l'instance govBean?
    merci encore pour ton aide.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Erreur Found shared references to a collection
    Par pcouas dans le forum Hibernate
    Réponses: 1
    Dernier message: 13/03/2019, 01h12
  2. [NHibernate] Found shared references to a collection
    Par m3z91 dans le forum NHibernate
    Réponses: 1
    Dernier message: 05/10/2010, 16h54
  3. Réponses: 2
    Dernier message: 02/07/2010, 10h37
  4. l'erreur javax.servlet.ServletException: No collection found
    Par freestyler1982 dans le forum Struts 1
    Réponses: 9
    Dernier message: 12/05/2009, 16h58
  5. Type mismatch / Item not found in the collection.
    Par broise dans le forum VBA Access
    Réponses: 2
    Dernier message: 18/07/2008, 14h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo