cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <res1c...@verizon.net>
Subject Re: Jexl and JXPath give different results! -- reposted!
Date Sun, 18 Apr 2004 19:34:47 GMT
Since #{person/traits} and #{values} are Maps (which are treated as "dynamic" beans by JXPath)
try this: 

<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>
</jx:forEach>



Chris

H.vanderLinden@MI.unimaas.nl wrote:

>I do hope someone can look at this and tell me where I'm wrong.
>
>Bye, Helma
>
>-----Original Message-----
>From: H.vanderLinden@MI.unimaas.nl [mailto:H.vanderLinden@MI.unimaas.nl] 
>Sent: Thursday, 15 April 2004 23:31
>To: dev@cocoon.apache.org
>Subject: 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
>
>  
>


Mime
View raw message