On 05.Feb.2003 -- 04:53 PM, Cyril Vidal wrote:
> I think I'm on the point of being successful with my business.
> But I still have one question, considering the following  short code and
> especially the uncommented snippet: (serves to retrieve and display all the
> items of the current session)
> 
> 
> <?xml version="1.0"?>
> 
> <xsp:page
> 
> xmlns:xsp="http://apache.org/xsp";
> 
> xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> 
> xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> 
> create-session="true">
> 
> <xsp:structure>
> 
> <xsp:include>java.util.Vector</xsp:include>
> 
> </xsp:structure>
> 
> <content>
> 
> <xsp:logic>
> 
> Object items = <xsp-session:get-attribute name="cart.items"/>;
> 
> if (items == null) items = new Vector(10,5);
> 
> ((Vector) items).add(<xsp-request:get-parameter name="item"/>);
> 
> session.setAttribute("cart.items",items);
> 
> 
> 
> /**************Error here:  method get() and variable i are not known from
> Cocoon's servlet
> 
> <ul>
> 
> for (int i=0; i&lt;items.size(); i++) {

Mind you that items is declared of type Object because that cast to
Vector might result in a NPE when applied to null. Thus size() and
get() method are not declared for this object! You need to cast it
first (and probably assign it to a variable of type vector).

> <li><xsp:expr>items.get(i)</xsp:expr></li>
> 
> }
> 
> </ul>
> 
> **************/
> 
> </xsp:logic>
> 
> </content>
> 
> </xsp:page>

        Chris.
-- 
C h r i s t i a n       H a u l
[EMAIL PROTECTED]
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to