AW: xsp + parameters

2002-12-31 Thread Nils Leßmann
Hi,

have a look in the generated java file (search for factoriel_xsp.java),
that's usually the fastest way to see what's really going on.

Anyway, I'd suggest using a second method

public static String get_fac(String number) {
  try {
long l = Long.parseLong(number);
return fac(l);
  } catch (NumberFormatException e) {
return number+" not a number";
  }
}
 
and calling this from the xsp.

Nils
 

-Ursprüngliche Nachricht-
Von: cyril vidal [mailto:[EMAIL PROTECTED]] 
Gesendet: Dienstag, 31. Dezember 2002 11:08
An: [EMAIL PROTECTED]
Betreff: Re: xsp + parameters


So, I've tried the following code, in the aim to convert String to long:
 result:
fac(java:lang.Long.parseLong())

but it doesn't run:
Error compiling factoriel_xsp: Line 127, column 57: ')' expected. Line
0,
column 0: 1 error



-
Please check that your question  has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




Re: xsp + parameters

2002-12-31 Thread cyril vidal
Hi,

Thanks for your response. When I do the following:


>
> Try something like:
>
> result: fac( name="number" default="0"/>)
>

I obtain such an error message:

description org.apache.cocoon.ProcessingException: Language Exception:
org.apache.cocoon.components.language.LanguageException: Error compiling
factoriel_xsp: Line 128, column 32: Incompatible type for method. Can't
convert java.lang.String to long. Line 0, column 0: 1 error

So, I've tried the following code, in the aim to convert String to long:
 result:
fac(java:lang.Long.parseLong())

but it doesn't run:
Error compiling factoriel_xsp: Line 127, column 57: ')' expected. Line 0,
column 0: 1 error

Cyril.



-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




Re: xsp + parameters

2002-12-30 Thread Jim Bearce

Try something like:

result: fac()



cyril vidal wrote:

Hi,
 
I would like to calculate the factorial of a number via XSP. The 
number should be transmitted as a parameter via HTTP.
 
The code I've got for this purpose is the following: it retrieves the 
parameter 'number' and defines a fac method, that calculates the 
factorial of its formal parameter.
My problem: I don't know the syntax to calculate the fac() for the 
parameter 'number'. For the moment, I'm just able to calculate fac(8) 
or fac(13), and it runs well; but itsn't exactly what I want...
 





xmlns:xsp="http://apache.org/xsp";

xmlns:xsp-request="http://apache.org/xsp/request/2.0";>



public static long fac(long n) {

if (n>1) return (fac(n-1)*n);

else return 1;

}











 

result: fac(8)





 

I would be very grateful for any assistance,

Thanks,

Cyril.



-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




xsp + parameters

2002-12-30 Thread cyril vidal



Hi,
 
I would like to calculate the 
factorial of a number via XSP. The number should be transmitted as a parameter 
via HTTP.
 
The code I've got for this purpose is 
the following: it retrieves the parameter 'number' and defines a fac method, 
that calculates the factorial of its formal parameter.
My problem: I don't know the syntax 
to calculate the fac() for the parameter 'number'. For the moment, I'm just able 
to calculate fac(8) or fac(13), and it runs well; but itsn't exactly what I 
want...
 



xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">

public static long fac(long n) {
if (n>1) return (fac(n-1)*n);
else return 1;
}





 
result: 
fac(8)


 
I would be very grateful for any 
assistance,
Thanks,
Cyril.