You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Andrew Madu <an...@gmail.com> on 2006/02/23 03:17:34 UTC

Cast type in flowscript

Hi,
can someone remind me how to cast types in flowscript? What I have is:

var response = (DoDirectPaymentResponseType) caller.call 
("DoDirectPayment", request);

regards

Andrew

Re: Cast type in flowscript [ Javaflow]

Posted by Simone Gianni <s....@thebug.it>.
Hi Jason,
I made a quick experiment with javaflow. Yeah, you are completely right, 
global variables DOES NOT span sessions, static ones does. They are 
initialized for each user session, and when the sitemap changes if 
sitemap gets reloaded. They are not bound to continuations, that means 
that if I initialize private int a = 1, then check a value and send a 
form, the set a = 2, if the user hits the back button "a" will still be 
2. So, they should not be used for "state" informations with a scope 
smaller than user session, but can safely be initialized with session 
values.

Sorry for saying uncorrect things, I'm sure i had problems with global 
variables spaning different sessions in flowscript back in 2.1.6 and 
thought this remained unchanged 'till now.

Simone

Jason Johnston wrote:

>Simone Gianni wrote:
>  
>
>>Hey, pay attention. In Javaflow AND in flowscript, global variabiles are
>>quite dangerous : they are global in the real sense, can span different
>>user sessions, you should not use them if not for singleton classes, or
>>other really global data like configuration.
>>    
>>
>
>I'm pretty sure this is not correct; at least in flowscript global
>variables (explicitly declared with the var keyword in global scope) are
>attached to the user session and do not span across sessions.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>


Re: Cast type in flowscript [ Javaflow]

Posted by Jason Johnston <co...@lojjic.net>.
Simone Gianni wrote:
> Hey, pay attention. In Javaflow AND in flowscript, global variabiles are
> quite dangerous : they are global in the real sense, can span different
> user sessions, you should not use them if not for singleton classes, or
> other really global data like configuration.

I'm pretty sure this is not correct; at least in flowscript global
variables (explicitly declared with the var keyword in global scope) are
attached to the user session and do not span across sessions.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript [ Javaflow]

Posted by Andrew Madu <an...@gmail.com>.
Hey Simone,

> wow, lots of questions :)

your email came through just as I sent one back ;-)

Many thanks

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Re[2]: Cast type in flowscript [ Javaflow]

Posted by Andrew Madu <an...@gmail.com>.
g[R]eK,

> newUser.setFirstName(bizData.getMap().get("fname"));

ahhhhhhhhh! I continue to cross purpose myself here ;-)

many thanks

Andrew

Re[2]: Cast type in flowscript [ Javaflow]

Posted by "g[R]eK" <gr...@crispymail.com>.
Hello Andrew!

> Hey guys,

>>     VarMap bizdata = new VarMap();
>>     bizdata.put("user", user);

> i'm doing something very silly here but can't figure it at all....

>                         VarMap bizData = new VarMap()
>                         .add("fname", model.lookupWidget("fname").getValue());
>                         
>                         ......
>                         newUser.setFirstName(bizData.fname);

It's java, so you have forget about all magic you used to have in flowscript ;-)
Try:
newUser.setFirstName(bizData.getMap().get("fname"));
and take a look at:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/flow/java/VarMap.html

HTH

-- 
 g[R]eK


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript [ Javaflow]

Posted by Andrew Madu <an...@gmail.com>.
Hey guys,

>     VarMap bizdata = new VarMap();
>     bizdata.put("user", user);

i'm doing something very silly here but can't figure it at all....

			VarMap bizData = new VarMap()
			.add("fname", model.lookupWidget("fname").getValue());
			
			......
			newUser.setFirstName(bizData.fname);

This gives me bizData.fname cannot be resolved or is not a field.  
What am I doing wrong?

many thanks

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript [ Javaflow]

Posted by Simone Gianni <s....@thebug.it>.
Hi Andrew,
yeah, sorry, you have to explictly cast it :

Form model = (Form)fi.getModel();

Simone

Andrew Madu wrote:

>  Simone,
>
>> Form form = fi.getModel();
>
>
> this incorrect as I get a 'Type mismatch: cannot convert from widget  
> to form' error. What is the issue here?:
>
>             FormInstance fi = new FormInstance("forms/register.xml");
>             fi.show("register1.xml", new VarMap()
>                     .add("msg",Registermsg)
>                     .add("newOrderReg2",neworderreg2));
>            
>             Form model = fi.getModel();
>
> many thanks
>
> Andrew
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript [ Javaflow]

Posted by Andrew Madu <an...@gmail.com>.
  Simone,

> Form form = fi.getModel();

this incorrect as I get a 'Type mismatch: cannot convert from widget  
to form' error. What is the issue here?:

			FormInstance fi = new FormInstance("forms/register.xml");
			fi.show("register1.xml", new VarMap()
					.add("msg",Registermsg)
					.add("newOrderReg2",neworderreg2));
			
			Form model = fi.getModel();

many thanks

Andrew



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript [ Javaflow]

Posted by Simone Gianni <s....@thebug.it>.
Andrew Madu wrote:

>
> sorry for being a pain but i'm still not clear about the form 
> implementation.
>
> var form = new Form("forms/register.xml");
> form.showForm("register1.xml", {"msg":Registermsg, "newOrderReg2" : 
> neworderreg2});
>
> becomes:
>
> FormInstance fi = new FormInstance("forms/register.xml");
>
> fi.createBinding("register1.xml",new VarMap()
> .add("msg":Registermsg)
> .add("newOrderReg2" : neworderreg2);

Nope. You have 2 files for each form, a definition and a template. 
Optionally you can have a binding. Also, you need a pipe in the sitemap 
to show the form. In javascript you use :

var form = new Form("definition");
form.showForm("pipe", {"key: variable});

in this case, you are not using a binding. So, this in javaflow is :

FormInstance fi = new FormInstance("definition");
fi.show("pipe", new VarMap().add("key", variable));

The fi.createBinding is used to assign a binding to the form instance. 
fi.load is used once you have a binding to "transfer" values from  a 
bean or xml document to widget fields, while fi.save transfers values 
from the form widgets to the bean or document.

> ---------------------------------------------------   
>                
> var model = form.getModel();
>
> becomes:
>
> fi.getModel model = fi.getModel(); ????

fi.getModel() returns a org.apache.cocoon.forms.formmodel.Form, that is 
the underlying form object. So you can do :

Form form = fi.getModel();
form.lookupWidget(.....).getValue();
etc..etc..

>
> many thanks 
>
> Andrew
>
Simone

-- 
Simone Gianni

Re: Cast type in flowscript [ Javaflow]

Posted by Andrew Madu <an...@gmail.com>.
Hi Simone,

>     FormInstance fi = new FormInstance("cart.def.xml");
>     fi.createBinding("cart.bnd.xml");
>     fi.load(cart);
>     fi.show("cart", bizdata);

sorry for being a pain but i'm still not clear about the form  
implementation.

var form = new Form("forms/register.xml");
form.showForm("register1.xml", {"msg":Registermsg, "newOrderReg2" :  
neworderreg2});

becomes:

FormInstance fi = new FormInstance("forms/register.xml");

fi.createBinding("register1.xml",new VarMap()
.add("msg":Registermsg)
.add("newOrderReg2" : neworderreg2);
---------------------------------------------------

var model = form.getModel();

becomes:

fi.getModel model = fi.getModel(); ????

many thanks

Andrew

	


Re: Cast type in flowscript [ Javaflow]

Posted by Simone Gianni <s....@thebug.it>.
Hi Andrew,
wow, lots of questions :)

Andrew Madu wrote:

> Hi Simone,
> many thanks for your reply. Would you by any chance have an example of 
> a very simple process done in a .js and .java version? 
>
> I take it that I can still reference the java classes from my sitemap 
> as I would do the flowscripts?:
>
>
>  <map:flow language="java">
>   <map:script src="flow/login.class"/>
>  </map:flow>

Nearly. In the normal way, the class must be in classpath (so either a 
jar in WEB-INF/lib or in classes) and referenced with its fully 
qualified name, so for example <map:script 
src="com.mycompany.myproject.cart.ShoppingCartFlow"/> . This 
unfortunately means that you will have to recompile your flows and 
restart the server for each change you make.

Another approach is the compiling classloader, that compiles from source 
code, and thus avoids all the rebuild/restart problems. I haven't used 
this myself, and can't give you much help on this subject.

>
> How would I reference method calls from the site map to java methods? 
> In javascript it would be:
>
> <map:call function="terms">
> <map:parameter name="page_Name" value="account"/>
> </map:call>
>
> Would I be correct in thinking that I would do:
>
> <map:call login.user="terms">
> <map:parameter name="page_Name" value="account"/>
> </map:call>

Unfortunately no. Every method you wish to call from the sitemap must be 
public, void, with no parameters, and called doSomethingToDo. You will 
then call it from the sitemap with <map:call function="somethingToDo"/> 
. The "function name space" is flat, so if you have two methods with the 
same name in two different classes (or in two different javascripts) it 
will be a problem.

>
> How would I read the parameter into the class/method from the sitemap? 
> Like so?:
>
> private String artistID = cocoon.parameters.artistID;

Nearly : String artistID = getParameters().get("artistID");

>
> Would I pass it from the sitemap the same was as shown 
> above?: <map:parameter name="page_Name" value="account"/>

Yes, the same.

>
> What about persisting data? I have a variable which persists a user 
> object after a user has logged in:
>
> var userGlobal = cocoon.session.getAttribute("user");
>
> Would the javaflow equiv be:
>
> private Object userGlobal = cocoon.session.getAttribute("user"); ???

Hey, pay attention. In Javaflow AND in flowscript, global variabiles are 
quite dangerous : they are global in the real sense, can span different 
user sessions, you should not use them if not for singleton classes, or 
other really global data like configuration.

Also, they are not continuation-safe, so i always go for local variables :

// This is a singleton class, so no danger in using it as global.
private ShoppingCartManager cartManager = ShoppingCartManager.getInstance();

public void doSomethingToDo() {
    String user = getRequest().getSession().getAttribute("user");
    ShoppingCart cart = cartManager.findCartForUser(user);

    VarMap bizdata = new VarMap();
    bizdata.put("user", user);
   
    FormInstance fi = new FormInstance("cart.def.xml");
    fi.createBinding("cart.bnd.xml");
    fi.load(cart);
    fi.show("cart", bizdata);
    ....
}

I'm going by heart, so i apologize in advance for errors :)

>
> How do i represent forms in javaflow:
>
> var form = new Form("forms/artistOrder.xml");
> form.showForm("artistLyricsPopUp1.xml",{"artistID":artistID,"artist_name":artist_name,"artist_info":artist_info,"track_lyrics":track_lyrics,"track_title":track_title,"userGlobal":userGlobal});
> var model = form.getModel();
> var bizData = {"next" : model.next, "delItem" : model.delItem, 
> "quantity" : model.quantity}
>
See previous example.

> and finally would I be correct in thinking that continuation is still 
> represented as:
>
> cocoon.sendPageAndWait("artistDetails2.xml",{"artistID":artistID});

sure :

VarMap bizdata = new VarMap();
bizdata.put("artistID", artistID);
sendPageAndWait("artistDetails2.xml",bizdata);


>
> many thanks
>
> Andrew
>
You're welcome.

Simone

-- 
Simone Gianni

Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
Hi Simone,
many thanks for your reply. Would you by any chance have an example  
of a very simple process done in a .js and .java version?

I take it that I can still reference the java classes from my sitemap  
as I would do the flowscripts?:


  <map:flow language="java">
  	<map:script src="flow/login.class"/>
  </map:flow>

How would I reference method calls from the site map to java methods?  
In javascript it would be:

				<map:call function="terms">
					<map:parameter name="page_Name" value="account"/>
				</map:call>

Would I be correct in thinking that I would do:

				<map:call login.user="terms">
					<map:parameter name="page_Name" value="account"/>
				</map:call>

How would I read the parameter into the class/method from the  
sitemap? Like so?:

private String artistID = cocoon.parameters.artistID;

Would I pass it from the sitemap the same was as shown above?:  
<map:parameter name="page_Name" value="account"/>

What about persisting data? I have a variable which persists a user  
object after a user has logged in:

var userGlobal = cocoon.session.getAttribute("user");

Would the javaflow equiv be:

private Object userGlobal = cocoon.session.getAttribute("user"); ???

How do i represent forms in javaflow:

		var form = new Form("forms/artistOrder.xml");
		form.showForm("artistLyricsPopUp1.xml", 
{"artistID":artistID,"artist_name":artist_name,"artist_info":artist_info 
,"track_lyrics":track_lyrics,"track_title":track_title,"userGlobal":user 
Global});
		var model = form.getModel();
		var bizData = {"next" : model.next, "delItem" : model.delItem,  
"quantity" : model.quantity}

and finally would I be correct in thinking that continuation is still  
represented as:

	cocoon.sendPageAndWait("artistDetails2.xml",{"artistID":artistID});

many thanks

Andrew

> Hi Andrew,
> JavaFlow is the same thing as FlowScript, but instead of writing  
> javascript files, you write common java classes. The rest is  
> basically the same, you have sendPage, sendPageAndWait, can  
> instantiate and send forms etc.. etc..
>
> The main advantages of JavaFlow are :
> - You use java, which is typed, so you son't have problems with  
> overloading, polymorphism etc..
> - You have compile time checking, that you don't have in javascript  
> since it's not compiled.
> - You use common java developement tools, like any java editor and  
> debugger (Eclipse works for me), even remotely on a test server and  
> not only the embedded venkmann debugger only on the delevoper machine.
> - You avoid common javascript nightmares ( if (c && (c == 'true' ||  
> c == true)) ) etc.. etc..
>
> It also have drawbacks :
> - Javascript is usually considered easier to write
> - The BCEL rewritings that are made automatically on java classes  
> to make them continuation aware are sometimes weird.
>
> I personally find myself much more happy with javaflow, since  
> compile time code checking is a must, and since i usually write  
> flows that  use a java backend, and it's much more simpler to use  
> it directly in java than in javascript. This is expecially true if  
> you have a complex backend (with polymorphism and/or other design  
> patterns) where untyped javascript (and the consequent rhino  
> guesses) can cause hard to find bugs or even disasters. Also, quite  
> commonly the backend and frontend are developed by different teams,  
> with javascript you have no way to check if a change in the backend  
> can cause problems to frontend flows, while with javaflow automatic  
> refactoring is applied also in flows, and backend guys can quickly  
> check if they broke something.
>
> Simone
>
>
>
> Andrew Madu wrote:
>> Hi Jason,
>>
>>> Or you could move
>>> to JavaFlow if you'd rather go that way.
>>
>> do you know of any good documentation that describes the  
>> conversion process required to get from flowscript to javaflow?  
>> I've had a quick look at the javaflow docs under cocoon and they  
>> make little sense to me at this moment.
>>
>> Does JavaFlow support continuations?
>>
>> Andrew
>


Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.

> I personally find myself much more happy with javaflow, since  
> compile time code checking is a must, and since i usually write  
> flows that  use a java backend, and it's much more simpler to use  
> it directly in java than in javascript. This is expecially true if  
> you have a complex backend (with polymorphism and/or other design  
> patterns) where untyped javascript (and the consequent rhino  
> guesses) can cause hard to find bugs or even disasters. Also, quite  
> commonly the backend and frontend are developed by different teams,  
> with javascript you have no way to check if a change in the backend  
> can cause problems to frontend flows, while with javaflow automatic  
> refactoring is applied also in flows, and backend guys can quickly  
> check if they broke something.

For anyone interested in the similarity between fowscript and  
javaflow, from a syntactic point of view, I came across this very  
good IBM tutorial which breaks things down into sitemap instantiation  
of classes, sitemap calls to methods (still via map:call  
function='method name"). Yo can view the article here:

http://www-128.ibm.com/developerworks/library/j-contin.html

The only thing it didn't reveal is how to implement is how to implement

		var form = new Form("forms/artistOrder.xml");
		form.showForm("artistLyricsPopUp1.xml",{"artistID":artistID});
		var model = form.getModel();
		var bizData = {"next" : model.next, "delItem" : model.delItem,  
"quantity" : model.quantity}

Anyone?

Andrew

Re: Cast type in flowscript

Posted by Simone Gianni <s....@thebug.it>.
Hi Andrew,
JavaFlow is the same thing as FlowScript, but instead of writing 
javascript files, you write common java classes. The rest is basically 
the same, you have sendPage, sendPageAndWait, can instantiate and send 
forms etc.. etc..

The main advantages of JavaFlow are :
- You use java, which is typed, so you son't have problems with 
overloading, polymorphism etc..
- You have compile time checking, that you don't have in javascript 
since it's not compiled.
- You use common java developement tools, like any java editor and 
debugger (Eclipse works for me), even remotely on a test server and not 
only the embedded venkmann debugger only on the delevoper machine.
- You avoid common javascript nightmares ( if (c && (c == 'true' || c == 
true)) ) etc.. etc..

It also have drawbacks :
- Javascript is usually considered easier to write
- The BCEL rewritings that are made automatically on java classes to 
make them continuation aware are sometimes weird.

I personally find myself much more happy with javaflow, since compile 
time code checking is a must, and since i usually write flows that  use 
a java backend, and it's much more simpler to use it directly in java 
than in javascript. This is expecially true if you have a complex 
backend (with polymorphism and/or other design patterns) where untyped 
javascript (and the consequent rhino guesses) can cause hard to find 
bugs or even disasters. Also, quite commonly the backend and frontend 
are developed by different teams, with javascript you have no way to 
check if a change in the backend can cause problems to frontend flows, 
while with javaflow automatic refactoring is applied also in flows, and 
backend guys can quickly check if they broke something.

Simone



Andrew Madu wrote:

> Hi Jason,
>
>> Or you could move
>>
>> to JavaFlow if you'd rather go that way.
>>
>
> do you know of any good documentation that describes the conversion 
> process required to get from flowscript to javaflow? I've had a quick 
> look at the javaflow docs under cocoon and they make little sense to 
> me at this moment.
>
> Does JavaFlow support continuations?
>
> Andrew



Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
Hi Jason,

> Or you could move
> to JavaFlow if you'd rather go that way.

do you know of any good documentation that describes the conversion  
process required to get from flowscript to javaflow? I've had a quick  
look at the javaflow docs under cocoon and they make little sense to  
me at this moment.

Does JavaFlow support continuations?

Andrew

Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
Jason,

> It's possible that the problem is elsewhere in your code when
> you're assembling the request object or something like that.

I think you may be correct. I'll keep plodding on and let you know  
what I find out.

regards

Andrew

Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
> I'd try looking through the full stacktrace and narrow down the exact
> location of the ClassCastException

I have run the code as both a standalone Java application and via  
cocoon. The Java application runs fine but the cocoon version, with  
exactly the same code, does not. Here is the full stack trace in  
regards to the ClassCastException from my cocoon:

16:27:10,955 INFO  [APICaller] doDirectPayment sent
16:27:10,964 ERROR [TransactionException] ; nested exception is:
         java.lang.ClassCastException
java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke 
(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke 
(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.paypal.sdk.core.AxisAPICaller.callSOAP(Unknown Source)
         at com.paypal.sdk.core.AxisAPICaller.call(Unknown Source)
         at com.paypal.sdk.services.CallerServices.call(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke 
(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke 
(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.mozilla.javascript.NativeJavaMethod.call 
(NativeJavaMethod.java:230)
         at org.mozilla.javascript.ScriptRuntime.call 
(ScriptRuntime.java:1244)
         at  
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret 
(ContinuationInterpreter.java:1134)
         at  
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret 
(ContinuationInterpreter.java:190)
         at  
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret 
(ContinuationInterpreter.java:138)
         at  
org.mozilla.javascript.continuations.InterpretedFunctionImpl.call 
(InterpretedFunctionImpl.java:121)
         at org.mozilla.javascript.ScriptRuntime.call 
(ScriptRuntime.java:1244)
         at org.mozilla.javascript.ScriptableObject.callMethod 
(ScriptableObject.java:1591)
         at  
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpret 
er.handleContinuation(FOM_JavaScriptInterpreter.java:843)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invo 
ke(CallFunctionNode.java:123)
         at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.SelectNode.invoke 
(SelectNode.java:97)
         at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:46)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.i 
nvoke(PreparableMatchNode.java:130)
         at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke 
(PipelineNode.java:138)
         at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke( 
PipelinesNode.java:92)
         at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:234)
         at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:176)
         at  
org.apache.cocoon.components.treeprocessor.TreeProcessor.process 
(TreeProcessor.java:243)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke 
(MountNode.java:117)
         at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:46)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.i 
nvoke(PreparableMatchNode.java:130)
         at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke 
(PipelineNode.java:138)
         at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
         at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke( 
PipelinesNode.java:92)
         at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:234)
         at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:176)
         at  
org.apache.cocoon.components.treeprocessor.TreeProcessor.process 
(TreeProcessor.java:243)
         at org.apache.cocoon.Cocoon.process(Cocoon.java:608)
         at org.apache.cocoon.servlet.CocoonServlet.service 
(CocoonServlet.java:1123)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at  
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter 
(ApplicationFilterChain.java:173)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter 
(ReplyHeaderFilter.java:81)
         at  
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter 
(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke 
(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke 
(StandardContextValve.java:178)
         at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke 
(CustomPrincipalValve.java:39)
         at  
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke 
(SecurityAssociationValve.java:153)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke 
(JaccContextValve.java:59)
         at org.apache.catalina.core.StandardHostValve.invoke 
(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke 
(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke 
(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service 
(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process 
(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol 
$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket 
(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run 
(MasterSlaveWorkerThread.java:112)
         at java.lang.Thread.run(Thread.java:552)
Caused by: java.lang.ClassCastException
         at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
         at org.apache.axis.client.Call.invoke(Call.java:1828)
         at  
com.paypal.soap.api.PayPalAPIAASoapBindingStub.doDirectPayment 
(Unknown Source)
         ... 64 more
Caused by: java.lang.ClassCastException
         at org.apache.axis.Message.setup(Message.java:352)
         at org.apache.axis.Message.<init>(Message.java:246)
         at org.apache.axis.client.Call.invoke(Call.java:2425)
         at org.apache.axis.client.Call.invoke(Call.java:2366)
         at org.apache.axis.client.Call.invoke(Call.java:1812)
         ... 65 more

And here are the logs from the java application:


24 Feb 2006 17:11:40 INFO  [AxisAPICaller] doDirectPayment sent
24 Feb 2006 17:11:40 DEBUG [DefaultSOAPHandler] <?xml version="1.0"  
encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/ 
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"  
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"  
soapenv:mustUnderstand="1">
<ebl:Credentials xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
<ebl:Username>andrewmadu_api1.gmail.com</ebl:Username>
<ebl:Password>*******</ebl:Password>
<ebl:Subject/>
</ebl:Credentials>
</RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<DoDirectPaymentReq xmlns="urn:ebay:api:PayPalAPI">
<DoDirectPaymentRequest>
<ns1:Version xmlns:ns1="urn:ebay:apis:eBLBaseComponents">2.10</ 
ns1:Version>
<ns2:DoDirectPaymentRequestDetails  
xmlns:ns2="urn:ebay:apis:eBLBaseComponents">
<ns2:PaymentAction>Sale</ns2:PaymentAction>
<ns2:PaymentDetails>
<ns2:OrderTotal currencyID="USD">20.00</ns2:OrderTotal>
</ns2:PaymentDetails>
<ns2:CreditCard>
<ns2:CreditCardType>Visa</ns2:CreditCardType>
<ns2:CreditCardNumber>XXXX</ns2:CreditCardNumber>
<ns2:ExpMonth>11</ns2:ExpMonth>
<ns2:ExpYear>2007</ns2:ExpYear>
<ns2:CardOwner>
<ns2:PayerName>
<ns2:FirstName>SDK</ns2:FirstName>
<ns2:LastName>Buyer</ns2:LastName>
</ns2:PayerName>
<ns2:PayerCountry>US</ns2:PayerCountry>
<ns2:Address>
<ns2:Street1>123 Main St</ns2:Street1>
<ns2:CityName>San Jose</ns2:CityName>
<ns2:StateOrProvince>CA</ns2:StateOrProvince>
<ns2:Country>US</ns2:Country>
<ns2:CountryName>US</ns2:CountryName>
<ns2:PostalCode>95101</ns2:PostalCode>
</ns2:Address>
</ns2:CardOwner>
<ns2:CVV2>XXX</ns2:CVV2>
</ns2:CreditCard>
<ns2:IPAddress>12.36.5.78</ns2:IPAddress>
<ns2:MerchantSessionId>456977</ns2:MerchantSessionId>
</ns2:DoDirectPaymentRequestDetails>
</DoDirectPaymentRequest>
</DoDirectPaymentReq>
</soapenv:Body>
</soapenv:Envelope>

24 Feb 2006 17:11:41 DEBUG [PPCrypto] PPCrypto.p12ToKeyStore,  
keystore = /Library/jboss-4.0.2/server/default/cert/paypal_cert_usa.p12
24 Feb 2006 17:11:47 DEBUG [DefaultSOAPHandler] <?xml version="1.0"  
encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/ 
envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http:// 
www.w3.org/2001/XMLSchema"  
xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http:// 
schemas.xmlsoap.org/ws/2002/07/utility"  
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http:// 
www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ 
ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents"  
xmlns:ns="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"  
xsi:type="wsse:SecurityType"/>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"  
xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents"  
xsi:type="ebl:UserIdPasswordType">
<Username xsi:type="xs:string"/>
<Password xsi:type="xs:string"/>
<Subject xsi:type="xs:string"/>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<DoDirectPaymentResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp  
xmlns="urn:ebay:apis:eBLBaseComponents">2006-02-24T17:11:47Z</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">5651ec467ec37</ 
CorrelationID>
<Errors xmlns="urn:ebay:apis:eBLBaseComponents"  
xsi:type="ebl:ErrorType">
<ShortMessage xsi:type="xs:string">Retry</ShortMessage>
<LongMessage xsi:type="xs:string">Retry</LongMessage>
<ErrorCode xsi:type="xs:token">10207</ErrorCode>
<SeverityCode>Error</SeverityCode>
</Errors>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">2.100000</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">1.0006</Build>
<CVV2Code xsi:type="xs:string"/>
</DoDirectPaymentResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

24 Feb 2006 17:11:47 INFO  [AxisAPICaller] doDirectPayment Ack :  
Failure  Elapsed Time : 7,806 ms
24 Feb 2006 17:11:47 INFO  [AxisAPICaller] doDirectPayment Error : Retry


As you can see the cocoon app breaks on receipt of the SOAP reply!!  
Any ideas?

Andrew

Re: Cast type in flowscript

Posted by Jason Johnston <co...@lojjic.net>.
I'm not convinced my hunch was correct anymore, now that I've seen the
API... Rhino should already have been selecting the correct overloaded
method.  You should be able to verify that in your full stacktrace.

Assuming that's the case, I can't think of any other obvious problems.
I'd try looking through the full stacktrace and narrow down the exact
location of the ClassCastException, it may give you an idea of what is
trying to be casted to what unsuccessfully and help you narrow down the
issue.  It's possible that the problem is elsewhere in your code when
you're assembling the request object or something like that.

If you still can't get this working in JS you could try putting that
block of logic in a separate Java helper class method and just calling
that method with the appropriate input values; that should avoid the
issues arising from Rhino's runtime type resolution.  Or you could move
to JavaFlow if you'd rather go that way.

Good luck
--Jason


Andrew Madu wrote:
> Jason,
> 
>> If that's the case then I think you can use the technique described at
>>
>> the bottom of
>>
>> http://www.mozilla.org/js/liveconnect/lc3_method_overloading.html (the
>>
>> section "Explicit Method Specification") which should allow you to
>>
>> choose the specific overloaded method to use.
>>
> 
> i'm trying to implement the info you sent me but am having a bit of
> trouble with the syntax. The class in question reads as so:
> 
> public class CallerServices {
> 
> 
>     /**
>      * Initializes the API Caller 
>      * @throws PayPalException 
>     */
>     public void initialize() throws PayPalException
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>
> { 
>         caller
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-488948067>
> = APICallerFactory
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/core/APICallerFactory.source.html#-1822136301>.createAPICaller
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/core/APICallerFactory.source.html#-347892909>(); 
>     }
> 
>     /**
> 
>      * Invokes an API call from a request object
> 
>      * @param operationName name of web service to invoke
> 
>      * @param request request object
> 
>      * @return response object
> 
>      * @throws PayPalException if no profile is set, or an error occurs
> while executing the call
> 
>     */
> 
> *    **public** AbstractResponseType call(String operationName,
> AbstractRequestType request) **throws** **PayPalException*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>*
> {** *
> *        **if (**caller*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-488948067>*
> == null) {*
> **
> *            **this.**initialize*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#1890163899>*();*
> *
> *
> *        **}** *
> *        **return** **caller*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-488948067>*.**call*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/core/APICaller.source.html#612444619>*(**operationName*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-1384803100>*,
> **request*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#1844704353>*);** *
> *    **}*
> 
>     
> 
>     /**
> 
>      * Invokes an API call from an XML request string (NOTE: Used only
> by the console) 
>      * @param operationName name of web service to invoke 
>      * @param requestStr request string
> 
>      * @return response string
>      * @throws PayPalException
> 
>     */
> *    **public** String call(String operationName, String requestStr)
> **throws** **PayPalException*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>*
> {*
> *
> *
> *        **AbstractRequestType request =
> (AbstractRequestType)**XMLSerializer*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#599806693>*.**fromXML*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#741945851>*(**requestStr*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-454823755>*);** *
> *        **AbstractResponseType response = this.**call*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#1581845376>*(**operationName*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-344207329>*,
> **request*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-819333156>*);*
> * *
> *        **return** **XMLSerializer*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#599806693>*.**toXML*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#-1525636627>*(**response*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#423409812>*);** *
> *    **}** *
> }
> 
> The method I am after is:
> 
> * public AbstractResponseType call(String operationName,
> AbstractRequestType request) throws **PayPalException*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>
> 
> So I do the following in my flowscript:
> 
> importClass(Packages.com.paypal.sdk.services.CallerServices);
> ....
> response = CallerServices["call(String, AbstractRequestType)"]; 
> response(5);
> 
> I am now getting the following error message:
> 
> *Java class "com.paypal.sdk.services.CallerServices" has no public
> instance field or method named "call(String, AbstractRequestType)".*
> *
> *
> What am I doing wrong here?
> 
> Andrew
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
Jason,

> If that's the case then I think you can use the technique described at
> the bottom of
> http://www.mozilla.org/js/liveconnect/lc3_method_overloading.html (the
> section "Explicit Method Specification") which should allow you to
> choose the specific overloaded method to use.

i'm trying to implement the info you sent me but am having a bit of  
trouble with the syntax. The class in question reads as so:

public class CallerServices {


     /**
      * Initializes the API Caller
      * @throws PayPalException
     */
     public void initialize() throws PayPalException {
         caller = APICallerFactory.createAPICaller();
     }

     /**

      * Invokes an API call from a request object

      * @param operationName name of web service to invoke

      * @param request request object

      * @return response object

      * @throws PayPalException if no profile is set, or an error  
occurs while executing the call

     */

     public AbstractResponseType call(String operationName,  
AbstractRequestType request) throws PayPalException {
         if (caller == null) {
             this.initialize();

         }
         return caller.call(operationName, request);
     }


     /**

      * Invokes an API call from an XML request string (NOTE: Used  
only by the console)
      * @param operationName name of web service to invoke
      * @param requestStr request string

      * @return response string
      * @throws PayPalException

     */
     public String call(String operationName, String requestStr)  
throws PayPalException {

         AbstractRequestType request = (AbstractRequestType) 
XMLSerializer.fromXML(requestStr);
         AbstractResponseType response = this.call(operationName,  
request);

         return XMLSerializer.toXML(response);
     }
}

The method I am after is:

  public AbstractResponseType call(String operationName,  
AbstractRequestType request) throws PayPalException

So I do the following in my flowscript:

		importClass(Packages.com.paypal.sdk.services.CallerServices);
		....
		response = CallerServices["call(String, AbstractRequestType)"];
		response(5);

I am now getting the following error message:

Java class "com.paypal.sdk.services.CallerServices" has no public  
instance field or method named "call(String, AbstractRequestType)".

What am I doing wrong here?

Andrew




Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
Jason,

> I've tried searching for the paypal API javadocs without success

you can download the javaDocs from here:

https://www.paypal.com/cgi-bin/webscr?cmd=xpt/cps/general/ 
SoftwareDevKit-outside

Downloading the paypal java sdk will give you access to the docs

Andrew

Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
Jason,

> so I'm
> not sure what the caller.call method is expecting as arguments.

I managed to track down the source for class  
com.paypal.sdk.services.CallerServices (caller.call):


http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/ 
package-tree.html

HTH

Andrew

Re: Cast type in flowscript

Posted by Jason Johnston <co...@lojjic.net>.
Andrew Madu wrote:

> var caller = new CallerServices();
> ...
> var request = new DoDirectPaymentRequestType();
> ...
> var response = caller.call("DoDirectPayment", request);
> 

I've tried searching for the paypal API javadocs without success, so I'm
not sure what the caller.call method is expecting as arguments.
Assuming all your other code is correct, my hunch is the caller.call
method is overloaded in a way that Rhino (the javascript engine) cannot
resolve the correct overloaded method to use given the request object.
It may be selecting the wrong overloaded method, resulting in a
ClassCastException within that method.

If that's the case then I think you can use the technique described at
the bottom of
http://www.mozilla.org/js/liveconnect/lc3_method_overloading.html (the
section "Explicit Method Specification") which should allow you to
choose the specific overloaded method to use.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
Jason,

> Can you paste the flowscript surrounding that line so we can get
> some context?

here is the code in full:

	importClass(Packages.com.paypal.sdk.exceptions.PayPalException);
	importClass(Packages.com.paypal.sdk.profiles.APIProfile);
	importClass(Packages.com.paypal.sdk.profiles.ProfileFactory);
	importClass(Packages.com.paypal.sdk.services.CallerServices);
	importPackage(Packages.com.paypal.soap.api);


         var caller = new CallerServices();
	var profile = ProfileFactory.createAPIProfile();

     	profile.setAPIUsername("andrew_api2.beyarecords.com");
     	profile.setAPIPassword("mypassword");
     	profile.setCertificateFile("/Library/jboss-4.0.2/server/default/ 
cert/paypal_cert.p12");
     	profile.setPrivateKeyPassword("mypassword");
     	profile.setEnvironment("sandbox");
     	caller.setAPIProfile(profile);
     	
         var request = new DoDirectPaymentRequestType();
	var details = new DoDirectPaymentRequestDetailsType();
	
	var creditCard = new CreditCardDetailsType();
	creditCard.setCreditCardNumber("4721930402892796");
	creditCard.setCreditCardType(CreditCardTypeType.Visa);
	creditCard.setCVV2("000");
	creditCard.setExpMonth(11);
	creditCard.setExpYear(2007);
	
	var cardOwner = new PayerInfoType();
	cardOwner.setPayerCountry(CountryCodeType.US);
	
	var address = new AddressType();
	address.setPostalCode("95101");
	address.setStateOrProvince("CA");
	address.setStreet1("123 Main St");
	address.setCountryName("US");
	address.setCountry(CountryCodeType.US);
	address.setCityName("San Jose");
	cardOwner.setAddress(address);
	
	var payerName = new PersonNameType();
	payerName.setFirstName("SDK");
	payerName.setLastName("Buyer");
	cardOwner.setPayerName(payerName);

	creditCard.setCardOwner(cardOwner);
	details.setCreditCard(creditCard);

	details.setIPAddress("12.36.5.78");
	details.setMerchantSessionId("456977");
	details.setPaymentAction(PaymentActionCodeType.Sale);
	var payment = new PaymentDetailsType();

	var orderTotal = new BasicAmountType();
	orderTotal.setCurrencyID(CurrencyCodeType.USD);
	orderTotal.set_value("20.00");
	payment.setOrderTotal(orderTotal);

	
	details.setPaymentDetails(payment);
	request.setDoDirectPaymentRequestDetails(details);
	
	var response = new DoDirectPaymentResponseType();
	response = caller.call("DoDirectPayment", request);

regards


Andrew

Re: Cast type in flowscript

Posted by Jason Johnston <co...@lojjic.net>.
Andrew Madu wrote:
>  Jason,
> 
>>> var response = (DoDirectPaymentResponseType)
>>>
>>> caller.call("DoDirectPayment", request);
>>>
>>
>> Javascript does not do compile-time type checking, so "casting" is
>>
>> completely unnecessary.  Just go ahead and access properties and call
>>
>> methods on your response variable; it will let you know at runtime if
>>
>> those methods or properties don't exist.
>>
>>
>>   var response = caller.call("DoDirectPayment", request);
>>
> 
> I tried your suggestion and am getting a class cast exception error:
> 
> *'com.paypal.sdk.exceptions.TransactionException: ; nested exception is:
> java.lang.ClassCastException'*

Is the ClassCastException occurring on the line you pasted above?  I
don't know this API, or what the caller variable is, so it's hard to
help.  Can you paste the flowscript surrounding that line so we can get
some context?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cast type in flowscript

Posted by Andrew Madu <an...@gmail.com>.
  Jason,

>> var response = (DoDirectPaymentResponseType)
>> caller.call("DoDirectPayment", request);
>
> Javascript does not do compile-time type checking, so "casting" is
> completely unnecessary.  Just go ahead and access properties and call
> methods on your response variable; it will let you know at runtime if
> those methods or properties don't exist.
>
>   var response = caller.call("DoDirectPayment", request);

I tried your suggestion and am getting a class cast exception error:

'com.paypal.sdk.exceptions.TransactionException: ; nested exception  
is: java.lang.ClassCastException'

Any suggestions?

regards

Andrew

Re: Cast type in flowscript

Posted by Jason Johnston <co...@lojjic.net>.
Andrew Madu wrote:
> Hi,
> can someone remind me how to cast types in flowscript? What I have is:
> 
> var response = (DoDirectPaymentResponseType)
> caller.call("DoDirectPayment", request);

Javascript does not do compile-time type checking, so "casting" is
completely unnecessary.  Just go ahead and access properties and call
methods on your response variable; it will let you know at runtime if
those methods or properties don't exist.

  var response = caller.call("DoDirectPayment", request);
  var amount = response.getAVSCode(); //successful
  var oops = response.notAMethod(); //runtime error

If you're more comfortable with compile-time type checking and Java in
general you might check out the JavaFlow block which lets you write your
flow in pure Java.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org