I have written a webpage with GWT which contains auto-generated Hyperlinks. These hyperlinks currently dont point to anything, however, I want them to display certain dynamic information based on the name of the hyperlink. For instance if the hyperlink says iPhone, it should open up another URL with dynamic information about the iPhone which I retrieve from my database. I know JSP/Servlets are used to generate dynamic information on webpages, but how can I integrate such functionality into my GWT webpage?
Thanks
Great this certainly helps in giving me an idea on how I can go about my design.
As a follow up though I have a question on how I can access my backend DB. Now I have stored some data in a SQLite DB which I want to be displayed on the webpage. I was able to implement backend access via GWT's RPC, however, it doesnt seem to allow transfer of a ResultSet object returned by a query. How can ResultSets be transferred? In my browsing I have seen a few keywords such as DTO, JPA etc thrown around but I dont quite have a picture on how they will plug in.
How about this:
[CLIENT]: add a ClickHandler to your hyperlinks where you execute the following steps:
[CLIENT]: retrieve token from hyperlink (i.e. iPhone).
[CLIENT]: access the backend (RPC, RequestFactory or normal RequestBuilder) and pass the token (iPhone) to the backend
[SERVER]: On the backend (servlet, python, php, etc) handle the AJAX call from your GWT app and return the dynamic information based on the token.
[CLIENT]: Display the dynamic information returned by the server call (step 3) in a HTMLPanel or SimplePanel
Related
I have recently started to learn Java and I have a created my first desktop application using Swing. I now however, want to start my own little project that involves creating a desktop application that can retrieve and input data on a webpage.
Ideally, I would want to input and retrieve data from a webpage that is open and visible in a web browser (preferably Chrome), rather than doing it all behind the scenes where it cant be seen. I need my program to have a GUI written in Swing, which takes values and then inputs them onto the webpage; I need to be able to take values from the open webpage as well as be able to press buttons - all through my desktop app.
In conclusion you can say I need to create an application that automates a web browser, however it needs to be able to do it to an already open browser/webpage. What should I do and use to achieve this?
You can achieve this by applet programming in Java which can send request data to server web page. Additional to this you can use Web Service mechanism to where you can get data from your swing form and bind the request in any appropriate transfer method like XML or Json and you can post it on to server endpoint. For example in JAVA you can use Jersey rest implementation for this.
Background: I am creating an Android app that will get data from a web page (that will be created by me) and parse it. This data can be in XML or JSON format. I would personally prefer JSON but if there is an easy way to achieve it with XML, I would most certainly use it. The app is a Live Score app. So, my page would have XML or JSON with the current score, the current time and minute by minute commentary.
Progress so far: My app is able to read and parse JSON data using the HttpGet and HttpResponse methods alongwith the JSONObject. My concern however is that I am unable to create a dynamic web page. I tried to create and host a page using Google App Engine and Python. The problem was that everytime I'd make changes to the JSON file, I would need to re-deploy the program from the Google App Engine to ensure that the changes are reflected on the URL. I felt this was relatively time consuming.
My Questions:
1.) Is there any way to host a dynamic web page? Preferably with Eclipse and Java. One that I can add the commentary to, as and when an event occurs and it is reflected on the page.
2.) I am not good with Web Services but would GET and POST be a better alternative as opposed to deploying my JSON file with the GAE? If so, how can I go about with that?
3.) Is GCM a good alternative for all this? I tried reading up some of the documentation but it seemed really complex to me.
Thanks.
Sure, it's called AJAX. It requires client-side (browser) javascript code making a request and server-side java code making a response. See: How to use Servlets and Ajax?
Yes, you should use POST and GET to create/retrieve data on server. Your server-side java code should receive data on POST, save it to datastore, and then serve it back on GET. I'd suggest using objectify library for storing data, and GSON for converting java objects to JSON.
GCM is an asynchronous way to notify Android apps (aka notifications) when apps are not running. While with GCM it's possible to send data both ways, it's more complex then plain POST/GET and also only works on Android devices with Google Play.
Im using the Magento 1.6 and I use a web service to process some of the fields I pass along. I've added two fields to the zend's billing.phtml form and I want to pass that along also to the web service.
I see that I can access the built in fields but I wish to add my custom ones as well. What is the best way to do this?
The solution I'm seeing right now is that when I select and input the field (its is a drop down box and a input menu), using AJAX, I post it to a PHP form and it stores it as a session variable but I see this more as a bandage fix than anything else.
I am building a social web application using Java and Cassandra DB. I want some of the data from my database to be visible to search engines.
Since my application is completely dynamic & contains data only in DB and not in static pages, how do the crawlers read this data?
1.)How can I ensure that the data stored on my servers can be seen by the search engines? My application contains user specific data
2.)How do the search engines access that data ??
3.)How can I limit the search engines crawling only to some specific data?
Read the explanations from Google.
The search engines access your data as any other user of your website : by browsing it and clicking all the links they find. Content accessible only through AJAX will be more difficult to make accessible by search engines.
Access can be restricted using a robots.txt file. Explanations are given in the link given above.
1) You need to separate user specific info from public info, either you should have public and private pages - or you could decorate you'r public page with user specifics through some session based Ajax calls.
Meaning: the browser just load the public version of the page, while a javascript would load the users specifics and inject them into the page.
2 and 3 could be solved by uploading a site map to Google.
Or do you want Google to talk to Cassendra directly...? Then ignore all above - I think.
I have a database from which I want to expose data.
Ideally I would like to be able to just add a URL into some other web page and that URL would then call the correct datum using the web app I use to interact with the database.
Would a web service be the best option?
Looks to me like a perfect job for ODATA:
The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today. OData does this by applying and building upon Web technologies such as HTTP, Atom Publishing Protocol (AtomPub) and JSON to provide access to information from a variety of applications, services, and stores.
See it action (showing query results in a browser is just one way to use ODATA).
A URL-based solution as you describe would only work if:
a) the web app framework you use can resolve the URL automatically as it parses and sends the HTML to the browser, or
b) the browser resolves the URL (e.g. the IMG element)
If the web app framework you use can resolve the URL (or if you can extend it so that it does), then you still need something that listens at that URL and retrieve the correct element from the database.
The approach here depends on whether you are doing Ajax style web pages or simple HTML, where each UI update refreshes the whole page.
The latter, a traditional page by page web site, it probably the simplest thing. For this explore JSP technologies. The idea is that you write what looks like an HTML page, but embed in it references to Java objects (or even Java code). In this case you should read up on simple frameworks such as Struts. The broad-brish idea is that you get this sequence of processing
Request arrives from Broswer, interpret it to figure out what the user wants to see
Some Java code talks to the Database gets data puts it in a Java Object
A JSP is chosen, that JSP picks items from the Java Object we just prepared
The JSP renders HTML which is sent to the Browser
In the case of Ajax, JavaScript in the Browser decides to display some data and calls a service to get it. So here, yes a "Web Service" of some kind is needed. Usually we use REST services, which return a payload in JSON format, effectively the data is transferred as JavaScript.
There are plenty of libraries for creating RESTful Web Services, for example Apache Wink.