Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In our GWT web application, we reach a state where we want to remove everything and just show a big fat warning that the application was stopped.
We are not able to figure out a way to do that. What we basically need is:
force GWT to stop all processing and abort any existing RPC messages
force all registered events to become inactive
clear all visible content from the page
set a single paragraph/text
In a nutshell, we want to kill the entire DOM and add just a single paragraph to it.
We tried many different combinations of
RootPanel.get().clear()
but found no reliable way to do what we want to achieve. Any ideas how to do that?
First of all you have to take of server activities. That's a good practice, which makes your application robust.
To make it uniform, you probably want to respond with appropriate exception to any requests made to your Service implementations. For instance, if that's what happens when user is removed rights to access the application, then it should probably throw some kind of security exception for all requests except those made for relogin or other approved actions.
You can do it manually in every service method or you can have a filter that handles that. Frameworks such as Spring Security provide an easy way to configure security filters.
After you've done with server side and confirmed that UI is unable to penetrate through server's security layer, you can make changes to UI. There are different ways to make a nice looking blocking screen.
In general, I do the following in my code to create content and can use clear() method to remove viewport or stuff from the viewport. No refresh or revalidation needed.
Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
viewport.add(new MainPanel());
RootPanel.get().add(viewport);
Not sure how your layout is. If you're able to provide a code sample for your scenario, I can show you how to do what you need. Because in my examples it works just fine.
Window.Location.replace("URL-OF-A-STATIC-HTML")
Javadoc :
Replaces the current URL with a new one. All GWT state will be lost.
In the browser's history, the current URL will be replaced by the new
URL.
If you want to re-activate the GWT app, put a link on that HTML page.
Store information or say flag in the cookies, when ever u load the application see that whether that cookie is set, if it is set display the message or else load the application. Now whenever you want to stop the application completely, set the cookie and reload the application.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
I've almost 'finished' my first website. Which consists of an authors anthology, essentially 100's of pages containing individual articles. It's built with HTML and CSS.
At the bottom of each page I want to link to related pages, displaying the title and an image. How can I auto-populate these boxes by fetching related pages from a database?
I'm just looking for someone to point me in the right direction, I will try to teach myself. I assume there would be some server side scripting? or loading the data into a sql?
There are two approaches.
Lets compare and contrast!
1. Server Side:
You write code on the server (in PHP or Python or Java or whatever) to create HTML files programmatically, which will have the relevant links.
Pros:
You are in full control
Cons:
Resource intensive (relatively speaking)
Longer initial loading time (waiting for server to create a new page, per request)
It's the way it was always done.
2. Client Side:
You write code on the client (browser) that receives from the server just the data (perhaps JSON?), and figures out how to display it on its own. Perhaps using Angular, or React.
Pros:
Very light-weight on the server
HTML pages can be hosted cheaply (S3, DropBox, what have you)
Cons:
Content is fetched and analyzed on the fly, making the page feel slow if you're not careful
Bloats the front end, kinda harder to grasp
As a sub-topic of the Client Side, There's a new hotness in town, and it's called Serverless. You don't have to write a back end, and you focus 100% on the front end.
If you really have to make calculations outside of the users browser you can use cloud functions (like Amazon Lambda), but I don't think that's your use case.
For your use case, you can access a database straight from the front end, without needing any back end. See: Firebase.
You'll need some sort of server side program. Something that can query the database, then return the results either through an api or process it all server side and return the html. Below are some frameworks that can help.
Java:
Play, Spring, Javalin, Dropwizard, etc.
Python:
Django
I was wondering how to preserve an application when the user leave the application completly by going to another site (for example when the user logs into the application and then goes to nytimes.com and then comes back to the application some components go missing). To preserve the application on a refresh you can use the #PreserveOnRefresh annotation, but this does not preserve the application when you leave it. The header, menu and footer are disappearing. These three components are have their own class and are only declared in the main ui. Each view (or page) has its own class (which sit between the menu and the footer). Everything works fine until the user leaves the webpage and comes back the header, menu, and footer disapear So my question is how to preserve my vaadin application when the user leaves it and comes back?
Well, there could be problem with serialization and deserialization from session. Make sure you have implemented Serialization interface for your own classes.
Have you tried to repaint the missing components? They should be set to setImmediate(false) during repaintRequest.
Anyway, ordinary Vaadin application works without problem after returning back from other url. So good luck.
To solve this situation you can add a listener to the navigator which will get the uri to the page you are going to and check your permissions. If you do not have permission it will keep you on the same page and give you a notification saying that you are not allowed to go to this page. If they are allowed you will proceed to direct them to that page.
What components are missing when you go back to the application? Vaadin applicaction lives as long as web session. If I go to nytimes.com and then go back before the web session ends, the Vaadin application will survive (if it has #PreserveOnRefresh) or will be renewed
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How would one go about sending and receiving simple data such as a string from an app inside a cell phone?
Essentially, though it is not my goal, I am asking how one would create a text messaging service.
My current idea is to buy some online storage from a data-center store the string in there, alone with their intended recipient, and whenever the recipient checks the app the strings are sent him.
I would like to know if this method is possible, or if it there is a better method, or software to help me?
Additionally if this method is possible and preferable please point me in the correct direction to begin.
There are lots and lots of ways to do this. It all depends on what knowledge you have on web servers etc.
For sending to the device you could use GCM (http://developer.android.com/guide/google/gcm/index.html)
However this doesn't do from the phone, only to it.
You could set up a simple web server...
You need an HTTP server, almost all languages have one, for simple servers, if you don't need much throughput then try something like python, otherwise have a look at Apache or something. http://httpd.apache.org/
For a cleaner and more structured way of sending these strings I would use JSON, so the web server will need a JSON layer to handle JSON requests, have a look here: http://www.json.org/
Once you have the request you will need to do some logic with it, this is up to you. But as soon as you get the JSON request and parse it you should be able to do almost anything with it.
This all should be really easy to implement. Then if you were to make it public (I would develop this by running the server on a local machine) then you need to have a static IP at your house, by a domain, and set it up so that the domain is pointing to your IP, if your IP is dynamic it may take a bit more to set up but you will need to look into something like FreeDNS and an updater client.
Otherwise you could just find hosting that supports the language you are going to be using (PHP, ASP.NET, or what ever) and then get something set up with them.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to create a server which initially checks an Android applications trial period, so
on running an Android application the phones info is sent over to ther server.
The server stores this information.
Whenever the application is opened within that android phone
the server checks its trial period has or has not expired.
In a way it's like an Android time bomb.
I'm completely new to servers and really just want a basic, secure, server that simply registers a phone and compares it against a trial limit.
Anyone have any information on how I could do this?
Any code examples or tutorials are very much appreciated.
You didn't specify your server technology, but in principal you need to do the following:
You probably want to expose them as a REST Webservice. All you need is a GET operation to basically figure out if the trial has expired or not. Since you are using Android and have gained familiarity with Java, I suggest you look at JAX-RS which is one way to implement REST in Java. If you are familiar with other language, then feel free to go for that.
The simplest form of your GET URL would probably look like http://yoursite/getTrial/[beginTrialDate] where [beginTrialDate] is a date in millis since Jan 1, 1970 GMT (standard approach)
On the server side, you simply took the [beginTrialDate] and check if it has exceed your trial period by comparing current time to [beginTrialDate] + [trial period]
You would then return a simple JSON response containing the information whether the app has expired or not. The simplest form would be: { "hasExpired" : true/false }
You would call this WebService in Android using HttpClient as you would probably know already. Check this HTTP Client Tutorial
You could make the server more robust by storing the phone identifier and your GET URL change to http://yoursite/getTrial/[phoneID]. The only additional complexity is you have to look up the begin trial date by phoneID and then compare it again using the step #4
Let me know if you need more clarification and I will add it to the post
Easiest way would be write a JSON service. here is a link to a sample PHP JSON service - http://davidwalsh.name/web-service-php-mysql-xml-json
You can easily find JSON code for your choice of language.
I'm guessing that you dont need the service to return lot of data - probably a flag or minimal data. You could simply parse through the JSON string that is returned to the device. If you have lot of data to be passed, you could try some free JSON libraries available
Although I've been programming for a few years I've only really dabbled in the web side of things, it's been more application based for computers up until now. I was wondering, in java for example, what library defined function or self defined function I would use to have a program launch a web browser to a certain site? Also as an extension to this how could I have it find a certain field in the website like a search box for instance (if it wasnt the current target of the cursor) and then populate it with a string and submit it to the server? (maybe this is a kind of find by ID scenario?!)
Also, is there a way to control whethere this is visible or not to the user. What I mean is, if I want to do something as a background task whilst the user carries on using the program, I will want the program to be submitting data to a webpage without the whole visual side of things that would interrupt the user?
This may be basic but like I say, I've never tried my hand at it so perhaps if someone could just provide some rough code outlines I'd really appreciate it.
Many thanks
I think Selenium might be what you are looking for.
Selenium allows you to start a Web browser, launch it to a certain website and interact with it. Also, there is a Java API (and a lot of other languages, by the way) allowing you to control the launched browser from a Java application.
There are some tweaking to do, but you can also launch Selenium in background, using a headless Web browser.
as i understand it you want to submit data to a server via the excisting webinterface?
in that case you need to find out how the URL for the request is build and then make a http-call using the corresponding URL
i advice reading this if it involves a POST submit