You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ma...@bull.net on 2007/06/14 17:04:09 UTC

No Collection Found problem

Hello,

I am having some problems with getting a session attribut in my JSP.

A have a JSP where the user can make a search based on information he must
enter in a form.
The result of the search must be displayed in a table.

To display the result I do:

<logic:notEmpty name="cautionVOs" scope="session">
      <tr>
            <td>
            <div style="overflow:auto; height:100px;">
            <table class="result">
            <logic:iterate id="cautionVOs" name="remPayVO" type="RemPayVO">
                  <tr>
                        <td><html:radio styleClass="radio" name="remPayVO"
                                                      property="paymentId"
                                                      value="<%=
remPayVO.getPaymentId().toString() %>"
                                                      onclick="forward
('prepare','/modifycautionmanagement.do','ModifyCautionForm');waiting();"
/>
                        </td>
                        <td><bean:write name="remPayVO" property=
"dateModifStatut" /></td>
                        <td><bean:write name="remPayVO" property="modePay"
/></td>
                        <td><bean:write name="ModifyCautionForm" property=
"compteFacturation" /></td>
                        <td><bean:write name="remPayVO" property="montant"
/></td>
                        <td><bean:write name="remPayVO" property=
"commentaire" /></td>
                  </tr>

            </logic:iterate>
            </table>
            </div>


            </td>
      </tr>
</logic:notEmpty>

The problem is that I get the error javax.servlet.jsp.jspException: No
Collection found, and i think i get it with <logic:notEmpty name=
"cautionVOs" scope="session">

Here is a piece of my Action class:
*****
ModifyCautionForm modifyCautionForm = (ModifyCautionForm)form;
errors = modifyCautionForm.validate(mapping, request);
purgeSession(request);

RechercheCautionVO rechercheCautionVO = new RechercheCautionVO();

rechercheCautionVO.setCompteFacturation(modifyCautionForm.getCompteFacturation
());
rechercheCautionVO.setPaymentMethod(modifyCautionForm.getModePay());
rechercheCautionVO.setMontant(modifyCautionForm.getMontant());
rechercheCautionVO.setDate(date);
rechercheCautionVO.setPaymentID(modifyCautionForm.getPaymentID());
rechercheCautionVO.setBanque(modifyCautionForm.getBanque());
rechercheCautionVO.setAgence(modifyCautionForm.getAgence());
rechercheCautionVO.setCompte(modifyCautionForm.getCompte());
rechercheCautionVO.setNumPiece(modifyCautionForm.getNumPiece());

Collection cautions = null;

