dart:io and dart:html being mutually exclusive - dart

I've run into a similar situation to this chap where I'd like to have dart:io and dart:html in the same application. I know that dart:io is a server-side library and dart:html is a client side. My situation is as follows. I have a program to outputs a huge amount of text to a log file. I've found Dart to be great at text manipulation. I wanted to take the log file text, manipulate it, put some information in headed textareas for readability etc., and view the page.
I have no intentions to put this on the web. It's just for my work computer. I just want the file loading capabilities of dart:io and the nice display of dart:html. The previous post was in April and development on Dart is speedy. Is there now another way of doing what I want?
I know I could write a program to build a HTML file with the manipulated text in the appropriate fields and then open that HTML file but I don't like that idea as much. Is there another way?

You may consider using this library html5lib on server side apps to generate HTML output. Then it's simply a matter of opening the file up in a browser. This can also be automated by calling starting a Process which launches the browser and points to your generated html file.
html5lib is still a work in progress, but I'm sure they would like to hear your feedback.

I do agree that if all you want to do is to create a static web page, then using a lib like html5lib may be the best. However, if you like to do something more I think the way to go is to think of the server side dart as the model and the client side as the "rest". What the rest is depends mostly on if you like MVC, MVP, ...
I have been close to develop a desktop app in dart but I still haven't found an interesting enough example to get me going. I have been thinking of how I would do it though, and I believe that by connecting the two sides (model and "the rest") with a web socket, a make a simple serialization protocol (e.g. json), you can easily create an rpc with a client side wrapper using noSuchMethod() as the proxy and on the server side you use mirrors. You can create callbacks the other way if you like using the web socket. I believe Gilad mentioned a similar rpc technique between isolates in his talk from the HTML5 Dev Conf.
Anyway, what you would get is both dart:io and dart:html in the same "app", but the app would consist of a server side and a client side. This is what I will try for my next desktop app, whatever that will be :)

Related

Programming with swift backend and Angular 2 front. Is it possible?

I didn't find anything on Google saying about it.. so, is it possible?
i.e discard the XCode's Storyboard and use Angular 2 to make apps.
PS: Swift isn't discartable for me due frameworks and done backend code. I am using FFT algorythm from Swift's AudioKit Framework.
Angular2 can be used with any compliant web server written in any language. As long as it speaks HTTP correctly it doesn't matter what it's written in.
Angular2 is a front end JavaScript based technology. As long as you have a web viewer that can render HTML and has a standards compliant JavaScript runtime you can make it talk to your back end.
You can wrap it in an app store compatible package but it will still be a JavaScript app and will connect to your backend in the exact same way that it would if you targeted the browser. The difference is it'll be able to leverage certain device specific capabilities. You will communicate with your backend by sending JSON (any format can be used) back and forth.
The key point is that all communication will be in the form of serialized messages only.
Even if your backend were running on the same device, there's no shared memory space.
Of course since a mobile app can persist it's own state locally it might not need a backend at all. This last point is very domain specific.
It could be posibble if you use Vapor as your backend engine. Take a look at Vapor's website for more info.

How does Vaadin work?

Can anybody explain to me how Vaadin's server side Java components work? They seem to do a sync between server-side state with a client-side javascript engine called a "widgetset".
Does anybody have a more detailed explanation of Vaadin's internals? I have been trying to explain it to my coworkers and am at a loss for words.
Basically Vaadin runs your UI code on the server and uses the browser as a "thin client" (the widgetset) to create and update the DOM. All server-client communication is automated and taken care of by Vaadin. The end result in the browser is just a plain HTML5 application as far as the browser is concerned, no plugins are needed and it will work across different devices.
Going a bit deeper, each component in the framework has both a server side and a browser implementation. Both share a state that is maintained and communicated by the framework. As all communication is taken care of by the framework, it is able to optimize the transport quite a bit by only sending diffs and skip sending defaults etc. Also, since the widgetset contains the JS implementation of the browser component, no HTML templates are generated on the server and sent over, only the actual component state which is much more light weight.
Here is a more in-depth explanation from the docs: https://vaadin.com/docs/-/part/framework/introduction/intro-overview.html

How to create forms in dart?

