restful simple web api , how to make this project? [duplicate] - scala

This question already has answers here:
What Scala web-frameworks are available? [closed]
(18 answers)
Closed 5 years ago.
I am trying to create a web app in React.js and Scala. So I have a programing code in Scala which just prints a random Name with the current time it prints in my stdout as Json object. It looks something like this.
{ Name : Ash TimeLastActive: 14:24:06:6456}
{ Name : Kum TimeLastActive: 15:44:06:6456} ...
first thing is i want this println message to go to responses of my web app that I am about to create in react. how can i do that in scala?
my react webapi would be very simple. It would have a start button which should run the scala program and whatever the program outputs on stdout should come to my webpage and diplsay there till i press the stop button. How should i handle this in the front end side .
Can you tell me hwat all technologies should i need to be familiar with to go ahead and make this project happen and at which point do i need which technology.

I recommend you have a look at scalatra http://scalatra.org/ which will act as your api endpoint so that your web can request for it then you need
you should use the react-create tool to help you create a react project
axios or bluebird to request from your api (Play 2) Library is a bit overkill again you should do some more research
some example endpoint you could try
send a json get request to /random (this is when you run your scala program and send a json)
and then return as a json for react to process (return http status code 200)
the stuff you want to display
[
{
"Name" : "John Doe",
"timestamp": "some timestamp"
},
...
]

Related

Reverse Engineering an auth code query parameter passed to Play Framework in URL query Parameter

I recently got thrown into a company to do DD on a SaaS solution that needs to generate codes to send invites. Has anyone seen or used this method of passing an API key/auth code? It's using the Play Framework. I don't have access to the play source code, just a compiled binary so I can't even see how the GET request is validated.
Eg:
https://<site.com>/?auth=10002-1644542228446-75ac043770463c36039f29d75304171c
I checked the packages used and there is io.jsonwebtoken.jjwt-0.9.1.jar used but I'm only familiar with passing it as a header "Bearer ". and haven't seen this three segmented formatting. XXXXX-XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Any help would be appreciated. I know it's not a lot to go off but I'm only looking to be pointed at the method used to get started.

Stopping Ember.js Controller

My question is very basic on one hand but on the other hand the general situation is more complex, plus I cannot really get any working sample.
I'm developing/maintaing a web-application which is currently in transition from GWT code base into Ember.js.
Most of the newer code already relies on Ember.js and I think it's really awesome.
The problem is we cannot use Ember Router as all the request are being handled by the GWT.
In order to enabled the application run in this unusual configuration we have special JavaScript files that create our Ember main objects (Controllers & Models) for us.
As you can imagine navigation between tabs is cumbersome and is handled by GWT who creates Ember objects when needed. We are in transit toward a brave new world Ember Router and all.
But in the meantime, this is the problem I'm facing right now.
The user clicks a link which opens a page that contains some Ember based table.
The data is retrieved form the server using some Ajax code. Upon success it spawns a forEach loop which tries to pushObject all the received date into our Ember based components.
My problem happens when the user quickly switches between tabs. In this case the first list of object has not finished rendering yet and suddenly there's a new set of objects to handle. This causes Ember to throw errors like:
"Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM. "
and
"Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist."
Is it possible to prevent the loop from trying to render?
I've tried checking if the controller in question is already inDOM and it is, is there a way to notify Ember this object is no longer valid?
Sorry for a lengthy question and lack of running sample.
I'd probably modify the switch tab code to only execute afterRender has completed, that way you aren't mucking with ember objects while they are being used.
Ember.run.scheduleOnce('afterRender', this, function(){
// call GWT switch tab routine
});
Thank you Daniel and Márcio Rodrigues Correa Júnior. eventually what I did is to add a patch that would check the current context of the application (in my case the currently selected tab). If upon receiving the AJAX response the application is in the correct context (meaning the user haven't change the tab) go on. Otherwise just ignore the response and do not try to render it.
Now it seems to be working

LoadRunner and wicket application

Doing some research with regards to application framework used on the SUT am going to LoadTest using Loadrunner I fond the application is developed using wickets.
I have generated script using web http/html protocol against a wicket
application and there was some calls recorded in the following
format,script is failing at this URL when i ran the script in VUGen.
http://somem/nnnweb/main/ ?
wicket:interface= :1:someSearchForm :someSearchForm :searchInfo: :IActi
vePageBehaviorListener :0:&wicket: ignoreIfNotActiv e=true&random=
0.038901654740178815",
I find out like when i generate the script which has just views(
viewing tabs) is working fine, but when i edit somefileds and submit
the script is generating the above calls ( http://xxx...) and failing
This guy has explained just the same issue here:
http://tech.groups.yahoo.com/group/LoadRunner/message/27295
I hope it is ok to refer other sites in Stackoverflow?
General question. Does loadrunner support testing of wicket application and is TruClient the best choice here? I actually got it to work with TruClient, but as I understand there are drawbacks with memory footprint using TruClient, but maybe it is time to move on to next generation protocol given my project has decided to use wicket framework?

Grails + GWT - using the same Date Format

I am developing an app using Grails and GWT for a client side.
I want to use the same date format both on the client side and on the server side (preferably defined in one file).
So far i've understood that Grails got it's own mechanism for internationalization (grails-app/i18n). I know i can access these messages from any server code using app context.
I can also access any resource file inside web-app directory.
For the client side, i can use ConstantsWithLookup interface and GWT.Create(...) to get an instance of it.
But, i still haven't found good solution to integrate these two together, so i have date format defined in one place. Any ideas or tips?
Thanks,
Sergey
After digging into Grails more, i came to a solution.
I've put constant into .properties file under grails-app/i18n.
Then, i hook to eventCompileEnd and i copy resources from grails-app/i18n to specific package in target\generated-sources.
After this step is completed, i generate google I18N interfaces using copied property files.
I've put this functionality to separate plugin.
_Events.groovy:
includeTargets << new File("${myPluginDir}/scripts/_MyInternal.groovy")
eventCompileEnd = {
internalCopyMessageResources();
}
eventCopyMessageResourcesEnd = {
generateI18NInterface();
}
Now it is possible to access localized data from server side and from client side.

Event from JAva Script to objective c

I am developing a map application for iPhone.I am using google maps API to develop this,by adding the java script file to the resource.My problem is that I need to catch an event defined in the java script. for eg: I need to cath the following event in java script
"GEvent.addListener(poly, "click", function(latlng, index)" .
Please anyone help me.
Thanks in advance
Why are you not using MapKit? Is this a web app only?
You can call javascript to probe if something has happened, but you cannot have javascript call back to your code... at least not directly. You can override the URL handling and have javascript included that tries to make an external call that your code recognizes and acts on.