Create an input form with Oracle JET
![Oracle website](/integrationapplicationtalents/sites/hot_iatalents/files/styles/keyvisual_content_xlarge_1488x700/public/2018-12/shutterstock_702396340.jpg?h=51a72048&itok=dGI0QkcD)
After creating my first JET-application I want to know more of Oracle JET.
I want to create a web form that saves the input in the database through a REST-service.
First let’s create the table for the input of the data.
![Table input data](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%201%20blog%20input%20form.jpg?itok=KslOFjtK)
The data for this table must be inserted through a REST-service. So I create an ADF web application with an entity-object for the table I just mentioned.
This entity-object will be then exposed as a REST-service.
![REST-service](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%202%20blog%20input%20form.jpg?itok=3WnYjlX8)
So now it’s time for creating the input form. This form uses the default ALTA-CSS style.
![ALTA-CSS](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%203%20blog%20input%20form.jpg?itok=TdIEokVK)
I chose some special inputfields which I will use in the input form.
These are the inputfields:
- Title and Nationality are “Single select”
- Birthdate is an “InputDate” field
- Zipcode is “Validation” field
- Gender is a “Radioset”
Let’s look a bit closer to these special inputfields:
Single select:
This is the code for the single select:
![code for single select](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%204%20blog%20input%20form.jpg?itok=r5CAwbAI)
The first option in the option value list is the default value shown in the input form. Don’t forget to initialise the single select item:
self.SelectTitleValue("MR");
Birthdate:
This is the code for the inputdate:
![Code for the inputdate](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%205%20blog%20input%20form.jpg?itok=L0mtaXcS)
In the object datePicker there is the possibility to specify a yearrange. Default this is plus 10 years and minus 10 years. This is not enough for a birthdate. So you can specify your own yearrange as you can see in the next image. See for more information the API documentation: datePicker.
![datePicker](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%206%20blog%20input%20form.jpg?itok=qSRl1D3e)
To set a default date for the inputdate field, you can use the following code:
self.birthdatedateTimeValue = ko.observable(oj.IntlConverterUtils.dateToLocalIso(new Date(2015, 1, 1)));
Zipcode:
This is the code for the validation field. The zipcode what the user entered must be validated.
![Zipcode](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%207%20blog%20input%20form.jpg?itok=AtS9elWR)
Placeholder is the hinttext for the user as you can see in the screenprint of the input form. For validating the zipcode I use a regular expression. When the input doesn’t match the regular expression the messageDetail is shown:
![Zipcode error](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%208%20blog%20input%20form.jpg?itok=FMGC607_)
Gender:
This is the code for the radioset.
![Code for radioset](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%209%20blog%20input%20form.jpg?itok=oBkxmMhr)
The first input item is the default item of the radioset. Also don’t forget to initialise this item:
self.radiosetGenderValue("MALE");
At the end there are two buttons; Save and Clear. When the Save button is pressed the inputdata will be send to the database using the REST-service.
When the button Clear is pressed, all inputfields will be cleared and the default values are set.
So let’s enter a person:
![Enter a person](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%2010%20blog%20input%20form.jpg?itok=zZb7RK6I)
Below the buttons there is a textfield. In this textfield I show the user if the data succesfull is saved. Otherwise the user see’s an error.
When the button Save is pressed the user see’s a message that the input is saved.
After that let’s check the database:
![Check database](/integrationapplicationtalents/sites/hot_iatalents/files/styles/content_image_medium_max/public/2018-12/Afbeelding%2011%20blog%20input%20form.jpg?itok=U-7Cvm8r)
This is a simple example for creating an input form with Oracle JET. With the use of the API documentation there are a lot of possibilities for the different type of inputfields.
Overzicht blogs
Geen reacties
Geef jouw mening
Reactie plaatsenReactie toevoegen