Re: Flash and WebObjects...Make it Work with XML or other ?
Re: Flash and WebObjects...Make it Work with XML or other ?
- Subject: Re: Flash and WebObjects...Make it Work with XML or other ?
- From: Chuck Hill <email@hidden>
- Date: Thu, 8 Sep 2005 10:33:46 -0700
Nathan,
On Sep 8, 2005, at 8:58 AM, Nathan Walker wrote:
I gave this a try and I am still getting a MalformedURLException.
Debugging requires careful reading of the API and stack trace and a
scientific approach of hypothesis, test, repeat. You are making
assumptions and jumping to incorrect conclusions. That is not an
effective way of finding bugs.
I will restate the above (from your point of view) as: I made
several changes and I am getting a MalformedURLException which I am
assuming is coming from the same place that it originally did.
Here's the part of the stack trace:
Read carefully now, top to bottom:
[2005-09-08 11:54:56 EDT] <WorkerThread13>
com.webobjects.foundation.NSForwardException for
java.net.MalformedURLException
at java.net.URL.<init>(URL.java:571)
at java.net.URL.<init>(URL.java:434)
at java.net.URL.<init>(URL.java:383)
at org.apache.xerces.impl.XMLEntityManager.startEntity
(XMLEntityManager.java:807)
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity
(XMLEntityManager.java:753)
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource
(XMLDocumentScannerImpl.java:260)
at org.apache.xerces.parsers.DTDConfiguration.parse
(DTDConfiguration.java:499)
at org.apache.xerces.parsers.DTDConfiguration.parse
(DTDConfiguration.java:581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at org.apache.xerces.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1114)
at
com.webobjects.appserver.xml._private._MappingModel.mappingModelWithXM
LFile(_MappingModel.java:405)
at
com.webobjects.appserver.xml._private._WOXMLMappingDecoder.<init>
(_WOXMLMappingDecoder.java:121)
at com.webobjects.appserver.xml.WOXMLDecoder.decoderWithMapping
(WOXMLDecoder.java:581)
This tells us that the exception is coming from a call to
decoderWithMapping() on WOXMLDecoder. This call happens at this line:
at XMLDecodeMachine.decodeXML(XMLDecodeMachine.java:25)
at DirectAction.newOrderAction(DirectAction.java:47)
the XMLDecodeMachine.decodeXML method is here (with line 25 denoted):
public String decodeXML (String theXML) {
mappingFile = application().resourceManager
().pathForResourceNamed("OrderXMLModel.xml", null, null);
NSData xmlData = new NSData(theXML, "UTF-8");
line 25 --> CustomBar custBar = (CustomBar)
WOXMLDecoder.decoderWithMapping(mappingFile).decodeRootObject
(xmlData);
System.out.println(custBar);
So the error is coming from WOXMLDecoder.decoderWithMapping
(mappingFile). That indicates that it is mappingFile _not_ xmlData
that is in error. The mapppingFile parameter should be "an URL to
the mapping file that specifies the mapping model". You are creating
mappingFile like this:
mappingFile = application().resourceManager().pathForResourceNamed
("OrderXMLModel.xml", null, null);
pathForResourceNamed returns a path, not a URL. A path is not a URL
and so a MalformedURLException would be expected. Read the
WOResourceManager API more thoroughly. Notice there is a method
urlForResourceNamed. That will probably work but you will still need
to make it absolute which is probably more work than you want.
First, I would try adding 'file://' to the start of mappingFile to
see if that works. Also see the maze of java.net.URL and java.net.URI.
return "Done";
}
I don't understand why I am getting the malformedURLException...I'm
passing in an NSData object which is acceptable. I AM CONFUSED
here. It's just not making sense !!
That is because you are assuming that it is coming from where it is
not. :-)
Chuck
On Sep 6, 2005, at 1:43 PM, Chuck Hill wrote:
On Sep 6, 2005, at 10:30 AM, Nathan Walker wrote:
The exception is raised from the line starting with: "CustomBar
custBar = (CustomBar)xmlDecode.decodeRootObject(theXML);" that
method throws an exception because it is expecting a URL to the
XML which in this case it is a string of XML.
Ah, OK. Um, why are you using that constructor? As you say, it
does not take XML. Wishing won't make it so.
String theXML = context().request().stringFormValueForKey
("NewOrder");
NSData xmlData = new NSData(theXML, "UTF-8"); // Or whatever
encoding you are using
// you might even be able to use request().formValueEncoding() for
the encoding
// I've never tried it.
CustomBar custBar = (CustomBar)xmlDecode.decodeRootObject(xmlData);
_that_ constructor matches what you have.
Chuck
Have you used XMLDecoder much ? and if so, do you possibly have
any sample source code or explanation on how to properly use it.
I have been reading the API but I am a little confused with it.
It seems that there would be a straightforward method that would
allow me to pass in a string of XML and then parse each node as I
would like. It doesn't seem to be that straight-forward ??
Again, the big thing here is DECODING the xml back into
WebObjects so I can deal with it there.
thx..
On Sep 6, 2005, at 12:52 PM, Chuck Hill wrote:
On Sep 5, 2005, at 8:03 AM, Nathan Walker wrote:
I'm trying to send XML from Flash to my app and I am a bit
confused on the decoder. I constructed an XML file with similar
code in Flash:
data_lv = new LoadVars();
data_lv.NewOrder = _root.myXML;
data_lv.send("http://nateg5.local/cgi-bin/WebObjects/
TikiBarz.woa/-50088/wa/newOrder","_self");
Not at all sure what that does or if it is right or not...
and then I receive the XML with the Direct Action code below:
public WOActionResults newOrderAction() {
WOComponent nextPage = pageWithName("Main");
Add:
System.out.println("URL: " + request().uri());
String theXML = context().request
().stringFormValueForKey("NewOrder");
Add:
System.out.println("NewOrder XML: " + theXML);
WOXMLDecoder xmlDecode = WOXMLDecoder.decoder();
CustomBar custBar = (CustomBar)
xmlDecode.decodeRootObject(theXML);
System.out.println(custBar);
return nextPage;
}
i know I'm not doing that right. But I'm just confused as to
how to go about this. I get a malformed URL,
From where? Is there an exception? What is it? Which line is
it raised from?
Chuck
of course with that because I'm not passing in a URL. Can
someone help set me on the right path here. Below is the XML
that is getting sent (It'd be nice to use a mapping file but I
believe I'd like to just manually parse it for greater control):
<customizebar><step1><roofSelection>Spanish Tile</
roofSelection><frontPanalSelection>Galvinized Steel</
frontPanalSelection></step1><step2><CustomBarTop
CustomName="Name Your Bar Here!"><picture picsize="5x7" rot="0"
ypos="333" xpos="184" number="2" /></CustomBarTop></
step2><step3><accessories>None</accessories></
step3><step4><order OrderTotal="$4850"
OrderNumber="46381"><firstname>Nathan</
firstname><lastname>Walker</lastname><address>5189468</
address><city>654</city><state>GA</state><zip>63546</
zip><phone>65465465</phone><email>email@hidden</
email><username>test</username><password>secret</
password><cardname>nasldkjf</
cardname><cardnum>43214324354354321</cardnum><cardexp>04/06</
cardexp><cardtype>MasterCard</cardtype><billaddress>lkasdjf sad
f dr.</billaddress><billcity>valkdso</billcity><billstate>GA</
billstate><billzip>31602</billzip></order></step4></customizebar>
Thanks,
Nathan
On Jun 1, 2005, at 9:35 AM, Pierre Frisch wrote:
We have a technology demo application that works well with
Flash and WebObjects. We made it work by returning the data in
XML. You will probably have to use XMLHttpRequest to make it
work as you cannot reload the Flash without loosing the state.
http://pears.spearcat.com/
Pierre
On 31-May-05, at 9:39 PM, Nathan Walker wrote:
Thanks for this, I will give this a try and see what happens.
The OpenLaszlo project looks VERY interesting.
On May 31, 2005, at 9:48 PM, Dave Elsner wrote:
Hi Nathan,
You could try making a direct action and call request
().formValueForKey and simply call it from flash
For example in flash (action script)
data_lv = new LoadVars();
data_lv.forumData = someXML;
data_lv.send("URL to directaction", "target window");
Then in your direct action:
String theXML = (String)request().formValueForKey("forumData");
You can also return XML databack to flash and then use
action script like
data_lv.sendAndLoad("URL to directaction", variable to load
returned data into);
Hope this helps.
Dave
On 01/06/2005, at 10:45 AM, Nathan Walker wrote:
Has anybody out there successfully deployed a solution that
integrates Flash with WebObjects ? I'm working on a
project right now that would benefit greatly if I could do
just that. I'm thinking about writing ActionScript that
will either save data to text files or send XML information
to a Direct Action which would then allow WebObjects to
pick up the data the Flash application is sending. Anybody
had to deal with this ?
This would be an awesome combination !
Thanks,
Nathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-
email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-
email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects
developers who want to increase their overall knowledge of
WebObjects, or those who are trying to solve specific
application development problems.
http://www.global-village.net/products/practical_webobjects
--
Practical WebObjects - a book for intermediate WebObjects
developers who want to increase their overall knowledge of
WebObjects, or those who are trying to solve specific application
development problems.
http://www.global-village.net/products/practical_webobjects
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden