You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "M. Amin" <am...@imkenberg.net> on 2000/11/15 01:57:15 UTC

A strange problem

Hi All,
While i navigate through the articles in my xml file (shown below), i
encounterd a very strange
problem (try with it):
First, when i use GotoNext() function only, the navigation works perfectly
but, when i use both GotoNext() and GotoPrevious() functions the navigation
freezes.
The "current" variable in my code freezes to zero it can't increment nor
decrement it.
 why? this question made me a crazy man.
Do you have any solution to this problem ?


/*  My xml file */


<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="ArtWebshop.xsl" type="text/xsl"?>

<xsp:page
  language="java"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>

<xsp:structure>
<xsp:include>com.imkenberg.xml.XmlRecordset</xsp:include>
<xsp:include>com.imkenberg.xml.xmlRecord</xsp:include>
<xsp:include>com.imkenberg.bo.ArticleCondition</xsp:include>
<xsp:include>com.imkenberg.bo.Article</xsp:include>
</xsp:structure>

<xsp:logic>
    public static int current = 0;
    public Long articleno = new Long(0);
    public String shortdesciption = "New Article";
    public String longname = "New Article";
    public Float price = new Float(0);
    public String currency = "DM";
    public String category = "Undefined";

    XmlRecordset rs = new XmlRecordset();

    public void GotoFirst(){
      if (rs.size() >= 1)
      displayArt((com.imkenberg.bo.Article)rs.get(1));
     }

    public void displayArt(com.imkenberg.bo.Article a){
    articleno = a.getArticleno();
    shortdesciption = a.getShortname();
    longname = a.getLongname();
    price = a.getPrice();
    currency = a.getCurrency();
    category = a.getCategory();
    }

    public void GotoNext() {

        if(rs.size() > (current+1)){
         displayArt((com.imkenberg.bo.Article)rs.get(++current));

        }

    }
   public void GotoPrevious() {
    if(current >0){
      displayArticle((com.imkenberg.bo.Article)rs.get(--current));
    }
  }


</xsp:logic>


 <page>
  <xsp:logic>
    if ( current == 0 ){
    rs.Load("/usr/local/jakarta-tomcat/webapps/ROOT/articles.xml");
    GotoFirst();

    }

    if (session == null ){
        session = request.getSession(true);
       }



  </xsp:logic>

  <Art_info>
  <Art_no>
   <xsp:expr>articleno</xsp:expr>
  </Art_no>
  <short_desc>
   <xsp:expr>shortdesciption</xsp:expr>
  </short_desc>
  <longname>
   <xsp:expr>longname</xsp:expr>
  </longname>
  <price>
   <xsp:expr>price</xsp:expr>
  </price>
  <currency>
   <xsp:expr>currency</xsp:expr>
  </currency>
  <category>
   <xsp:expr>category</xsp:expr>
  </category>
 </Art_info>

 <Next_Art>
   <xsp:logic>
    String next_ref = response.encodeUrl("ArtWebshop.xml");

    <xsp:element name="link">
     <xsp:attribute name="href">
      <xsp:expr>next_ref</xsp:expr>
    </xsp:attribute>
      Next
    </xsp:element>
     GotoNext();
   </xsp:logic>
 </Next_Art>

 <Prev_Art>
   <xsp:logic>
    String prev_ref = response.encodeUrl("ArtWebshop2.xml");

    <xsp:element name="link">
     <xsp:attribute name="href">
      <xsp:expr>prev_ref</xsp:expr>
    </xsp:attribute>
      Previous
    </xsp:element>
     GotoPrevious();
   </xsp:logic>
 </Prev_Art>
  </page>
</xsp:page>












M. Amin