try {
      PaymentDelegate payDelegate = new PaymentDelegate();
      cautions = payDelegate.getAccountCaution(rechercheCautionVO);
      log.debug("*** cautions size " + cautions.size());
      log.debug("*** cautions is empty? " + cautions.isEmpty());

      request.getSession().setAttribute( SESSION_REMPAYVOS, cautions);
      Collection col = (Collection)request.getSession
().getAttribute(SESSION_REMPAYVOS);
      log.debug("*** cautions is empty? " + col.isEmpty());
      modifyCautionForm.setCautionVOs(cautions);

      Iterator it = modifyCautionForm.getCautionVOs().iterator();
      while(it.hasNext()){
            RemPayVO rpVO = (RemPayVO)it.next();
            log.debug("paymentID: " + rpVO.getPaymentId());
      }

****

(SESSION_REMPAYVOS = "cautionVOs")


When I look at the log I can verify that cautions is not null, and neither
is the session attribute.

But if i add
<% Collection col = (Collection)request.getSession().getAttribute(
"cautionVos"); %>
in my JSP right before
<logic:notEmpty name="cautionVOs" scope="session">
I get a java.lang.NullPointerException

Somewhere between my action class and my jsp the session attribute is set
to null.

Does anyone have some idea of what is happening??
Thanks in advance!!

Marianne






---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: No Collection Found problem

Posted by Niall Pemberton <ni...@gmail.com>.
On 6/14/07, Marianne.Gardes@bull.net <Ma...@bull.net> wrote:
> Hello,
>
> I am having some problems with getting a session attribut in my JSP.
>
> A have a JSP where the user can make a search based on information he must
> enter in a form.
> The result of the search must be displayed in a table.
>
> To display the result I do:
>
> <logic:notEmpty name="cautionVOs" scope="session">
>       <tr>
>             <td>
>             <div style="overflow:auto; height:100px;">
>             <table class="result">
>             <logic:iterate id="cautionVOs" name="remPayVO" type="RemPayVO">
>                   <tr>
>                         <td><html:radio styleClass="radio" name="remPayVO"
>                                                       property="paymentId"
>                                                       value="<%=
> remPayVO.getPaymentId().toString() %>"
>                                                       onclick="forward
> ('prepare','/modifycautionmanagement.do','ModifyCautionForm');waiting();"
> />
>                         </td>
>                         <td><bean:write name="remPayVO" property=
> "dateModifStatut" /></td>
>                         <td><bean:write name="remPayVO" property="modePay"
> /></td>
>                         <td><bean:write name="ModifyCautionForm" property=
> "compteFacturation" /></td>
>                         <td><bean:write name="remPayVO" property="montant"
> /></td>
>                         <td><bean:write name="remPayVO" property=
> "commentaire" /></td>
>                   </tr>
>
>             </logic:iterate>
>             </table>
>             </div>
>
>
>             </td>
>       </tr>
> </logic:notEmpty>
>
> The problem is that I get the error javax.servlet.jsp.jspException: No
> Collection found, and i think i get it with <logic:notEmpty name=
> "cautionVOs" scope="session">
>
> Here is a piece of my Action class:
> *****
> ModifyCautionForm modifyCautionForm = (ModifyCautionForm)form;
> errors = modifyCautionForm.validate(mapping, request);
> purgeSession(request);
>
> RechercheCautionVO rechercheCautionVO = new RechercheCautionVO();
>
> rechercheCautionVO.setCompteFacturation(modifyCautionForm.getCompteFacturation
> ());
> rechercheCautionVO.setPaymentMethod(modifyCautionForm.getModePay());
> rechercheCautionVO.setMontant(modifyCautionForm.getMontant());
> rechercheCautionVO.setDate(date);
> rechercheCautionVO.setPaymentID(modifyCautionForm.getPaymentID());
> rechercheCautionVO.setBanque(modifyCautionForm.getBanque());
> rechercheCautionVO.setAgence(modifyCautionForm.getAgence());
> rechercheCautionVO.setCompte(modifyCautionForm.getCompte());
> rechercheCautionVO.setNumPiece(modifyCautionForm.getNumPiece());
>
> Collection cautions = null;
>
> try {
>       PaymentDelegate payDelegate = new PaymentDelegate();
>       cautions = payDelegate.getAccountCaution(rechercheCautionVO);
>       log.debug("*** cautions size " + cautions.size());
>       log.debug("*** cautions is empty? " + cautions.isEmpty());
>
>       request.getSession().setAttribute( SESSION_REMPAYVOS, cautions);
>       Collection col = (Collection)request.getSession
> ().getAttribute(SESSION_REMPAYVOS);
>       log.debug("*** cautions is empty? " + col.isEmpty());
>       modifyCautionForm.setCautionVOs(cautions);
>
>       Iterator it = modifyCautionForm.getCautionVOs().iterator();
>       while(it.hasNext()){
>             RemPayVO rpVO = (RemPayVO)it.next();
>             log.debug("paymentID: " + rpVO.getPaymentId());
>       }
>
> ****
>
> (SESSION_REMPAYVOS = "cautionVOs")
>
>
> When I look at the log I can verify that cautions is not null, and neither
> is the session attribute.
>
> But if i add
> <% Collection col = (Collection)request.getSession().getAttribute(
> "cautionVos"); %>
> in my JSP right before
> <logic:notEmpty name="cautionVOs" scope="session">
> I get a java.lang.NullPointerException
>
> Somewhere between my action class and my jsp the session attribute is set
> to null.

Are you sure that it is the <logic:notEmpty> that is causing the
problem? The reason I'm asking is that your <logic:iterate> doesn't
seem to tie up with what you have in <logic:notEmpty> and doesn't
match what you say your session attribute is. Looks to me like you
have the "id" and "name"  attributes the wrong way round - should be:

<logic:iterate name="cautionVOs" id="remPayVO" type="RemPayVO">

Niall

> Does anyone have some idea of what is happening??
> Thanks in advance!!
>
> Marianne

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org