How to control print and cancel buttons on browser's print page? - java

I work on a Java web application on Eclipse.It has a screen, which some invoices are listed in a table.I can approve, edit,send via email,print or cancel the invoices via selecting them from the table.
When I click on print button, a MessageDialog gets opened and asks whether the user is sure to print the invoice, and I say yes.Then the browser's print page gets opened:
I want to be able to control the "Print" and "Cancel" buttons on these page.If I click on "Print", the status of invoice is going to be "PRINTED".If I click on "CANCEL" the status of invoice is not going to change, it should remain same.
When I execute the following method on the class,it opens browser's print page.
private void printPressed() {
browserContent.execute("printMe();");
}
And I am stuck at these stage.I want to modify this method for the purpose of controlling "Print" and "Cancel" buttons.How can I change it?

You can't as this will be security hole (Imagine that you make loop to print 1000000 pages of stg nasty). Every user must decide on his own.

Related

How can I create a popup menu that allows user to choose a certain elements from a list on Java?

I am writing a Java program to record some events and their status, i.e., done or not. I have implemented the recording and calculations, but I also want to have a button that will open another window that will list the events with a checkbox corresponding to each of them, so I can pick which ones' statuses I will change to done. I have only used Swing libraries so far.
I want this window to contain one event per line, with a checkbox next to the event. Each checkbox should determine whether the status of the even should be changed or not. I had trouble even making such a window open and list the items, let alone put the checkbox.
Note: The design is not too important. This won't be a published project, I will mostly use it for personal work. I can do with buttons instead of checkboxes, where any click changes the status of the event next to it.
Thank you in advance for your valuable responses.

vaadin UI call from callback

i am trying to build a 2-step process using vaadin. I created a view that holds my 2 main components (extends Div) which are displayed alternately.
to change from one of the main components to the other i have a ComboBox that i use for searching and therefore implemented a CallbackDataProvider, like seen below.
ComboBox<ResponsePartSearchResult> cmbPartSearch = new ComboBox<>();
CallbackDataProvider<ResponsePartSearchResult, String> provider = new CallbackDataProvider<ResponsePartSearchResult, String>(
query -> {
// fetch callback
}, query -> {
// retrieve count
});
The user is supposed to search for parts, get a list, and should be able to click on one of the results. this result is then displayed in the ComboBox. In another text field he has to add more info and click on a Button, in order to proceed. The Button's ClickListener retrieves the value from the ComboBox and the second TextField and sends it to a private method:
ResponsePartSearchResult value = cmbPartSearch.getValue();
value.q = txtPartSerial.getValue();
proceedToStepTwo(value)
BUT! If the user pastes a valid ID, the result coming back from the backend contains a certain flag, showing that this part was retrieved by its ID and with all required additional info. In this case the user is supposed to be directly "redirected" to the second main component, whithout the need to click the Button.
In this case I call the method proceedToStepTwo within the "fetch callback".
For the first case everything is running smoothly so far. For the second case, however, the 2nd main component and all it's UI elements are shown, but in order to click on something, whether it is a button or a checkbox, i need a double click.
It's a very strange behaviour without any error message. When I click on a Button (I added a sysout to a ClickListener) on that 2nd main component my RequestLoggingFilter shows a few of the following lines:
After request [uri=/?v-r=uidl&v-uiId=0;client=0:0:0:0:0:0:0:1;session= ...]
but not the content of the sysout. It only shows the content (and a few of the Logging lines above) when i doubleclick.
This shows that the Button reacts, but not entirely.
When I just let the fetch callback fill the ComboBox and TextFields and click the Button manually, it works again. But I want to get rid of the separate manual step.
I assume when I'm inside of that callback method, I need to call proceedToStepTwo differently, but how? Any ideas or experiences? Any help would be appreciated.
Thanks!
EDIT
When i debug and set a breakpoint into the method proceedToStepTwo() the UI will behave expectedly. However when i remove the breakpoint again and put a Thread.sleep(1000) in there, nothing changes and i cannot properly click the UI elements.

Callbacks in GWT - save data to the list after click submit button

I have a interesting problem with callbacks in GWT. My application have a form, where I have few fields, OK button which add something to the list and a main send button.
When I fill all fields, click OK button first and click send button, on the next page, I see the results - everything I wrote to the form is correctly displaying on the confirm site.
But, I have a problem with fields which add something to the list - I have fields, where I put the name and surname, click the button OK next to this field which add this data to the list. It works good, I can add as many data I want. This button has his own onClick() method, which do something - this is not important here what. As I said, when I click OK button, data is added to the list.
But, I have also my main send button. I want to add data to the list with this button, but without clicking on the button OK.
Example:
I have put some data to the fields name and surname, I haven't click button OK and I click send button. The problem is, data was not add to the list and on my confirm page I cannot see the correct result. Of course, under the send button I called click() method from the OK button.
Maybe I don't know well how callbacks work, but this is very difficult thing for me to solve this problem.
If I manually click on the OK button, everything is good. When I do this same thing by programming side, it does not work. I debugged it for a long time, but in any cases everything run identically. Differents are in the final result.
My question is - how to add data to the list only by clicking send button?
EDIT - some pseudo code how it looks right now:
View class has method (form is a place where I have name and surname fields with button OK:
public void add(){
form.addButton().click();
}
Presenter for this view, where I have sendButton:
sendButton.addHandler(new ClickHandler(){
#Override
public void onClick(ClickEvent event) {
view.add();
}
}

Java login page lead to next gui

I am creating a java application that requires a login, using Eclipse. I have created 2 GUI's, the first is the login page and the second displays the data.
My problem is, once the user enters the login details, how do I get it to switch to the second GUI?
Have a listener on either a key press or a button click that closes your current GUI and creates the new one.

Android: Display a message during a call

I have a program that makes a phone call when a user clicks on a button. The user will need to provide some information very fast to the person who answers the call(ie GPS coordinates). The problem that I am having is that, once the user clicks on the call button, they cant go back to my application.
I want to know if it possible to bring my application to the front (without hanging up the call) or to display a message until the user clicks the ok button... or something like that. I tried toast notification but they disappear and I want them to stay until the user decides to close it.
look up startActivityForResult() and see if you can hook into the calling code.

Categories

Resources