SlideShare a Scribd company logo
1 of 17
Download to read offline
Formio
Need a form?
Radek Beran
Motivation
● I hate solving of repetitive problems where it is not
necessary
● I want to solve them in a simple way
● I want to have an easy to use tool that i can use
anywhere…
Formio | Radek Beran 2
Formio
● Form definition & binding framework
● Easy-to-use configurable handy tool
● Validation of form data (using bean validation)
● Support for file uploads, configurable max. request/file size
● Immutable, composable form definitions
● One simple entry point to API
● Easy integration to existing frameworks
● For environments with or without HttpServletRequest
● Simply unit testable forms
Formio | Radek Beran 3
Simple form example
Formio | Radek Beran 4
private static final FormMapping<Person> personForm =
Forms.automatic(Person.class, "person").build(/* Opt. config */);
…
FormData<Person> formData = new FormData<Person>(
person, ValidationResult.empty);
FormMapping<Person> filledForm = personForm.fill(formData);
// push filledForm to template …
…
FormData<Person> formData = personForm.bind(
new ServletRequestParams(request));
if (formData.isValid()) {
// save person – formData.getData() …
} else {
// fill and show the form again …
}
Formio API
● Forms – entry point
● FormMapping, BasicFormMappingBuilder
● FormField, FieldProps for field definition
● ParamsProvider
● ValidationResult
● ConstraintViolationMessage
● Config
● Formatters, Formatter
● CollectionBuilders, CollectionBuilder,
● BeanExtractor
● Binder, Instantiator, ArgumentNameResolver
● BeanValidator
● PropertyMethodRegex
● UploadedFile
Formio | Radek Beran 5
Data binding
●
Setter and construction method binding
●
Immutable objects supported (Instantiator abstraction)
●
Default or non-default constructors
●
Static factory methods
●
Collections and arrays
●
Complex nested objects and lists of complex objects
●
And arbitrary combination recursively
●
Primitives (and their wrapper classes) supported everywhere
●
String, Enums, BigDecimal, BigInteger, Date supported by default
formatters
Formio | Radek Beran 6
Data for templates (1)
●
Just push the filled form to the template
●
Use its properties
●
validationResult
●
success
●
fieldMessages
●
globalMessages
●
fields – Map<String, FormField>
●
name – unique name/path of mapping
●
labelKey – key for caption of nested complex object carried by
mapping
●
filledObject
●
required
●
nested – map with nested mappings
●
list – list of nested mappings for complex objects if this is
MappingType.LIST mapping
Formio | Radek Beran 7
Data for templates (2)
●
Properties of FormField
●
name – unique name/path of form field
●
labelKey – key for localization of label (name without brackets)
●
filledObject, filledObjects (for group of checkboxes, multiselect)
●
required
Formio | Radek Beran 8
Form definition (1)
Formio | Radek Beran 9
private static final FormMapping<RegDate> regDateMapping =
Forms.basic(RegDate.class, "regDate").fields("month", "year")
.build();
private static final FormMapping<Registration> registrationForm =
Forms.basic(Registration.class, "registration")
// whitelist of properties to bind
.fields("attendanceReasons", "cv", "interests", "email")
.nested(Forms.basic(Address.class, "contactAddress",
Forms.factoryMethod(Address.class, "getInstance"))
.fields("street", "city", "zipCode").build())
.nested(Forms.basic(Collegue.class, "collegues",
null, MappingType.LIST)
.fields("name", "email")
.nested(regDateMapping)
.build())
.build();
Form definition (2)
Formio | Radek Beran 10
Or equivalent automatic one
●
Or equivalent automatic mapping
private static final FormMapping<Registration> registrationForm =
Forms.automatic(Registration.class, "registration")
.nested(Forms.automatic(Address.class, "contactAddress",
Forms.factoryMethod(Address.class, "getInstance")).build())
.build();
• Automatic mapping
● Introspects readable (and settable – via setters/instantiators)
properties (incl. nested objects, list of nested objects)
● @Ignored on getters can be used
● Custom field definitions have precedence
• Custom field definition
Forms.<Date>field("birthDate", "text")
.formatter(CUSTOM_DATE_FORMATTER).build();
Form definition (2)
Validation
●
Using bean validation API (JSR-303)
●
ValidationResult
●
ConstraintViolationMessage(s) for global and field constraints
●
Fields (properties) and also mappings (whole complex objects) are validated
●
Binding and validation errors
●
Custom message bundle can be configured
●
Default are properties for class of form data
●
Fallback to ValidationMessages.properties with default messages
●
Message bundle need not to be used
●
Error messages carry possible translation and also unresolved key with
arguments
Formio | Radek Beran 11
Other validation features
●
Conditional validation
●
Using bean validation groups
●
Custom validators can be written
●
NotEmpty
●
RodneCislo
●
Email
●
CustomMultiFieldValidator, …
●
Error, warning, info severity supported and recognized from payload
of annotations
●
Required flag automatically filled from Size, NotNull and derived
constaints in default validator implementation
●
For FormFields
●
For mappings of complex objects
Formio | Radek Beran 12
Configuration
●
Config object (Created using Forms.config()…build())
●
Immutable
●
Default configuration available
●
Custom configuration can be supplied
●
Automatically propagated to nested mappings
Formio | Radek Beran 13
File uploads
●
Using Apache FileUpload API
●
Max. request size, size of one uploaded file, threshold for storing
data in memory can be set via Formio API
●
Global/field ConstraintViolationMessages created when limits are
exceeded
●
Automatic binding to UploadedFile, collections/arrays of
UploadedFile(s)
●
UploadedFileWrapper as a complex object for indexed lists of
uploaded files (nested list mappings)
Formio | Radek Beran 14
What about AJAX?
●
AJAX compatible
●
You can expose server methods/API for update of state called from client
●
On the server: Form definition can be filled with current data updated with
sent data
●
Filled nested mapping (inc. its validation result) can be sent back to client
●
Cooperating AJAX framework can be used
●
Twinstone TDI, jQuery, …
Formio | Radek Beran 15
Formio vs. Spring
● Formio Pros:
● Even easier to learn and use than forms in Spring
● Functional form processing, immutable/composable/reusable form definitions
● Immutable view/domain objects can be used (via constructors, static factory
methods), arbitrarily nested – no need for custom Spring MVC
WebArgumentResolver(s) or HttpMessageConverter(s)
● Minimum of dependencies (bean validation, fileupload)
● Message bundle for form data class with fallback to common ValidationMessages
● Not bound to any particular UI architecture like MVC, but fully usable in Spring
MVC or other frameworks
● Automatic construction of form field names/paths, also for nested objects/lists
● Self-contained independent object representation of a form
● Cons:
● Spring is widely used and offers usable solution in Spring MVC
Formio | Radek Beran 16
Q & A?
Formio | Radek Beran 17
Documentation: http://www.formio.net
Demo: http://formio-demo.herokuapp.com/

