on 09-28-2009 2:53 PM
Givent the following java code:
class myClass {
static int num=0;
static public int getNum() {
++ num;
return num;
}
}
If I call getNum() in XSL as follows
<xsl:value-of select="Java:myCLass.getNum()"/>
<xsl:value-of select="Java:myCLass.getNum()"/>
is the result:
1, 2
or
1, 1?
I want to ouput 1,2, if not, how can I do?
I can not test in sap now ,hence post this thread, thanks.
close this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I remember correctly, ++num will first increment value and THEN assign it to num ... num ++ will assign the value and THEN increment it (available for next time) ...
In your case, it should output 1, 2 etc ! Why not using static int num = 1; and num++; ?
Hope this helps
Chris
Edited by: Christophe PFERTZEL on Sep 28, 2009 4:22 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks.
Well, no matter ++num or num ++.
My point is if num value can being passed through multiple java calls in the transformation.
I mean when each time XSLT call the java method, the XSLT processor init a new process or there is just one process.
If is new process, then we can not view value changes from different java method.
It's fine to hear that it output 1,2 , which is what I want. That means, XSLT just use one process------
And XSLT only can call static java method?
Or it can call the non static methods like: ?
<xsl:variable name="obj" select="java:myClass.new()"/>
<xsl:variable name="test" select="java:obj.xxxx()"/>
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.