Javafx change view during runtime and save the new one - java

I am searching for a way to change the view of an JavaFX FXML Application during runtime and save the result so, that it is present at the next Application start. Is there a way? I was searching the WWW but dont find any solution! For example: I have a function where i can add a label to a GridPane and can save the new added label. At the next start of my Application, the new label is present. Its for an DB Application where the user can add new Database fields for custom data.

I think, by using properties file(or DataBase) you can achieve this. Before closing the application update the current status into properties file. So that while opening the application once again read the properties file and update it to the previous status.

Related

Azure event Grid trigger function is reading all the existing files in Java

I have Created an azure Evet Grid trigger Java function which reads blob files whenever a new file is uploaded to container.
But the problem is when I deployed the function , its reading all the existing files from container. Ideally it should get triggered only when there is a new or updated files uploaded to container.
Here is the code.
#FunctionName("MyEventGridTrigger")
#StorageAccount("AzureWebJobsStorage")
public void run(#EventGridTrigger(name = "eventGridTrigger") String msg,
#BlobInput(name = "blob", dataType = "binary", path = "{data.url}") byte[] byte,
final ExecutionContext context) {
context.getLogger().info("Event Grid trigger function executed.");
// Logic to read file from byte[]
}
Everything working fine, but its reading the existing files.
Thanks in advance.
I have also implemented same type of event grid through azure portal. I followed three steps.
Create Azure Storage Topic :- That is Event Grid System Topic
Event Subscription and Filter :- in this step, there are two main point
a. Event type :- Tell when event trigger for example create blob (when file is uploaded in blob) or delete blob.
b. End Point Type:- Which subscribe the event like azure function. At this point give information about azure function.
Handle Event with AzureFunction :- Write Code for handle event or action after event fire.
Please click on this link for more help :- Create, view, and manage Event Grid system topics in the Azure portal
By this, you can start your journey in azure and then you can figure it out that how can do by without azure portal. But for custom event grid also you need to create event grid topic.
Note :- Before using Event Grid in azure, Need to register Event Grid Resource Provide first
Please let me know if you still are facing issue.

How to reload/ refresh a table after adding new data to database table?

I use rapidClipse 4.0
And I am at beginning with rapidClipse and java
I created a page with a table and a fieldgroup.
After saving a new record, the table gets not refreshed.
The Properties:
AutoQueryData is false
Data is "findAllContacts" (JPASQL Query)
Entity is set.
All col's are set
I tried to follow the video "RapidClipse: Daten manuell laden"
I followed: https://www.rapidclipse.com/en/forum/index.php/forum/programmierung/495-table-refresh-bei-neuem-datensatz
and
https://www.rapidclipse.com/en/forum/index.php/forum/bugs/120-aktualisierung-anzeige-tabelle
---> This Method is not available/undifined
I tried use
- this.table.getBeanContainerDatasource().refresh()
- this.table.getBeanContainerDatasource().addAll(new OkmMetaDataValueDAO().findAllContacts(); --> This did fill the table a second time/twice with the same data,but did not reload it.
- this.table.addContainerDatasource().addAll(...
to reload the Container
All without success.
I feel, that I have to trigger a content reload at the client, by using java-script. but how to do it with rapidclipse?
Could someone explain, what I have to consider/ think about or what I did wrong?
All help would be appreciated!
Thank you in advance - OpaHeinz
this.table.getBeanContainerDatasource().refresh()
Always works for me (which you already did).
Note: Some time it take time to have affect in Database and then the view.
In my case, I had this problem. I had to delete the data and refresh the table as soon as data gets deleted. What I found was the time lag. So I placed one more button beside delete button. When someone delete data the "Delete" button gets disabled and refresh button gets enable, the only way to enable "delete" button is to click on refresh.

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)

Text duplication

I am working on simple text editor and on main panel, I have JList with currently opened files (CDocument class) and active document, which contents is shown (also CDocument class). I store opened files (CDocument objects) in vector and on the right side the active document is shown.
Now, at program start, there is no active document and opened document list is empty. After I click File->New, I create new, empty object from class CDocument. If I enter something into active document area (the red region on screenshot) and then I reclick File->New, I get new, empty (with no text - I've doublechecked with ) CDocument object. But, the text from previous active document still shows into newly created (red region - newly empty CDocument). I am busting my brain here because I do not know why?! Here is File->New code chunck:
`
if(e.getSource()==this.menuItemFileNew())
{
CDocument currentDocument=new CDocument();
if(this.panelMain().documentActive()!=null)
{
this.panelMain().remove(this.panelMain().documentActive());
}
this.panelMain().openedDocuments().add(currentDocument);
this.panelMain().setDocumentActive(currentDocument);
this.panelMain().add(panelMain().documentActive().pane(),
BorderLayout.CENTER);
this.panelMain().documentActive().addKeyListener(this);
this.panelMain().documentActive().requestFocus();
this.menuItemFileSave().setEnabled(true);
this.menuItemFileSaveAs().setEnabled(true);
this.menuItemFileClose().setEnabled(true);
this.menuItemFileCloseAll().setEnabled(true);
this.toolBarFileSwitcher().panelActiveDocumentInfo().
panelFileSizeInfo().updatePanel(this.panelMain().documentActive().getText().length(),
false);
this.toolBarFileSwitcher().listOpenedFiles().model().addElement(currentDocument.filename());
this.toolBarFileSwitcher().listOpenedFiles().setSelectedIndex(this.toolBarFileSwitcher().listOpenedFiles().model().size()-1);
this.toolBarFileSwitcher().setVisible(true);
}
`
Why is text shown, I've tried updateUI, repaint, nothing works!
Use Action to encapsulate functionality related to your CDocument data type. This will help ensure that all invocations are consistent. This example manages images, while this example illustrates a menu of files.

Vaadin, where to put images?

I have a Liferay project with Vaadin portlet.
I want to add icon to my buttons.
Button search = new Button("Search");
search.setIcon(new ThemeResource("img/silk/add.png"));
But dont know where i gonna put it? Now i put it in docroot directory.
UPDATE
No i try this.
Button search = new Button("Search");
search.setIcon(new ThemeResource("LifeRayVaadin-portlet/icons/add.png"));
But when i redeploy project in console get
09:34:05,773 WARN [404_jsp:109] /html/VAADIN/themes/liferay/LifeRayVaadin-portlet/icons/add.png
So your portlet is looking for the icons in /html/VAADIN/themes/liferay/LifeRayVaadin-portlet/icons/add.png.
You could create a directory icons under VAADIN and call:
search.setIcon(new ThemeResource("../../icons/add.png"));
ThemeResource without any path will look for the file in VAADIN/themes/yourtheme/ path and thus ../../ will get you (in this case) to /VAADIN/. I personally would never hardcode the name of a theme or a portlet in a project, because when it changes you have to go through every reference and change them.
You can put your images in $PORTLET-NAME/docroot/icons directory and call them using the Path
/$PORTLET-NAME$/icons/add.png
in your case it will be
Button search = new Button("Search");
search.setIcon(new ThemeResource("/$PORLTET-NAME$/icons/add.png"));

Categories