Ch11: Thymeleaf Views Flashcards

1
Q

Define template

A

Provides general structure for a web page. Editing a template modifies all pages using the template.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A template represents a ____ in MVC

A

view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What information does the following line in a thymeleaf template provide?

A

xmlns provides the syntax to IDE that will be used by the template

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In a method that sends data to a template:

A ___ parameter is an object that stores the variable names and values passed into a template

A

model

Ex: public String methodName(Model model) {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In a method that sends data to a template:

____ statements add data to the model object

A

addAttribute

Ex: model.addAttribute(“variableName”, variableValue);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In a method that sends data to a template:

___ contains the path and file name for the desired template

A

return string

Ex: dogs.html in animals subfolder = “animals/dogs”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Thymeleaf commands appear as ____ in standard HTML tags

A

attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The data available to a template includes variables and values stored in the ____ objects, and are accessible with by syntax ____.

A

model, ${variableName}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the use of default text in a template

A

Help visualize planned layout for the webpage while under development. It improves readability, and indicates what data will appear in each section

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is th used for in the following statement:

A

prefix indicates beginning of a thymeleaf command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the following code achieve in thymeleaf?

th:each = “variableName : ${collectionName}”

A

Iterates through a collection. Repeats tag that contains th:each statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

${ } This syntax indicates what?

A

Data provided by controller/model object that is referenced by the template.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

th:block is a Thymeleaf _____ which allows application of a Thymeleaf attribute to a block of code

A

element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Does th:block get rendered in the view?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

List some benefits of using th:block

A
  • helps clarify HTML code by placing related Thymeleaf attributes into separate tags
  • can group together tags you want to be displayed in a given order (ex. heading/paragraph pair)
  • can set up nested loops
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define fragments

A

Blocks of HTML elements we want to use across multiple templates

17
Q

Bootstrap

A

Commonly used style library. Allows quick application of CSS style rules with class selectors

18
Q

Write the syntax for including a conditional in Thymeleaf

A

th: if = “${condition}”

- Condition is boolean variable from controller or expression evaluating to a boolean

19
Q

When is the following attribute considered truthy?

th:if = “${condition}”

A
  • If condition is boolean true
  • If condition is nonzero # or char
  • If condition is string that isn’t “false”, “off”, or “no”
  • If condition is data type other than boolean, number, character, or String
20
Q

Function of th:unless statement?

A

element is created if condition evaluates to false

21
Q

Logical AND = ____
Logical OR = ____
Logical NOT = ____, ____

A

and
or
!, not

22
Q

What are fragments?

A

blocks of HTML elements we want to use across multiple templates

23
Q

Use of th:remove attribute?

A

Selectively remove elements. ex: discard wrapper tag, but not its children

24
Q

Use of th:replace attribute?

A

Inject fragment, replacing tag where this attribute is used

25
Q

Describe function of following code:

<li>

A

Value of event variable will be inserted between list closing and opening tag in HTML by thymeleaf

26
Q

What is the HTML element used for?

A

Indicates navigational links will be included in this section of the webpage

27
Q

When can you leave off the action attribute in a form tag?

A

When you want the form to submit to the same route that the form was rendered at

28
Q

Declare a ____ object to declare data that needs to be passed into the template

A

Model

29
Q

Bootstrap

A

Commonly used style library allowing users to apply CSS style rules with class selectors

30
Q

Describe difference between href and src

A

href specifies the location (URL) of a resource, that an anchor element points to, or the location of a linked resource, like a stylesheet. src attribute is used to embed a resource - usually URLs - into a document, think embedded images ( <img></img> ) and tags.

31
Q

References to static resources are typically included in the ____ of the web page

A

Head

32
Q

Define CDN

A

Content delivery network. Linking to a CDN allows you to take advantage of a publicly available library without downloading the entire codebase. (ex: can incorporate Bootstrap in this manner)

33
Q

Bootstrap uses a ___ system of elements labelled ____ and ____ that respond dynamically to the state of a web page

A

grid, containers, rows