You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steven Nakhla <sd...@yahoo.com> on 2003/11/25 21:37:50 UTC

Struts, EJBs, and problems

I am still learning about EJBs, Struts, and a whole host of other things.  I'm writing a simple web app to manage my product license keys.  I have 3 CMR EJBs that I'm working with:  ProductVendor, Product, and LicenseKey.  The beans are created such that a ProductVendor can have multiple Products, each of which can have multiple LicenseKeys.  
 
In my web app, I would like to be able to list all of the entries in my database.  In my Struts Action, I perform a findAll() to return a Collection of ProductVendors, and then call request.setAttribute("vendorList", vendors); so it can be referenced from my JSP.
 
In my JSP, I have the following to iterate over the list and display the entries:

<logic:iterate id="vlist" name="vendorList">

<bean:write name="vlist" property="name" />

<ul>

<logic:iterate id="plist" name="vlist" property="products">

<li><bean:write name="plist" property="title" /></li>

</logic:iterate>

</ul>

</logic:iterate>

 

Everything looks like it is in order.  However, when I try to display the JSP I get the following exception:  org.apache.jasper.JasperException: A CMR collection may only be used within the transction in which it was created.

Can anyone explain to me what the problem is?  Does anyone know how I could go about displaying the list like I would like?  I'd really appreciate any help you could give this poor newbie.  Thanks in advance!

 

Steve Nakhla



---------------------------------
Do you Yahoo!?
Free Pop-Up Blocker - Get it now

Re: Struts, EJBs, and problems

Posted by guo yingshou <gu...@yahoo.com.cn>.
you need to use a collection of value objects instead
of component objects in your jsp.

guo

 --- Steven Nakhla <sd...@yahoo.com> 的正文:> I am
still learning about EJBs, Struts, and a whole
> host of other things.  I'm writing a simple web app
> to manage my product license keys.  I have 3 CMR
> EJBs that I'm working with:  ProductVendor, Product,
> and LicenseKey.  The beans are created such that a
> ProductVendor can have multiple Products, each of
> which can have multiple LicenseKeys.  
>  
> In my web app, I would like to be able to list all
> of the entries in my database.  In my Struts Action,
> I perform a findAll() to return a Collection of
> ProductVendors, and then call
> request.setAttribute("vendorList", vendors); so it
> can be referenced from my JSP.
>  
> In my JSP, I have the following to iterate over the
> list and display the entries:
> 
> <logic:iterate id="vlist" name="vendorList">
> 
> <bean:write name="vlist" property="name" />
> 
> <ul>
> 
> <logic:iterate id="plist" name="vlist"
> property="products">
> 
> <li><bean:write name="plist" property="title"
> /></li>
> 
> </logic:iterate>
> 
> </ul>
> 
> </logic:iterate>
> 
>  
> 
> Everything looks like it is in order.  However, when
> I try to display the JSP I get the following
> exception:  org.apache.jasper.JasperException: A CMR
> collection may only be used within the transction in
> which it was created.
> 
> Can anyone explain to me what the problem is?  Does
> anyone know how I could go about displaying the list
> like I would like?  I'd really appreciate any help
> you could give this poor newbie.  Thanks in advance!
> 
>  
> 
> Steve Nakhla
> 
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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