You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by H....@MI.unimaas.nl on 2004/04/15 23:30:50 UTC

Jexl and JXPath give different results!

Hi,

I've been fiddling around with retrieving info from a custom built object.
For clarity I'll explain the object here:

Class Person {
  private Hashtable cocoonTraits;
  private String ID;
  ....
  public String getID() { return ID; }
  public Map getTraits() { return cocoonTraits;  }
}

Class CocoonTrait {
  private Hashtable cocoonTraits;
  private Hashtable cocoonValues;
  private String name;
  ....
  public String getName() { return name; }
  public Map getTraits() { return cocoonTraits;  }
  public Map getValues() { return cocoonValues;  }
}

Class CocoonValue {
  private String name;
  private Object value;
  ....
  public String getName() { return name; }
  public Object getValue() { return value; }
}

I've instantiated the above and added some values to the CocoonValue
objects. Then I want to display them:

<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<html>
<head><title>A person</title></head>
<body>
	<p>A person = ${person.ID} </p>
	<table border="1">
	<jx:forEach var="trait" select="${person.traits}">
		<tr><td colspan="2">Trait = ${trait.name}</td></tr>
		<jx:forEach var="value" select="${trait.values}">
		<tr>
		<td>${value.name}</td><td>${value.value}</td>
		</tr>
		</jx:forEach>
	</jx:forEach>
	</table>
	
	<table border="1">
	<jx:forEach select="#{person/traits}">
	<tr>
	<td colspan="2">#{./name}</td>
	</tr>
	<jx:forEach select="#{values}">
		<tr>
		<td>#{./name}</td><td>#{./value}</td>
		</tr>
	</jx:forEach>
	</jx:forEach>
	</table>
</body>
</html>
</jx:template>

The first table correctly shows all Trait names and all Value names and the
values of those that are filled in.
The second table only shows:

<table border="1">
<tr>
<td colspan="2">nl.unimaas.mi.proper.pids.CocoonTrait@1991ba7</td>
</tr>
</table>

So either I've done something wrong in the syntax (which I cannot conclude
from the docs}, or there is something really wrong.

Bye, Helma