how to get event of change state of tabs or page - java

I have one application who has two parts one is display module which is web based using j2ee and other is my backend service module which is on java. I have one page which has 4 tabs which has graphs. When click on tab, it sends start request to my backend application to start sending live data on my page. Problem is when I change the page to other page, my backend service keeps on sending the data. I want some way from which I can send stop request to my service program, when I change the page or close the browser. Please provide me some idea.

Related

Multiple responses from a single HTTP request

I have a Java Web Application. When a user clicks on a "Retrieve" button they expect to see 3 new tabs open in their browser with a different PDF document in each tab. The PDF documents are generated from the server.
I know this can be accomplished by sending 3 requests from Javascript within the html page, but does anybody know of a way to accomplish this with a single request to the server or is that not allowed?

Dynamically force transition in Spring Web Flow

Spring web flow is a state machine of sorts for a user interacting with html pages. Traditionally, while a user is in a view state the system will wait until the user interacts with the page which will trigger some transition.
Is it possible to force a transition or update a page without interaction from the user in spring web flow? For example, I may have a REST controller, or an AMQP listener, or even maybe just some background process running. When data comes in from one of these independent processes, I'd like to update the user into a new transition.
For example the user is sitting at a decision point for a period of time and another service will call via REST into the web flow service to logout this user. The web page should suddenly navigate to a logged out screen.
The only way I've been able to achieve this is save the information and do a check for logout messages once input has been received but this is less than ideal.
You seem to be talking about a message sent asynchronously from the server to the client, like with Websockets.
Without a technology like that, I think your only options - unrelated to Web Flow itself - are:
JavaScript on the page timing out or polling
Wait for the user to submit their next request

Web Sockets in multiple page web project

i'm looking for nice tutorial or, maybe, some tips how to implements web sockets in multi-page web project.
For example i have welcome page and some link here. When i press on link i should be redirected to www.domainname.com/anypath with another fields and data.
To interact with the server i need to use web-socets. How many Server and client endpoint i should create? New endpoint for each page, or only 1 endpoint for each page?
I'm really trying to research it in google but there only tutorials with one page without any user navigation.
in simple realisation you create a websocket connection per each page, but if want optimize your application possible create one connect per all tabs.
for this optimize your can see how this realized in my open source comet server in file CometServerApi.js
In two words in file CometServerApi.js establishing a one connection to server from first opened tab ( i call this master tab), and other tabs send and receive message through master tab
For communications between tab i use event onstorage emerging on all tabs when i write any data to localstorage in any tab.

Browser based web app vs Mobile App?

In browser based web application(java), UI pages are served from web server . For example :- JSP are converted to HTML and then sent back to browser.
How does it work in Android Mobile Application ? Say i have a some mobile application whose home page has Employee Detail button. When i click on this button , I should be
navigated to new UI page(say Detail page) which should displays employee details.
Mine understanding :- On server side there will be restful API that will receive the http request and send the just Employee details in form of json. It will not send any UI
page. UI page(detail page) should already present inside mobile app. Now when i click the get detail button, i will be navigated to detail page . Now android API will fill
data i received from server in to that page. Is this correct ?
On server side there will be restful API that will receive the http request and send the just Employee details in form of json
It would not have to be JSON, though that is a typical response format for a Web service.
UI page(detail page) should already present inside mobile app
"Page" is not an appropriate noun here. Most GUIs do not use the term "page" for units of their user interface, as that is mostly used in Web apps. Desktop and mobile GUIs have other units of user interface: windows, screens, etc. In Android, the coarse unit of user interface is the Activity.
But, terminology aside, you are correct that normally a mobile app has code that will take the Web service response and use that to display results to the user, by one means or another.
Now when i click the get detail button, i will be navigated to detail page .
How navigation works is up to you and can take many forms.
This is no different than in a Web app. In a Web app, when the user clicks a button, the user might go to a different Web page, or might not. In the latter case, JavaScript code in the existing Web page might make a Web service call and update the contents of the current page.
The same thing is true for desktop and mobile programs.
Now android API will fill data i received from server in to that page
Some programmer's code will take data that the code received from the Web service and use that in the user interface, by one means or another.

JSF to send request on local machine on live application

We are doing university project in JSF 2.2 with primeface framework. We want to develop the application which is hosted on live server but the request needs to be sent on local machine from which user is accessing application. This might be stupid question but I would like to know if there is any possibility where we can do such implementation.
For example: We will host application 'www.somesite.com' on server, in this application we will have multiple forms, but we want this forms to be submitted to user local machine where we will deploy required component/service which will take the input from user and also send required response to user. It means, the view will be render from host server but data will be bind from local machine.
One way to do this is, when user submit form, we will send the request to host server and from server we will send data to user local machine where we will deploy required component/service which will be listening to server request/response, but we want to eliminate this layer and want to send direct request to user local machine as soon as user submit form
I would appreciate if you can help us....
If I understood well your request you need to change the action of the form to be able to send the request to a localhost.
I think the only way to do so is to use a pure html form and not a h:form. With an html form you can set the action attribute to a localhost.
JSF form with URL action?
But in this case you can have problem to use the jsf component, you will have a jsf warning (with javax.faces.PROJECT_STAGE set to Development)
The form component needs to have a UIForm in its ancestry. Suggestion:
enclose the necessary components within
see here for BalusC explanation

Categories

Resources