Add confirm (Yes /No) dialog box inside Model class in Adempiere - java

I want to create confirm dialog box inside Model class.
I created window which has several text boxes and after entering the values user can save data. At the point of saving data I want to add a confirm dialog box asking "Are you sure to save these data ?"
So inside Model class I tried to put
org.adempiere.webui.window.FDialog.ask(1,null,"Are you sure to save these data ?");
When I add this into my code, it will give errors and I can't build the project.
If anyone knows how to add confirm dialog box in model class? Please help me to do this...

In Adempiere
For Swing Class (i.e.) model class you can use by below
int response = JOptionPane.showConfirmDialog(null, Are you sure to save these data ?
"", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION)
;
else
;
or
Adialog in Client modules cann't used in Base modules
ADialog.ask(WindowNo, null,"Are you sure to save these data ?");
FDialog Should be used only in ZKWebui package, never use zk classes in base/client modules
org.adempiere.webui.window.FDialog.ask(1,null,"Are you sure to save these data ?")
In window/tab before save you can use "Commit Warning" column in Window,Tab & field (Application Dictionary)
Hope it will helps you.

You can use JOptionPane but not ADialog or FDialog.
Usage of ADialog throws build error. As its is defined in client folder, you cant use it in the upper hierarchy.
You can find the build order from here

Related

Read external Files with GlassFish / Vaadin?

I would like to make .txt-files accessible for my VaadinApp on a GlassfishServer.
Lets say I have a .txt-file, its content is 12345.
Now, when I click a button on my Vaadin StartPage, I would like to show the Data that has been written into this .txt-file.
I know how Java Input/Output is working but I have no clue how to make those files accessible for my VaadinApplication running on Glassfish 4.1.2.
Is there a folder I can put the .txt-file in, or how would I access the file?
Thanks
There is component named Label is available in Vaadin.
So that, the values which needs to be shown on the screen can be set as a caption/value for that object.
This can be done either through constructor or setter in that object.We will set the value through the setter as we need to display the value, once the button is clicked. That can be done like this.
Label sampleLabel = new Label();
sampleLabel.setContentMode(com.vaadin.shared.ui.ContentMode.HTML);
Now we will see how this can be added to the label, when a button is clicked.
Button sampleButton = new Button("Click");
sampleButton.addClickListener(event -> sampleLabel.setValue(<call the method that reads data from the text file>));
I hope this will be helpful.
Note: Basically you can place the file anywhere in the system.
But most preferred way.
If you are using maven to build the project, place the files in the resource folder.(src/main/resources)

How to open a form created on GWT using QRcode?

I have created a form that show details of a student (using GWT). I want to create a link of that form that should be opened using QR Code.
So basically you need an URL to open a particular form.
First I suggest you to read documentation about History Mechanism. One of it's main feature is:
It’s “bookmarkable”. I.e., the user can create a bookmark to the
current state and save it, email it, et cetera.
So you will be able to create a link to a specific application state. In your case a student form.
In the EntryPoint class, in onModuleLoad() method add this:
if(History.getToken() == "student_form")
// show student form
else
// proceed as normal
Now just add a history token at the end of yous normal URL (after a # sign) like this: http://host.com/#student_form or http://host.com/page.html#student_form.

JAVA gwt - saving info after refreshing page

At the moment , im working with java gwt and i stopped studdenly because one problem occured. I want that my information (for example string) will save after refresh button is clicked.
// user enters something in TextArea textArea1 object
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
//maybe there is a function or what
pleaseSaveInfomation(textArea1);
}
});
I tried this , but i know how to implement it correctly to my source code:
https://stackoverflow.com/a/14220746/5010218
The last(worst) chance is to store data from textArea in file.txt , after refreshing i could read info from file and thats all. But maybe GWT has a specific handler/method/class or what to handle this.
Thats for your opinion and help.
I had the same problem. You can easily overcome it with this.
import com.google.gwt.storage.client.Storage;
private Storage stockStore = null;
stockStore = Storage.getLocalStorageIfSupported();
Please read documentation
http://www.gwtproject.org/doc/latest/DevGuideHtml5Storage.html#UsingStorage
When a browser close a window (because of a refresh, or the user has closed the window, changed the url, etc), a script is not allowed to prevent this action. It's not specific to GWT.
However, you can suggest to the browser-agent to show a confirmation to the user. You can do this with the message property of the closing event.
In GWT:
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
closingEvent.setMessage("Confirm ?");
}
});
You shouldn't rely on this event to store your data, as a lot of condition can prevent you to do this. You should maybe periodically store a draft to the local-storage or to the server.
You probably want to store your data in sessionStorage. In GWT, this the Storage class.

Android Studio - URL string

So I'm pretty new to the whole Android Studio thing and I've been using the internet to help me with a lot of the things I am doing and needed help on something.
I'm not sure if it's possible to connect this to either a string or an SQL database but I have a Main Layouts with a bunch of buttons that allow me to click on them and choose what external player I would like to use to watch the video. In my MainActivity java class, this is how it finds the button.
case R.id.button3:
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://videoname.mp4"), "video/*");
startActivity(Intent.createChooser(intent, "Choose an External Player"));
break;"
I wanted to know if "http://videoname.mp4" url can be connected to like a string where I can always update or change the URL instead of manually going to find the URL in the MainActivity java and changing it. As of now I have to manually do it but a different way to do it would be helpful.
I'm sorry if it's all confusing, but if you know, please let me know as soon as.
Thank you.
you just need write your string URL :
open your directory folder /res/values/strings.xml -> write your string : <string name="yourStringName>yourStringURL</string>. to use your string do this
getContext().getString(R.string.yourStringName) in fragment
getString(R.string.yourStringName) in Activity
or you can write directly on your code, put your cursor on your string, then press key alt + enter choose extract string resource fill the resource name with your string name
wherever you need to use it, just do point 1 or 2. also in your Intent
hope this help you, never stop learning!
Add it to strings.xml in your project. That is the recommended way of using strings anyway.

How to create a dialoge message that transfer user to another window

Can some one give an example of how I can use a window which can transfer user to another window.
for example I want to give the user a suggestion and if he press ok he will be transfer to the application manager setting (specifically to the settings of specific app so he can change it), ho can I do that?
thank you
Use JOptionPane. For example:
int option = JOptionPane.showMessageDialog(frame,"Prepare for redirecting");
if(option==JOptionPane.OK_OPTION)
{
SwingUtilities.invokeLater(()->{
new MyAnotherWindow().setVisible(true);
}
}

Categories