More Related Content

What's hot

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesVMware Tanzu
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewShahed Chowdhuri
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorialvinayiqbusiness
 
15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由
15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由
15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由Yasuhiro Horiuchi
 
Express JS Middleware Tutorial
Express JS Middleware TutorialExpress JS Middleware Tutorial
Express JS Middleware TutorialSimplilearn
 
Spring boot
Spring bootSpring boot
Spring bootsdeeg
 
IBM Watson Assistant - Build Chatbot and Deploy to Slack
IBM Watson Assistant - Build Chatbot and Deploy to SlackIBM Watson Assistant - Build Chatbot and Deploy to Slack
IBM Watson Assistant - Build Chatbot and Deploy to SlackUpkar Lidder
 
Spring Boot—Production Boost
Spring Boot—Production BoostSpring Boot—Production Boost
Spring Boot—Production BoostVMware Tanzu
 
Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioMindfire Solutions
 
Service cloud 開発概要 Webセミナー 前編
Service cloud 開発概要 Webセミナー  前編Service cloud 開発概要 Webセミナー  前編
Service cloud 開発概要 Webセミナー 前編Salesforce Developers Japan
 
Azure インフラの信頼性とガバナンス
Azure インフラの信頼性とガバナンスAzure インフラの信頼性とガバナンス
Azure インフラの信頼性とガバナンスDaisuke Masubuchi
 