What is the best way to create forms (textfields, checkboxes, radio buttons, ...) and handle the data after the user's input?
Just use web components as dart's web ui?
http://www.dartlang.org/articles/web-ui/
http://www.dartlang.org/docs/tutorials/web-ui/
edit: Lets imagine the following example application: I would like to create an online quiz/test.
First the user has to register
Data will be stored in a textfile or in a database
User can log in and play an online quiz or do an online test.
For that quiz/test i need to evaluate the input with the predefined correct answers
Here's a high-level answer to your question.
To handle data on the server side you can use the HttpServer class to start a web server. See this article.
To store data in a flat file you'll need to use the dart:io package to open a file and write to it. See the documentation for File.openWrite().
To store data in a database there are packages available on pub for mysql and postgresql.
There are two different ways to implement the client side. The traditional way is to use templating to generate html with the data in input elements within a form tag, and then handle the form submission in your webserver.
The modern way, that is the focus within the Dart community, is to write a single page app, which uses HttpRequest to read data from and send data to the server (usually using json).
On the client side, you could retrieve data from server (e.g. as JSON) and use that to build a form. This seems like a good fit for a web component as elements can be dynamically added based on received data.
The component would be bound to the model so you can serialize the model object to JSON on submit and send it to server on submit or just send it as standard HTML form.
The server side of the story is less clear, there are no production quality web server libraries that I am aware of, but you could take a look at DartExpress as an example, or Stream, and there are others, more or less complete. Anyway, you would have to extract the POST payload from HttpRequest (if sent as JSON) or use the form data which is also accessible via queryParameters property - please note that this is Dart:io.HttpRequest class, not Dart:html.HttpRequest, and it is available only on server side.
The mentioned server frameworks simplify this part a bit.
Using Web-UI would be a good choice. The todomvc application illustrates nicely how to dynamically capture the input from a user. Processing on the server side is wide open as far as choices go. Dart does have server side capabilities, and you could use some of the existing libraries to accomplish what you want.
Another way that you can process the information server side is to comunicate with the DB directly using a REST based web service like CouchDB. Cloudant offers such a service and allows you to communicate directly to the DB from the client, providing you can overcome the Same-Origin-Policy. There are 2 ways to do this. Enable CORS on the CouchDB instance, or host your application on the server that has the DB, which is also possible with CouchDB.
Dart serverside also supports websockets, so you can easily deliver the user provided data to the server with web sockets, and then do whatever processing you like on the serverside.
One other option I can think of would be to have the information processed and saved in the local browser. You can access the local DB or local browser file system from the Dart client, and keep everything local. For statistics, you can have the client update a web service of your choice.

PayPal integration. C# POST vs. WSDL

I got the PayPal integration working well using plain old HTTP POST using C# & .NET 2/3.5. I also get all transaction details in the response.
So, if I want to use WSDL (SOAP), will there be any advantage? (you can assume I know how to use web services)
Also, are there any examples on a complete C# project using this method? I already looked at http://www.codeproject.com/Articles/42894/Introduction-to-PayPal-for-C-ASP-NET-developers
but that page tells very little about how to make a fully functional transaction using WSDL.
Any ideas?
Or "if it ain't broke, don't fix it"
thanks!
I really don't work from WSDL's very often because I'm primarily a PHP developer. I have worked with them in Adobe Flex, though, and I gotta say I liked what I saw.
Basically, I was able to hook the WSDL up in Flex (which you can do in other IDE's as well) and it automatically gave me access to all of the API calls in the system. I could see all of the possible requests (functions) available to the web service as well as how to build them without even referring to much documentation.
When building HTTP requests directly (NVP/XML/JSON/etc) you gotta refer to documentation quite a bit to see how to build the request, and there's typically more trial and error involved, too, until you get things working. The WSDL helps you get around that, although, in reality you'll probably still be referring quite a bit to documentation.
The WSDL/SOAP tools I've used with PHP don't work nearly as nice as Flex or Visual Studio from what I've seen, so I typically stick to custom class libraries that build my requests for me. when I'm working in other platforms that utilize WSDL's a little nicer, though, I definitely prefer it.

Access Web Services on BlackBerry

What are the ways of accessing web services on a BlackBerry device?
I've learned about XML for webservices. We use SAX and DOM parsers in Blackberry. Are there any more ideas like this?
I also want to know what KSOAP is and how to use it on BlackBerry.
AFAIK, kSOAP is a library that lets you post soap requests to your web service. If the service accepts a simple POST request, the easiest way would be to use HttpConnection. Here's a good tutorial
I've also used kXML2 for XML parsing, and that has worked out well for me till now.
Additionally, including 3rd party libraries is a pain (kSOAP and kXML), so here's a guide that will hopefully save you some time.
You can try http://wsclient.neurospeech.com/wsclient/java-android-blackberry/ which supports soap code generation for blackberry with additional library that manages everything, it generates native typed soap client and calling them is very easy. Otherwise you will be spending lot of time in xml to your types and types to xml conversions and so on. Plus date and many things are little complex to handle.

Resources