cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cyril Vidal" <cy...@planetexml.com>
Subject Re: xsp session logicsheet
Date Wed, 05 Feb 2003 15:53:04 GMT
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++) {

<li><xsp:expr>items.get(i)</xsp:expr></li>

}

</ul>

**************/

</xsp:logic>

</content>

</xsp:page>



Why do I receive the following two errors:

Line 174, column 58:  variable i not found in class
org.apache.cocoon.www.mount.essai.session3_xsp
Line 174, column 54:  method get() not found in class java.lang.Object


Is the syntax  I am using here not the same as the following, which is OK?



<elements>

<xsp:logic>

for (int i=1; i&lt;11; i++)

{

<element><xsp:expr>i</xsp:expr></element>

}

</xsp:logic>

</elements>



Which is the difference between them?



Regards,

Cyril

----- Original Message -----
From: "Christian Haul" <haul@dvs1.informatik.tu-darmstadt.de>
To: <cocoon-users@xml.apache.org>
Sent: Wednesday, February 05, 2003 3:19 PM
Subject: Re: xsp session logicsheet


> On 05.Feb.2003 -- 02:56 PM, Cyril Vidal wrote:
> > Hello Christian,
> >
> > Thanks again for your help and your availibility.
> > Of course, I meant Session logicsheet and not ESQL one...Sorry...
> > I've tried to launch the code you've suggested:
> >
> > <?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">
>
> The class Vector is unknown here. Add
>
>   <xsp:structure>
>      <xsp:include>java.util.Vector</xsp:include>
>   </xsp:structure>
>
> in order to create an import statement.
>
> Add some markup here, otherwise the following code won't be inside the
> generate() method but would be expected to be a valid method
> declaration.
>
> <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"/>);
> >
> > request.getSession().setAttribute(items);
> >
> > // logicsheet only supports setting Strings objects :-(
> >
> > // thus do it manually.
> >
> > </xsp:logic>
>
> </content>
>
> > </xsp:page>
>
> > Regards,
> > Cyril.
> > PS: In the code, you've written:
> > request.getSession().setAttribute(items);
> >
> > shall we not write instead
> >
> > request.getSession().setAttribute("cart-item", items);
> >
> > as in the traditional java servlet?
>
> Absolutely, you are right. And the other poster is also right that
> there is a variable named "session" if the session logicsheet is
> used. Thus it suffices to write
>
>   session.setAttribute("cart.items", items);
>
> Chris.
>
> BTW when writing to the list you don't need to CC me -- it will end up
> in the same mailbox anyway (as duplicates).
>
> --
> C h r i s t i a n       H a u l
> haul@informatik.tu-darmstadt.de
>     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:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
>
>



---------------------------------------------------------------------
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message