Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Foss 2024 2 Final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
정 재윤
Foss 2024 2 Final
Commits
744ac558
Commit
744ac558
authored
7 months ago
by
정 재윤
Browse files
Options
Downloads
Patches
Plain Diff
Email 형태 및 기능 수정
formlayout 형태 수정
parent
12ae86ef
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/example/EmailField.java
+49
-0
49 additions, 0 deletions
src/main/java/org/example/EmailField.java
src/main/java/org/example/GridApp.java
+18
-16
18 additions, 16 deletions
src/main/java/org/example/GridApp.java
with
67 additions
and
16 deletions
src/main/java/org/example/EmailField.java
0 → 100644
+
49
−
0
View file @
744ac558
package
org.example
;
import
com.vaadin.flow.component.customfield.CustomField
;
import
com.vaadin.flow.component.orderedlayout.HorizontalLayout
;
import
com.vaadin.flow.component.select.Select
;
import
com.vaadin.flow.component.textfield.TextField
;
import
jakarta.validation.constraints.Email
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
EmailField
extends
CustomField
<
String
>
{
TextField
emailtext
=
new
TextField
();
String
[]
emailArray
=
{
"@gmail.com"
,
"@naver.com"
,
"@daum.net"
,
"@ajou.ac.kr"
};
private
final
List
<
String
>
emailList
=
Arrays
.
stream
(
emailArray
).
toList
();
private
final
Select
<
String
>
emailselect
=
new
Select
<>();
public
EmailField
()
{
HorizontalLayout
layout
=
new
HorizontalLayout
();
layout
.
setPadding
(
false
);
layout
.
setSpacing
(
false
);
layout
.
getThemeList
().
add
(
"spacing-xs"
);
layout
.
add
(
emailtext
);
emailselect
.
setItems
(
emailList
);
emailselect
.
setPlaceholder
(
"@example.com"
);
layout
.
add
(
emailselect
);
add
(
layout
);
}
@Override
protected
String
generateModelValue
(){
String
emailValue
=
emailtext
.
getValue
();
String
emailkind
=
emailselect
.
getValue
();
return
emailValue
+
emailkind
;
}
@Override
protected
void
setPresentationValue
(
String
expiration
){}
@Override
public
void
clear
(){
emailtext
.
clear
();
emailselect
.
clear
();
}
}
This diff is collapsed.
Click to expand it.
src/main/java/org/example/GridApp.java
+
18
−
16
View file @
744ac558
...
...
@@ -14,6 +14,7 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import
com.vaadin.flow.component.orderedlayout.VerticalLayout
;
import
com.vaadin.flow.component.select.Select
;
import
com.vaadin.flow.component.textfield.TextField
;
import
com.vaadin.flow.dom.Style
;
import
com.vaadin.flow.router.Route
;
import
java.util.ArrayList
;
...
...
@@ -36,40 +37,41 @@ public class GridApp extends Div {
private
void
setInfoForm
()
{
TextField
name
=
new
TextField
(
"Name"
);
TextField
name
=
new
TextField
();
//TextField age = new TextField("Age");
Select
<
Integer
>
age
=
new
Select
<>();
TextField
email
=
new
TextField
(
"Email"
);
TextField
school
=
new
TextField
(
"School"
);
//TextField email = new TextField();
TextField
school
=
new
TextField
();
final
List
<
Integer
>
AGES
=
IntStream
.
range
(
0
,
100
).
boxed
().
collect
(
Collectors
.
toList
());
age
.
setItems
(
AGES
);
age
.
setLabel
(
"Age"
);
age
.
setItems
(
AGES
);
EmailField
emailField
=
new
EmailField
();
FormLayout
formLayout
=
new
FormLayout
();
formLayout
.
add
(
name
,
age
,
email
,
school
);
formLayout
.
addFormItem
(
name
,
"Name"
);
formLayout
.
addFormItem
(
age
,
"Age"
);
formLayout
.
addFormItem
(
emailField
,
"Email"
).
getElement
().
setAttribute
(
"colspan"
,
"2"
);
formLayout
.
addFormItem
(
school
,
"School"
);
formLayout
.
setWidth
(
"80%"
);
//formLayout.getStyle().setAlignItems(Style.AlignItems.CENTER);
formLayout
.
setResponsiveSteps
(
// Use one column by default
new
ResponsiveStep
(
"0"
,
1
),
// Use two columns, if layout's width exceeds 500px
new
ResponsiveStep
(
"500px"
,
2
));
formLayout
.
setColspan
(
email
,
2
);
Button
button
=
new
Button
(
"click"
);
button
.
addClickListener
(
e
->
{
Optional
<
Person
>
person
=
DataService
.
savePerson
(
new
Person
(
name
.
getValue
(),
Integer
.
parseInt
(
age
.
getValue
().
toString
()),
email
.
get
Value
(),
school
.
getValue
()));
email
Field
.
generateModel
Value
(),
school
.
getValue
()));
if
(
person
.
isPresent
()){
people
.
add
(
person
.
get
());
this
.
refreshGrid
();
}
name
.
clear
();
age
.
clear
();
email
.
clear
();
school
.
clear
();
name
.
clear
();
age
.
clear
();
email
Field
.
clear
();
school
.
clear
();
});
button
.
addClickShortcut
(
Key
.
ENTER
);
VerticalLayout
layout
=
new
VerticalLayout
(
formLayout
,
button
);
layout
.
setPadding
(
true
);
layout
.
setWidth
(
"80%"
);
layout
.
getStyle
().
set
(
"margin"
,
"auto"
);
layout
.
getStyle
().
set
(
"display"
,
"flex"
);
layout
.
getStyle
().
set
(
"justify-content"
,
"center"
);
layout
.
getStyle
().
set
(
"align-items"
,
"center"
);
//layout.setPadding(true);
formLayout
.
getStyle
().
set
(
"margin-left"
,
"15%"
);
layout
.
setAlignItems
(
FlexComponent
.
Alignment
.
CENTER
);
add
(
layout
);
}
private
void
setGridComponent
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment