cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe LAPLANCHE" <>
Subject RE: jx template and arrays ... I need help
Date Mon, 03 Apr 2006 15:26:35 GMT
It works with JXpath expressions :

With this, I get What I need :


I need the number 5 to be replaced with the value of account.payer.lines.currentLineIndex
So I thought of putting this value inside a variable using jx:set :

This works
<jx:set var="lineIndex" value="${account.payer.lines.currentLineIndex}"/>
var :${lineIndex} <br/>
But this doesn't work : 
<jx:set var="lineIndex" value="#{account/payer/lines/currentLineIndex}"/>
var :#{$lineIndex} <br/>

I then need to do something like that :
<jx:set var="line" value="#{account/payer/lines[$lineIndex + 1]}"/>

So that I can get #{$line/CL1data/CL1_NUMLIG} or #{$line/CL1data/CL1_PRODUI}

But I'm stuck again...

To answer your question, I'm using javascript Objects, and javascript Arrays. I took the petsotre
block as an inspiration to build my webapp. Everything is in flowscript ... I use this code
to instanciate account.payer :

account = new Object();
account.payer = new Payer();

function Payer(codcli,codpay) { = null;
	this.lines = null;

And to fill the array of lines, I use the javascript push() function like this :


Payer.prototype.fetchLines = function () {
	this.lines = [];
	var line = null;
	try {
		var conn = Database.getConnection("gptodb");
		var resultCL1 = conn.query("select * from CL1 where CL1_CODCLI = ? and CL1_PAYEUR = ?",
    	for (var i in resultCL1.rows) {
	    	line = new Line();
	    	line.CL1data = resultCL1.rows[i];
    } catch(e) {


-----Message d'origine-----
De : Jason Johnston [] 
Envoyé : samedi 1 avril 2006 04:15
À :
Objet : Re: jx template and arrays ... I need help

Philippe LAPLANCHE wrote:
> In my JXTemplate, this expression returns nothing: 
> ${account.payer.lines[5].CL1data.CL1_NUMLIG}
> But in my flow, just before I call the sendPage() function, this
> expression gives an int (I checked with the debugger)
> My object seems to be correctly passed and the arrays of lines is really
> there. Here's how I know :
> <jx:forEach var="line" varStatus="status" items="${account.payer.lines}"
> 	${line.CL1data.CL1_NUMLIG} <br/>
> </jx:forEach>
> This returns a list with all the data I need.
> Can someone understand what is happening here?
> I'm using Cocoon 2.1.8 under win XP with Tomcat 5.5 and SUN JDK 1.5

When you say "array"... what exactly is the lines object?  A true Java
Array?  A JavaScript array you created in flowscript?  Something else?

In my experience JXPath expressions are more flexible in the kinds of
objects they know how to traverse, compared to Jexl expressions.  Try:
#{account/payer/lines[6]/CL1data/CL1_NUMLIG} and see if it has any
better luck.  Keep in mind [n] indexes in XPath are 1-based.

To unsubscribe, e-mail:
For additional commands, e-mail:

Wanadoo vous informe que cet  e-mail a ete controle par l'anti-virus mail. 
Aucun virus connu a ce jour par nos services n'a ete detecte.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message