DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

The Latest Popular Topics

article thumbnail
MQTT Messaging With Java and Raspberry Pi
In this article, learn how to send and visualize sensor data using multiple types of Raspberry Pi boards, MQTT, and HiveMQ. Includes video tutorials.
March 18, 2022
by Frank Delporte
· 11,088 Views · 6 Likes
article thumbnail
Spring Boot: Cross-Origin AJAX HTTP Requests
What is CORS (Cross-Origin Resource Sharing)? In this Spring Boot video tutorial, we take a closer look at the Cross-Origin AJAX HTTP Requests.
March 18, 2022
by Ram N
· 3,795 Views · 3 Likes
article thumbnail
Blink a LED on a Raspberry Pi With Vaadin
Build a responsive website with Vaadin Flow to control electronic components connected to a Raspberry Pi with Pi4J
March 17, 2022
by Frank Delporte
· 8,576 Views · 9 Likes
article thumbnail
Building a Vector Database for Scalable Similarity Search
The first one in a blog series to take a closer look at the thought process and design principles behind the building of the most popular open-source vector database.
March 17, 2022
by Jun Gu
· 4,139 Views · 4 Likes
article thumbnail
Polymorphism and Dynamic Binding in Java
Learn about polymorphism in Java and the two types: compile-time and runtime. Plus, we take a look at demonstrations of how to achieve static and dynamic binding.
March 17, 2022
by Ankit Dixit
· 10,988 Views · 2 Likes
article thumbnail
Unsupervised Learning in Data Mining: Apriori Algorithm
Unsupervised learning in data mining for rule association via the Apriori Algorithm.
March 17, 2022
by Ritresh Girdhar
· 6,043 Views · 3 Likes
article thumbnail
Performance Evaluation of Python
Python is known for its classic properties and versatile usage. Let's evaluate its performance in areas like development, automation, data extraction, and more.
Updated March 17, 2022
by JASMEET SEHGAL
· 8,601 Views · 5 Likes
article thumbnail
Modular Feature-Driven Development: The Smartphone Pattern (OS) with React and Redux
In this post, see how feature-driven development should play a main role in the software development cycle, and design and implement modular features.
March 17, 2022
by Oren Farhi
· 3,435 Views · 3 Likes
article thumbnail
Automation Testing: The Bright Future of Software Testing
Automation Testing will help developers simplify the web development process. From creating tests to managing the deployment, it helps you achieve everything!
March 17, 2022
by Rodolfo Davis
· 3,670 Views · 2 Likes
article thumbnail
What's New With Java 17 and Containers?
Quarkus allows developers to start a new application development based on OpenJDK 17. Read the tutorial below to find out how!
March 16, 2022
by Daniel Oh DZone Core CORE
· 4,922 Views · 5 Likes
article thumbnail
How Vue Components Work
Let's look at how Vue uses components, and how to implement them in your code.
March 16, 2022
by Johnny Simpson
· 3,256 Views · 3 Likes
article thumbnail
React Apps Can Be Incredibly Fast: Here’s How to Optimize Load Time
Do you want to increase the speed of your React app? This article will help you optimize load time and make your React App faster. Don't miss this guide.
March 16, 2022
by Pratik Mistry
· 3,904 Views · 3 Likes
article thumbnail
How to Get Started With Vaadin Flow
In this blog, I will show you how I got started with Vaadin Flow. With Vaadin Flow, you can create web apps without HTML or JavaScript, but entirely with Java. Let’s get started! 1. Introduction For some time, I have been curious about Vaadin Flow. I am not very good in frontend developement but sometimes I try to get myself together and then I take a look at a frontend framework. In a previous post, I looked at React for example. Although the React introduction was a nice experience, I still did not think I could create a frontend with React before investing a serious amount of time. At Twitter, I often saw posts coming by about Vaadin and this took my interest. So, I put Vaadin on my blog todo list. A few weeks ago, I started to take a closer look at Vaadin, and more specifically at Vaadin Flow. Reading some blogs and examples, it reminded me about Java Swing but where Java Swing would create a traditional desktop application, Vaadin will create a web application for me. That sounds cool, because now I probably do not have a very steep learning curve and I can continue working in my Java IDE. Besides that, it also seems to integrate quite well with Spring, which I also already know. Enough prerequisites which should lead to a succes story for me. During my research I came up to the following interesting articles: Why I (still) love Vaadin, by Nicolas Fränkel; 5 Reasons Why Enterprises Use Vaadin For Their Web Application UI Needs, by Ankurman Shrestha Vaadin also takes care of the communication between frontend and backend. But when you are using a First API approach, you can call the API from the Vaadin backend part preventing duplication in your code. 2. Vaadin Flow Tutorial The easiest way to get started, is by following the Vaadin Flow Tutorial. Beware that you select the correct version of Vaadin Flow. At the time of writing, Vaadin 14 is the LTS version and is the one you should use when running in production, Vaadin 22 is the latest non-LTS version with new features to experiment with. I am most interested in the current production status and follow the Vaadin 14 Tutorial. The tutorial contains a basic project which you will enhance each time with code snippets which are provided. Also, the concepts and code snippets are clearly explained. Some basic components are used, login is added and it is also shown how you can write tests for the application. The latter is a great advantage because automated testing of a frontend application is always difficult to execute. It takes about 3-4 hours to complete the tutorial, but after that, you already have a good basis for creating your own project. The only disadvantage for me is that the tutorial is mainly copying of code snippets. This way, you miss certain details when trying to use Vaadin Flow yourself. 3. Own Project Let’s see whether I am able to create a frontend for a simple application. The application I create is quite basic and contains of a list of Shows for which ShowEvents can be created. A Show consists out of a title and a ShowEvent consists out of a date and the Show the event is for. The sources for this project can be found at GitHub. I will not explain the entire application, but I will mention some highlights how I built the application. 3.1 Get Started In order to get a quick start, I navigated to start.vaadin.com. Here you can configure the basic setup for the application. I chose an Empty template and added two views: one for the Shows and one for the ShowEvents. In the Settings tab, I changed the Project, the Group ID and decided to use Java 17. When ready configuring, I clicked the Download button and opened the project in my favorite IDE. In the pom, I changed the vaadin dependency to vaadin-core. Reason for this is that I only want to use free components and this should be more than enough for the basic application I want to build. XML com.vaadin vaadin-core ... Next, I wanted to run the application by running the main method of the Application class. Remember, Vaadin integrates well with Spring, so we are talking about a Spring Boot application here. However, this gave the following exception: Shell java.lang.IllegalStateException: The compatibility mode is explicitly set to 'false', but there are neither 'flow-build-info.json' nor 'webpack.config.js' file available in the project/work I was a little too enthusiastic, I had to build the application first. Shell $ mvn clean package After this, the application started successfully. 3.2 Creating the Application I started with creating the data package and copying the AbstractEntity of the tutorial into it. This required adding the spring-boot-starter-data-jpa dependency to the pom. OK, I know I wrote that by copying you miss some details and now I do it myself, but there is nothing wrong with a smart copy now and then. XML org.springframework.boot spring-boot-starter-data-jpa Next, I created the Show and ShowEvent entities and added the JPA repositories. Vaadin also provides a dependency for generating example data. This way, you can generate data into your application for testing purposes. Therefore, I added the exampledata dependency and created the DataGenerator class. XML com.vaadin exampledata 4.1.0 In order to get this working, I had to remove the NotEmpty annotation because of the following exception. I did not investigate this exception any further. Shell No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.time.LocalDate' Next, I created the ShowService and added the H2 database as a dependency to the pom. XML com.h2database h2 Building and starting the application was successfull again and after that, I implemented the ShowsView, ShowEventsView and the ShowEventForm. The first two are for displaying the Shows and ShowEvents into a grid and the ShowEventForm will allow us to change and delete a ShowEvent. To give you an impression, some screenshots are shown here. The Shows page. The ShowEvents page. The ShowEvent form. 3.3 Lazy Loading In the DataGenerator the number of ShowEvents was initially set to 50, but when I increase this to 1000, then a problem occurs in the ShowEvents page. The whole list of ShowEvents is retrieved and loaded into memory. This will get worse when the list grows even further. The solution is provided in the documentation. First, I needed to change to ShowEventRepository by extending it from PagingAndSortingRepository instead of JpaRepository. Java public interface ShowEventRepository extends PagingAndSortingRepository { } Following the instructions of the documentation worked just fine when I scrolled slowly through the list, but when I scrolled a bit faster an IndexOutOfBoundsException was thrown. Shell java.lang.IndexOutOfBoundsException: Index 50 out of bounds for length 50 In order to explain why this exception occurs, we need to take a look at the code for fetching the results. Java private void updateList() { DataProvider dataProvider = DataProvider.fromCallbacks( // First callback fetches items based on a query query -> { // The index of the first item to load int offset = query.getOffset(); // The number of items to load int limit = query.getLimit(); List showEvents = showService.fetchShowEvents(offset, limit); return showEvents.stream(); }, // Second callback fetches the total number of items currently in the Grid. // The grid can then use it to properly adjust the scrollbars. query -> showService.countShowEvents()); grid.setDataProvider(dataProvider); } The offset and the limit (number of items to load) are retrieved from the query provided by Vaadin. However, JPA pagination needs a page and a limit. Therefore, the page needs to be calculated by dividing the offset by the limit. Initially, I just used the offset directly for the page and this caused the error. Java public List fetchShowEvents(int offset, int limit) { return showEventRepository.findAll(PageRequest.of(offset / limit, limit)).stream().toList(); } 4. Conclusion My first experience with Vaadin is quite positive. In most cases, I just need a frontend for an administrator or a limited set of users. With Vaadin I can make use of my Java experience and still provide a fancy web application. Also, the idea that I am able to create tests appeals me a lot. The free components will be most of the time enough for these kind of applications and if not, also some more advanced components are provided by means of a license.
March 16, 2022
by Gunter Rotsaert DZone Core CORE
· 2,859 Views · 2 Likes
article thumbnail
Java on Raspberry Pi
In this post, follow an overview of resources with information and examples of Java projects to control electronic components on the Raspberry Pi.
March 16, 2022
by Frank Delporte
· 9,860 Views · 7 Likes
article thumbnail
Where Spring Boot Meets Machine Learning Services: A Study
In this post, learn more about how the Deep Java Library brings Java developers into the machine learning (ML) game.
March 16, 2022
by John Vester DZone Core CORE
· 48,080 Views · 6 Likes
article thumbnail
Spring Boot: How To Use Java Persistence Query Language (JPQL)
In this Spring Boot video tutorial, take a closer look at how to use Java Persistence Query Language(JPQL), RESTful Web Services.
March 15, 2022
by Ram N
· 4,708 Views · 7 Likes
article thumbnail
Devoxx UK 2022: Designing Your Best Architecture Diagrams
Learn about a workshop that explores how diagramming is one of the most important communication tools to use for sharing your project and architectural ideas.
March 15, 2022
by Eric D. Schabell DZone Core CORE
· 2,362 Views · 4 Likes
article thumbnail
The Rise of the Data Reliability Engineer
With ever-growing complexity in the data driving today's dashboards and learning models, maintaining data quality and availability depends on the DRE.
March 15, 2022
by Alvin Lee DZone Core CORE
· 9,118 Views · 7 Likes
article thumbnail
What Devs Need To Teach CEOs About AI With Lexion’s Emad Elwany
Lexion's CTO and Co-Founder Emad Elwany gives a crash course on the current status of AI technology and what we can all expect in the future.
March 14, 2022
by Dan Lines
· 5,182 Views · 4 Likes
article thumbnail
Deploying AI With an Event-Driven Platform
Explore advantages of an event-driven platform for model deployment of your platform and create greater accessibility to your model classifications results.
March 14, 2022
by Tim Spann DZone Core CORE
· 8,686 Views · 3 Likes
  • Previous
  • ...
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×