How can I use Vaadin with SparkJava - vaadin

I have implemented an API that is REST based using SparkJava (http://sparkjava.com). Its a standalone app and works great.
Now I'd like to implement part of that functionality access through a Vaadin UI. I'm quite new to Vaadin as well.
Does anyone know how I can still keep the single VM model, and able to use Vaadin's wonderful UI structures with greatness of SparkJava?
Is there someway that I can bind the Vaadin Servlet to the SparkJava Route perhaps?? Just thinking loud here.
Appreciate your help very much!!
I assume this is possible because I saw its used with Jetty (Vaadin 10/11 and embedded Jetty)

sure that is possible! You can simply make Jetty expose both SparkJava filter, and Vaadin 10+ servlet. I've created an example application which builds on Alejandro's work: https://github.com/mvysny/embedded-jetty-demo

Related

Apache Wicket REST with Swagger UI

One of my project is using Apache Wicket 6.x and I have some API (resources) using wicketstuff-rest and it is working perfectly.
But for my API documentations, I am maintaining a google document for these APIs. Problem is that whenever there are changes in any of the API, or even on new APIs... I need to update this API documentation. Chances are, this documentation may not be updated.
On my other springboot projects, I am using swagger and the API documentation can be viewed via swagger-ui.
I wonder if I can use swagger-ui with existing apache wicket 6.x project so that whenever there are new API(s) or any change on the existing API(s)... it will reflect in swagger-ui without the need to maintain any API documentation.
What I currently search is swagger2markup, but this seems to be old and I am having problems with the setup and there are very few resources on how to set this up.
Anyone who successfully setup swagger-ui with apache wicket rest?
Care to share resource/links on tutorials or how to setup swagger-ui on apache wicket rest?
Thanks!
I don't have an easy solution for you with Swagger but if you use Spring already then you could use Spring REST Docs to generate the documentation from the unit tests.

How do I request client geolocation in Vaadin 8 application?

Tried embedding this JS code into the UI: https://www.w3schools.com/html/html5_geolocation.asp but nothing happens.
Is there any way to achieve this in a Vaadin 8 app?
There couple of approaches to do this in Vaadin 8. In both cases you need to create custom component with client side part. The component can be based on GWT or be JavaScript component. In case of GWT based component, you need to use native JavaScript blocks. There is good example of that here in this GitHub repository:
https://github.com/heruan/vaadin-geolocation/blob/master/geolocation-addon/src/main/java/com/vaadin/addon/geolocation/client/GeolocationConnector.java
The above implementation has been released as an GeoLocation add-on in Vaadin Directory. So you do not need to re-invent the wheel, if you do not want to.

ZK framework advice grails

I am needing something to allow a user to use a tool to define a layout which then can be applied to a grails application.
I have been looking into ZK Framework, It seems this will allow it but I am not 100% sure.
Has any one made use of this before?
Or could anyone suggest any alternative.
It seems that the ZKGrails plugin does what you want.
It enables you to port the ZUL pages you developed in ZK to Grails. In particular, you would extend the class GrailsComposer (which in turn extends from ZK's GenericForwardComposer) in order to autowire your ZUL UI components to Grails event handlers.
This ZKGrails tutorial shows how to port the ZK's Load-On-Demand program to Grails.

Cannot create a session after the response has been committed - PrettyFaces MultiPageMessagesSupport on Glassfish4

I have a Java EE app where I use JSF2 + PrettyFaces + EBJ3 + Glassfish
I just recently updated to Glassfish4 which is the default Server implementation for Java EE 7 and I started getting issues with PrettyFaces.
I have configured on my faces-config.xml:
<lifecycle>
<phase-listener>com.ocpsoft.pretty.faces.event.MultiPageMessagesSupport</phase-listener>
</lifecycle>
to enable for Faces Messages to be passed around correctly and displayed on screen.
But since I upgraded from Glassfish3 to 4 I started getting this issue:
java.lang.IllegalStateException: Cannot create a session after the response has
been committed
...
at com.ocpsoft.pretty.faces.util.FacesMessagesUtils.saveMessages(FacesMe
ssagesUtils.java:56)
at com.ocpsoft.pretty.faces.event.MultiPageMessagesSupport.afterPhase(Mu
ltiPageMessagesSupport.java:66)
If I remove the listener from faces-config.xml none of the Faces messages are displayed on screen.
I am using PrettyFaces to have nice well formatted URLs to enhance SEO on my site. I wish I couldn't have to replace it or refactor my app to not use it since I already mapped a lot of the navigation flow using it. Does somebody know a better option for this scenario?
I really appreciate any suggestions. Thanks.
I don't recommend to use MultiPageMessagesSupport if you are deploying to a "modern" container with JSF 2.2 support. The MultiPageMessagesSupport phase listener has been developed for JSF 1.x. JSF 2.x added support for persisting messages across redirects. Just execute this code before redirecting:
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);

Convert jquery mobile mvc4 web application to phonegap

I've created one Jquery mobile mvc4 web application using webapi support, which is well looking site in almost all mobile device as well. but now i want to convert this MVC application to phonegap to use mobile feature supports like camera,accelerometer,sound etc..
What is the best way to start converting it to phonegap, will i need to create SOAP based web-Service for webapi code. I've searched on web regarding that but not getting enough help,support.
am i going right way ? or need something else ?
any help is appreciable.
Okay so in order to convert it first you are going to have to know Objective-C because that is the only language that is allowed on the iPhone but assuming you know that here are the steps you can take in making a conversion like that.
*Make sure that any outside information the application retrieves is either a) In a REST api you can use the new WebApi in fact I am using it right now and it works like a charm. Or b) Any script src= tags are converted to local files on disk. So if you had script src="My awesome css" make that file a local file on the phone.
*Next take any views and decide where all of their API calling code is. Make not of that and then get ready to be moving that code.
*Once that is all recorded startup a phonegap project and get rid of any extra .index files or anything you don't need.
*Create your applications PhoneGap plugin. Have the OBjective-C plugin make any API calls that you will be needing and then make the javascript plugin match the objective-C function.
*Where you had any calls in your previous views, make those now call the cordova (PhoneGap) plugin.
This is a very brief roadmap to get started.
Once the tediousness is over it is worth it though. I moved my IOS application to Android and they transfer pretty easy.
Cheers

Resources