You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Cyril Vidal <cy...@planetexml.com> on 2003/02/06 17:09:26 UTC

variable i not found in XSP!

Hi,

Since yesterday, I'm still stuck on the following problem: I can't list the
items contained in a session's attribute of type Vector:
Always the same following error is thrown:
Line 236, column 59:  variable i not found in class
org.apache.cocoon.www.mount.essai.session3_xsp

Below is my code:
<?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>

Vector items = (Vector)<xsp-session:get-attribute name="cart.items"/>;

if (items == null) items = new Vector(10,5);

items.add(<xsp-request:get-parameter name="item"/>);

session.setAttribute("cart.items",items);

**** the snippet below works fine *********


if (!<xsp-session:is-new/>) {

<ul>

<b>The list of items is:</b> <xsp-session:get-attribute name="cart.items"

default="not set"/>

</ul>

}

*** the snippet below doesn't work :-(( *****

if (!<xsp-session:is-new/>) {

<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>

SOmeone one can help me, please?

Regards,

Cyril.




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


Re: variable i not found in XSP!

Posted by Cyril Vidal <cy...@planetexml.com>.
Thanks  for your help Chris!
It's working fine now!

Cyril.


> On 06.Feb.2003 -- 05:09 PM, Cyril Vidal wrote:
> > Hi,
> >
> > Since yesterday, I'm still stuck on the following problem: I can't list
the
> > items contained in a session's attribute of type Vector:
> > Always the same following error is thrown:
> > Line 236, column 59:  variable i not found in class
> > org.apache.cocoon.www.mount.essai.session3_xsp
> >
> > Below is my code:
> > <?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>
> >
> > Vector items = (Vector)<xsp-session:get-attribute name="cart.items"/>;
> >
> > if (items == null) items = new Vector(10,5);
> >
> > items.add(<xsp-request:get-parameter name="item"/>);
> >
> > session.setAttribute("cart.items",items);
> >
> > if (!<xsp-session:is-new/>) {
> >
> > <ul>
>
>   When nesting logic inside markup inside logic, new xsp:logic tags
>   are needed! IOW, you can put markup inside logic without manually
>   switching to e.g. text mode. That is done automatically. But once
>   you are in text mode, logic needs to be escaped again. HTH.
>
>   <xsp:logic>
>
> > for (int i = 0; i &lt; items.size(); i++) {
> >
> > <li><xsp:expr>items.get(i)</xsp:expr></li>
> >
> > }
>
>   </xsp:logic>
>
> > </ul>
> >
> > }
> >
> >
> > </xsp:logic>
> >
> > </content>
> >
> > </xsp:page>
>
> Chris.
> --
> 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:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: variable i not found in XSP!

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 06.Feb.2003 -- 05:09 PM, Cyril Vidal wrote:
> Hi,
> 
> Since yesterday, I'm still stuck on the following problem: I can't list the
> items contained in a session's attribute of type Vector:
> Always the same following error is thrown:
> Line 236, column 59:  variable i not found in class
> org.apache.cocoon.www.mount.essai.session3_xsp
> 
> Below is my code:
> <?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>
> 
> Vector items = (Vector)<xsp-session:get-attribute name="cart.items"/>;
> 
> if (items == null) items = new Vector(10,5);
> 
> items.add(<xsp-request:get-parameter name="item"/>);
> 
> session.setAttribute("cart.items",items);
> 
> if (!<xsp-session:is-new/>) {
> 
> <ul>

  When nesting logic inside markup inside logic, new xsp:logic tags
  are needed! IOW, you can put markup inside logic without manually
  switching to e.g. text mode. That is done automatically. But once
  you are in text mode, logic needs to be escaped again. HTH.

  <xsp:logic>

> for (int i = 0; i &lt; items.size(); i++) {
> 
> <li><xsp:expr>items.get(i)</xsp:expr></li>
> 
> }

  </xsp:logic>

> </ul>
> 
> }
> 
> 
> </xsp:logic>
> 
> </content>
> 
> </xsp:page>

	Chris.
-- 
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>