What's hot (20)

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorial
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由
15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由
15分でわかるAWSクラウドで オンプレ以上のセキュリティを実現できる理由
 
Spring boot
Spring bootSpring boot
Spring boot
 
Express JS Middleware Tutorial
Express JS Middleware TutorialExpress JS Middleware Tutorial
Express JS Middleware Tutorial
 
Spring boot
Spring bootSpring boot
Spring boot
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
IBM Watson Assistant - Build Chatbot and Deploy to Slack
IBM Watson Assistant - Build Chatbot and Deploy to SlackIBM Watson Assistant - Build Chatbot and Deploy to Slack
IBM Watson Assistant - Build Chatbot and Deploy to Slack
 
Spring Boot—Production Boost
Spring Boot—Production BoostSpring Boot—Production Boost
Spring Boot—Production Boost
 
Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.io
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
Service cloud 開発概要 Webセミナー 前編
Service cloud 開発概要 Webセミナー  前編Service cloud 開発概要 Webセミナー  前編
Service cloud 開発概要 Webセミナー 前編
 
Azure インフラの信頼性とガバナンス
Azure インフラの信頼性とガバナンスAzure インフラの信頼性とガバナンス
Azure インフラの信頼性とガバナンス
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 

Similar to Formio - form definition & binding library for Java platform

XPages - The Ties That Bind
XPages - The Ties That BindXPages - The Ties That Bind
XPages - The Ties That BindMichael McGarel
 
Cloud data loading
Cloud data loadingCloud data loading
Cloud data loadingFeras Ahmad
 
Pdf template Invoice
Pdf template InvoicePdf template Invoice
Pdf template Invoicenm2allen
 
Symfony Form Basics - OroMeetup #3 Cherkassy
Symfony Form Basics - OroMeetup #3 CherkassySymfony Form Basics - OroMeetup #3 Cherkassy
Symfony Form Basics - OroMeetup #3 CherkassyAndrew Yatsenko
 
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8Philip Norton
 
Day 6.1 and_6.2__flat_files_and_service_api
Day 6.1 and_6.2__flat_files_and_service_apiDay 6.1 and_6.2__flat_files_and_service_api
Day 6.1 and_6.2__flat_files_and_service_apitovetrivel
 
Sitecore xDB - Architecture and Configuration
Sitecore xDB - Architecture and ConfigurationSitecore xDB - Architecture and Configuration
Sitecore xDB - Architecture and ConfigurationCodersCenter
 
Using jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityUsing jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityMark Rackley
 
Angular Reactive Forms vs React Redux Form
Angular Reactive Forms vs React Redux Form Angular Reactive Forms vs React Redux Form
Angular Reactive Forms vs React Redux Form Briisk
 
Best practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata APIBest practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata APISanchit Dua
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementingDoria Hamelryk
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataPace Integration
 
C# .NET Developer Portfolio
C# .NET Developer PortfolioC# .NET Developer Portfolio
C# .NET Developer Portfoliocummings49
 
Performance in .net best practices
Performance in .net best practicesPerformance in .net best practices
Performance in .net best practicesCodecamp Romania
 
Oracle ADF Quick Handy Reference
Oracle ADF Quick Handy ReferenceOracle ADF Quick Handy Reference
Oracle ADF Quick Handy ReferenceDeepak Bhagat
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overviewbwullems
 

Similar to Formio - form definition & binding library for Java platform (20)

SAP Adobe forms
SAP Adobe formsSAP Adobe forms
SAP Adobe forms
 
C#Portfolio
C#PortfolioC#Portfolio
C#Portfolio
 
XPages - The Ties That Bind
XPages - The Ties That BindXPages - The Ties That Bind
XPages - The Ties That Bind
 
Cloud data loading
Cloud data loadingCloud data loading
Cloud data loading
 
Pdf template Invoice
Pdf template InvoicePdf template Invoice
Pdf template Invoice
 
Symfony Form Basics - OroMeetup #3 Cherkassy
Symfony Form Basics - OroMeetup #3 CherkassySymfony Form Basics - OroMeetup #3 Cherkassy
Symfony Form Basics - OroMeetup #3 Cherkassy
 
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8
 
Day 6.1 and_6.2__flat_files_and_service_api
Day 6.1 and_6.2__flat_files_and_service_apiDay 6.1 and_6.2__flat_files_and_service_api
Day 6.1 and_6.2__flat_files_and_service_api
 
Dbms fast track 2/3
Dbms fast track 2/3Dbms fast track 2/3
Dbms fast track 2/3
 
Sitecore xDB - Architecture and Configuration
Sitecore xDB - Architecture and ConfigurationSitecore xDB - Architecture and Configuration
Sitecore xDB - Architecture and Configuration
 
Using jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityUsing jQuery to Maximize Form Usability
Using jQuery to Maximize Form Usability
 
Angular Reactive Forms vs React Redux Form
Angular Reactive Forms vs React Redux Form Angular Reactive Forms vs React Redux Form
Angular Reactive Forms vs React Redux Form
 
Best practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata APIBest practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata API
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementing
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and OData
 
C# .NET Developer Portfolio
C# .NET Developer PortfolioC# .NET Developer Portfolio
C# .NET Developer Portfolio
 
Performance in .net best practices
Performance in .net best practicesPerformance in .net best practices
Performance in .net best practices
 
Oracle ADF Quick Handy Reference
Oracle ADF Quick Handy ReferenceOracle ADF Quick Handy Reference
Oracle ADF Quick Handy Reference
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overview
 
Django introduction
Django introductionDjango introduction
Django introduction
 

More from Etnetera

Pavel Ševčík: Microdata a rich snippets
Pavel Ševčík: Microdata a rich snippetsPavel Ševčík: Microdata a rich snippets
Pavel Ševčík: Microdata a rich snippetsEtnetera
 
Dalibor Pulkert: Mobile marketing 2015
Dalibor Pulkert: Mobile marketing 2015Dalibor Pulkert: Mobile marketing 2015
Dalibor Pulkert: Mobile marketing 2015Etnetera
 
Dalibor Pulkert: Mobilní Džungle
Dalibor Pulkert: Mobilní DžungleDalibor Pulkert: Mobilní Džungle
Dalibor Pulkert: Mobilní DžungleEtnetera
 
LinuxDays 2014: Social Engineering
LinuxDays 2014: Social EngineeringLinuxDays 2014: Social Engineering
LinuxDays 2014: Social EngineeringEtnetera
 
Jiří Štěpán: Nebojte se být osobní i u vás doma na webu
Jiří Štěpán: Nebojte se být osobní i u vás doma na webuJiří Štěpán: Nebojte se být osobní i u vás doma na webu
Jiří Štěpán: Nebojte se být osobní i u vás doma na webuEtnetera
 
Vlastimil Menčík: Scala from the Trenches
Vlastimil Menčík: Scala from the TrenchesVlastimil Menčík: Scala from the Trenches
Vlastimil Menčík: Scala from the TrenchesEtnetera
 
Zbyněk Hraše: Pokročilá personalizace na cestě k efektivitě
Zbyněk Hraše: Pokročilá personalizace na cestě k efektivitěZbyněk Hraše: Pokročilá personalizace na cestě k efektivitě
Zbyněk Hraše: Pokročilá personalizace na cestě k efektivitěEtnetera
 
Krev net a_slzy
Krev net a_slzyKrev net a_slzy
Krev net a_slzyEtnetera
 

More from Etnetera (8)

Pavel Ševčík: Microdata a rich snippets
Pavel Ševčík: Microdata a rich snippetsPavel Ševčík: Microdata a rich snippets
Pavel Ševčík: Microdata a rich snippets
 
Dalibor Pulkert: Mobile marketing 2015
Dalibor Pulkert: Mobile marketing 2015Dalibor Pulkert: Mobile marketing 2015
Dalibor Pulkert: Mobile marketing 2015
 
Dalibor Pulkert: Mobilní Džungle
Dalibor Pulkert: Mobilní DžungleDalibor Pulkert: Mobilní Džungle
Dalibor Pulkert: Mobilní Džungle
 
LinuxDays 2014: Social Engineering
LinuxDays 2014: Social EngineeringLinuxDays 2014: Social Engineering
LinuxDays 2014: Social Engineering
 
Jiří Štěpán: Nebojte se být osobní i u vás doma na webu
Jiří Štěpán: Nebojte se být osobní i u vás doma na webuJiří Štěpán: Nebojte se být osobní i u vás doma na webu
Jiří Štěpán: Nebojte se být osobní i u vás doma na webu
 
Vlastimil Menčík: Scala from the Trenches
Vlastimil Menčík: Scala from the TrenchesVlastimil Menčík: Scala from the Trenches
Vlastimil Menčík: Scala from the Trenches
 
Zbyněk Hraše: Pokročilá personalizace na cestě k efektivitě
Zbyněk Hraše: Pokročilá personalizace na cestě k efektivitěZbyněk Hraše: Pokročilá personalizace na cestě k efektivitě
Zbyněk Hraše: Pokročilá personalizace na cestě k efektivitě
 
Krev net a_slzy
Krev net a_slzyKrev net a_slzy
Krev net a_slzy
 

Recently uploaded

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Formio - form definition & binding library for Java platform

  • 2. Motivation ● I hate solving of repetitive problems where it is not necessary ● I want to solve them in a simple way ● I want to have an easy to use tool that i can use anywhere… Formio | Radek Beran 2
  • 3. Formio ● Form definition & binding framework ● Easy-to-use configurable handy tool ● Validation of form data (using bean validation) ● Support for file uploads, configurable max. request/file size ● Immutable, composable form definitions ● One simple entry point to API ● Easy integration to existing frameworks ● For environments with or without HttpServletRequest ● Simply unit testable forms Formio | Radek Beran 3
  • 4. Simple form example Formio | Radek Beran 4 private static final FormMapping<Person> personForm = Forms.automatic(Person.class, "person").build(/* Opt. config */); … FormData<Person> formData = new FormData<Person>( person, ValidationResult.empty); FormMapping<Person> filledForm = personForm.fill(formData); // push filledForm to template … … FormData<Person> formData = personForm.bind( new ServletRequestParams(request)); if (formData.isValid()) { // save person – formData.getData() … } else { // fill and show the form again … }
  • 5. Formio API ● Forms – entry point ● FormMapping, BasicFormMappingBuilder ● FormField, FieldProps for field definition ● ParamsProvider ● ValidationResult ● ConstraintViolationMessage ● Config ● Formatters, Formatter ● CollectionBuilders, CollectionBuilder, ● BeanExtractor ● Binder, Instantiator, ArgumentNameResolver ● BeanValidator ● PropertyMethodRegex ● UploadedFile Formio | Radek Beran 5
  • 6. Data binding ● Setter and construction method binding ● Immutable objects supported (Instantiator abstraction) ● Default or non-default constructors ● Static factory methods ● Collections and arrays ● Complex nested objects and lists of complex objects ● And arbitrary combination recursively ● Primitives (and their wrapper classes) supported everywhere ● String, Enums, BigDecimal, BigInteger, Date supported by default formatters Formio | Radek Beran 6
  • 7. Data for templates (1) ● Just push the filled form to the template ● Use its properties ● validationResult ● success ● fieldMessages ● globalMessages ● fields – Map<String, FormField> ● name – unique name/path of mapping ● labelKey – key for caption of nested complex object carried by mapping ● filledObject ● required ● nested – map with nested mappings ● list – list of nested mappings for complex objects if this is MappingType.LIST mapping Formio | Radek Beran 7
  • 8. Data for templates (2) ● Properties of FormField ● name – unique name/path of form field ● labelKey – key for localization of label (name without brackets) ● filledObject, filledObjects (for group of checkboxes, multiselect) ● required Formio | Radek Beran 8
  • 9. Form definition (1) Formio | Radek Beran 9 private static final FormMapping<RegDate> regDateMapping = Forms.basic(RegDate.class, "regDate").fields("month", "year") .build(); private static final FormMapping<Registration> registrationForm = Forms.basic(Registration.class, "registration") // whitelist of properties to bind .fields("attendanceReasons", "cv", "interests", "email") .nested(Forms.basic(Address.class, "contactAddress", Forms.factoryMethod(Address.class, "getInstance")) .fields("street", "city", "zipCode").build()) .nested(Forms.basic(Collegue.class, "collegues", null, MappingType.LIST) .fields("name", "email") .nested(regDateMapping) .build()) .build();
  • 10. Form definition (2) Formio | Radek Beran 10 Or equivalent automatic one ● Or equivalent automatic mapping private static final FormMapping<Registration> registrationForm = Forms.automatic(Registration.class, "registration") .nested(Forms.automatic(Address.class, "contactAddress", Forms.factoryMethod(Address.class, "getInstance")).build()) .build(); • Automatic mapping ● Introspects readable (and settable – via setters/instantiators) properties (incl. nested objects, list of nested objects) ● @Ignored on getters can be used ● Custom field definitions have precedence • Custom field definition Forms.<Date>field("birthDate", "text") .formatter(CUSTOM_DATE_FORMATTER).build(); Form definition (2)
  • 11. Validation ● Using bean validation API (JSR-303) ● ValidationResult ● ConstraintViolationMessage(s) for global and field constraints ● Fields (properties) and also mappings (whole complex objects) are validated ● Binding and validation errors ● Custom message bundle can be configured ● Default are properties for class of form data ● Fallback to ValidationMessages.properties with default messages ● Message bundle need not to be used ● Error messages carry possible translation and also unresolved key with arguments Formio | Radek Beran 11
  • 12. Other validation features ● Conditional validation ● Using bean validation groups ● Custom validators can be written ● NotEmpty ● RodneCislo ● Email ● CustomMultiFieldValidator, … ● Error, warning, info severity supported and recognized from payload of annotations ● Required flag automatically filled from Size, NotNull and derived constaints in default validator implementation ● For FormFields ● For mappings of complex objects Formio | Radek Beran 12
  • 13. Configuration ● Config object (Created using Forms.config()…build()) ● Immutable ● Default configuration available ● Custom configuration can be supplied ● Automatically propagated to nested mappings Formio | Radek Beran 13
  • 14. File uploads ● Using Apache FileUpload API ● Max. request size, size of one uploaded file, threshold for storing data in memory can be set via Formio API ● Global/field ConstraintViolationMessages created when limits are exceeded ● Automatic binding to UploadedFile, collections/arrays of UploadedFile(s) ● UploadedFileWrapper as a complex object for indexed lists of uploaded files (nested list mappings) Formio | Radek Beran 14
  • 15. What about AJAX? ● AJAX compatible ● You can expose server methods/API for update of state called from client ● On the server: Form definition can be filled with current data updated with sent data ● Filled nested mapping (inc. its validation result) can be sent back to client ● Cooperating AJAX framework can be used ● Twinstone TDI, jQuery, … Formio | Radek Beran 15
  • 16. Formio vs. Spring ● Formio Pros: ● Even easier to learn and use than forms in Spring ● Functional form processing, immutable/composable/reusable form definitions ● Immutable view/domain objects can be used (via constructors, static factory methods), arbitrarily nested – no need for custom Spring MVC WebArgumentResolver(s) or HttpMessageConverter(s) ● Minimum of dependencies (bean validation, fileupload) ● Message bundle for form data class with fallback to common ValidationMessages ● Not bound to any particular UI architecture like MVC, but fully usable in Spring MVC or other frameworks ● Automatic construction of form field names/paths, also for nested objects/lists ● Self-contained independent object representation of a form ● Cons: ● Spring is widely used and offers usable solution in Spring MVC Formio | Radek Beran 16
  • 17. Q & A? Formio | Radek Beran 17 Documentation: http://www.formio.net Demo: http://formio-demo.herokuapp.com/