1. The form labels in the UI tab in STRUTS2 are divided into two types: the form label itself and the individual form label.
2.struts2 form labels include: form, TextField, password, radio, checkbox, CheckBoxList, select, Doubleselect, ComboBox, Optiontransferselect, Optgroup, Updownselect, textarea, hidden, file, label, submit, Token, head, DatePicker, Reset, Richtexteditor and so on.
The meanings of these tags are as follows:
Form: Output a form form.
TextField: Outputs a single-line text box.
Password: Outputs a password box.
Radio: Outputs a radio box.
CheckBox: Outputs a check box.
CheckBoxList: Outputs a list of check boxes.
Select: Outputs a drop-down box.
Doubleselect: Outputs a double-select drop-down box part, and the second drop-down box relies on the first one.
ComboBox: Outputs a part that can fill a text box from the contents of a drop-down box.
Optiontransferselect: Outputs an option to move the drop-down component, mainly two drop-down boxes and buttons to move the options between the two drop-down boxes.
Updownselect: Outputs a drop-down box control with the up and down buttons to move the drop-down box component elements.
TEXTAREA: Outputs a multiline text box.
Hidden: Outputs a hidden form field.
File: Outputs a selection box.
Submit: Outputs a submit (Submit) Form button.
Token: Outputs a hidden field to prevent the form from being submitted multiple times.
Head: Outputs the contents of the head portion of the theme, such as a reference to CSS and JavaScript.
DatePicker: Outputs a date selection part, using JavaScript and DOM.
Reset: Outputs a reset (reset) Form button.
Richtexteditor: Outputs a rich text editor.
3. For Struts2 form labels, most are dynamic to generate HTML code, so there are a lot of properties are universal, that is, most of the form labels have some properties, and then to introduce:
(1). The Name property and the Value property: The Name property and the Value property in the Struts2 form label are basically equivalent to the Name property and the Value property of the HTML component, but somewhat different: the Struts2 form label is dynamically generated when the HTML code is If the label does not have the Value property set, the value is obtained from the value stack by name, and the value obtained is set to the value of the generated HTML component.
(2). Other Common properties: In addition to the above Name property and the Value property, most Struts2 form labels have several common sets of properties:
~ ~ CSS-related properties:
CssClass: Specifies the class attribute of the generated HTML component.
CSSStyle: Specifies the style property of the generated HTML component, using the inline CSS property.
Csserrorclass: Specifies the CSS property that is referenced when validation fails.
Csserrorstyle: Specifies an inline CSS property that is referenced when validation fails.
~ ~ Properties related to triggering events:
Onblur: Specifies the event that is triggered when the generated HTML component loses focus.
OnChange: Specifies the event that is triggered when the content of the generated HTML component changes.
OnClick: Specifies the event that is triggered when the generated HTML component is clicked.
Ondbclick: Specifies the event that is triggered when the generated HTML component is double-clicked.
Onfocus: Specifies the event that is triggered when the generated HTML component obtains focus.
OnKeyDown: Specifies the event that is triggered when the keyboard is pressed in the generated HTML component.
onkeypress: Specifies the event that is triggered when the keyboard is pressed and released in the generated HTML component.
OnKeyUp: Specifies the event that is triggered when the keyboard is released in the generated HTML component.
OnMouseDown: Specifies the event that is triggered when the mouse is pressed in the generated HTML component.
OnMouseMove: Specifies the event that is triggered when the mouse moves in the generated HTML component.
onmouseout: Specifies the event that is triggered when the mouse moves out of the generated HTML component.
onmouseover: Specifies the event that is triggered when the mouse moves into the generated HTML component.
OnMouseUp: Specifies the event that is triggered when the mouse button is released.
Onselect: Specifies the event that is triggered when a zone is changed in the generated HTML component.
~ ~ Properties related to hover hints:
Jstooltipenabled: Whether JavaScript is allowed to generate hover hints.
ToolTip: The content of the hover hint.
Tootipdelay: The delay time, in milliseconds, that the hover hint appears.
ToolTipIcon: The URL path of the icon used to hover the hint.
~ ~ Other attributes from HTML:
AccessKey: Specifies the shortcut key, if set this property is X, press Alt+x can quickly locate to this generated HTML component.
Disabled: Whether the generated HTML component is available.
ID: Specifies the ID of the generated HTML component.
TabIndex: Specifies the index of the tab order of the generated HTML component.
Title: Specifies the header information for the generated HTML component.
~ ~ Properties related to hint text:
Label: The text to display in front of the HTML component.
Key: Same as label, it is used to display the text in front of the HTML component, but its contents are taken from internationalized information.
LabelPosition: The location of the label text display, you can select top or left.
~ ~ Properties related to templates and themes:
Template: Specifies the templates to use.
Templatedir: Specifies the directory where the template used is located.
Theme: Specifies the theme to use.
~ ~ Properties related to whether a required item is required:
Required: Specifies whether the HTML component of this build is required.
Requiredposition: Specifies the location where the message is displayed when the HTML component of this build is required, and you can select left or right.
4. The following is a description of some commonly used form tags:
(1). Form Label: The form label is the most specific of all UI components, and the other UI components must be placed within this tag to interact with the server data. This tag is also one of the most commonly used tags when writing server-side applications, and almost every interactive page can see its shadow.
The properties of the form tag are shown in the following table:
name |
is required |
Default Value |
type |
Description |
Action |
Whether |
The current action |
String |
Specify the name of the action to commit, and do not add the. Action suffix |
Namespace |
Whether |
The current namespace |
String |
Specifies the namespace to which the committed action belongs |
Method |
Whether |
Post |
String |
The method property of the HTML form, with a value of Get or post |
Enctype |
Whether |
No |
String |
When uploading a file, set to Multipart/form-data |
Focuselement |
Whether |
No |
String |
Specifies the ID of a FORM element that has focus when the page is loaded |
Validate |
Whether |
No |
Boolean |
Whether to perform client-side validation only if an XHTML theme or Ajax theme is used |
(2). Single-line text box TextField label: The single-line text box is the most common in form fields, and the TextField tag corresponds to the HTML <input type= "text"/>, which is used to generate a single line of text.
In addition to the various common general properties listed above, the TextField tag has several other properties:
name |
is required |
Default Value |
type |
Description |
MaxLength |
Whether |
No |
Integer |
Text input controls can enter the maximum length of a character |
ReadOnly |
Whether |
False |
Boolean |
When the value of this property is true, the user cannot enter text in the text control |
Size |
Whether |
No |
Integer |
Specify the visual dimensions of a text input control |
(3). Password tag: the password box, which is used to enter a single line of text, but is not displayed in clear text, but instead with a mask. The password label corresponds to <input type= "password"/>.
In addition to the various common general properties listed above, the password tag has several other properties:
name |
is required |
Default Value |
type |
Description |
MaxLength |
Whether |
No |
Integer |
The password input control can enter the maximum length of the character |
ReadOnly |
Whether |
False |
Boolean |
When the value of this property is true, the user cannot enter text in the password control |
Size |
Whether |
No |
Integer |
Specify the visual dimensions of the password input control |
Showpassword |
Whether |
False |
Boolean |
If the password is displayed, the password is displayed when True. Do not set this property to True unless you have special needs |
(4) Submit tag: Submit label output a Submit button. The submit tag is used with the form tag to provide asynchronous form submission, and the Submit tab can output the following three types of submit buttons:
Input: Equivalent to: <input type= "Submit"/>
Image: Equivalent to: <input type= "image"/>
Button: Equivalent to: <input type= "button"/>
In addition to the various common general properties listed above, the submit tag has several other properties:
name |
is required |
Default Value |
type |
Description |
Type |
Whether |
Input |
String |
The type of the commit button to use, valid values are: input, button, image |
Src |
Whether |
No |
String |
Sets the picture address for the submit button of the image type, which is not valid for the submit button of input and button types |
Action |
Whether |
No |
String |
Specifies the action to process the submit request |
Method |
Whether |
No |
String |
Specifies the method that handles the action of the submit request |
(5). Select tag: Used to output an HTML list box, equivalent to:<select><option></option></select>.
In addition to the various common common properties listed above, the SELECT tag has several other properties:
name |
is required |
Default Value |
type |
Description |
list |
is a collection of |
none |
Collection, MAP, enumeration, Iterator, array |
to iterate over. Use the elements in the collection to set the options, if the list's properties are map, then the map key becomes the option's Value,map value becomes the content of the option |
listKey |
no | td> no
String |
Specifies which property in the collection object to use as an option value |
listvalue |
no |
none |
String |
specifies which property in the collection object is the content of the option |
headerkey |
no |
none |
String |
Sets the value that is committed when the user selects the header option, and cannot set a null value for the property if the property is used /td> |
headervalue |
no |
none |
String |
Show Header options on page |
emptyoption |
no |
false |
Boolean |
whether to add an empty option after the header option |
Multiple Size |
No No |
False None |
P>boolean Integer |
Whether multiple selections Displays the number of options |
(6). Optgroup Tags: used as a sub-label for Select to generate a set of options. A drop-down list box can contain multiple option groups, and you can use multiple <s:optgroup> tags in a <s:select> tag.
The main attributes of the optgroup tag are:
~list: A collection that is used to generate drop-down box options.
~listkey: The Value property of the generated option.
~listvalue: The generated option displays the text.
~label: The text used to generate the option group.
(7). Radio Tags: used to generate a series of radio boxes, the user can only select one of them. The STRUTS2 radio tag corresponds to the HTML <input type= "Radio"/>.
In addition to the various common general properties listed above, the radio tag has several other properties:
~list: A collection that is used to generate a radio box, which must be configured.
~listkey: The Value property of the generated radio.
~listvalue: The text that is displayed after the generated radio.
These three attributes must be used in conjunction with the List property to specify from which collection the element is obtained, and the Listkey property specifies which property of the element to use as the generated <input type= "Radio"/> The Value property after the element is obtained. The ListValue property specifies the text to be read to the user after the generated <input type= "Radio"/>.
(8). CheckBoxList Tags: check box groups are used to generate a series of check boxes, the user can select 0 to more of them, Struts2 's CheckBoxList label is used to generate a set of <input type= "check"/>.
This tag is very similar to the properties of the radio tag described above, except for the common general properties listed above, whose main properties are:
~list: The collection used to generate check boxes.
~listkey: The Value property of the generated checkbox.
~listvalue: The text that appears after the generated checkbox.
The three properties are used in the same way as the three properties of the radio tag.
(9). Doubleselect tag: The doubleselect tag is an extension of the Select label, which can be used when there are a number of options to choose from for the user. For example, if you need to select a country first, select a province, select a city, and more, you can use the Doubleselect label. Where and select are different, the first drop-down box for the doubleselect tag is a grouped list that can be specified by the Lists property. By using methods such as JavaScript, the second drop-down box will vary depending on the selection of the first drop-down box.
The properties of the Doubleselect tag are:
Properties |
Data Type |
whether you must |
Description |
List |
Collection |
Whether |
The list of content, which can be an expression |
ListKey |
String |
Whether |
The expression for the key of the list |
ListValue |
String |
Whether |
Expression for list value |
Doublelist |
Collection |
Whether |
An expression used to evaluate all list list items |
Doublelistkey |
String |
Whether |
The expression for the key of the list |
Doublelistvalue |
String |
Whether |
Expression for list value |
Doublename |
String |
Whether |
The name of the form used to map to the second drop-down box |
Doublevalue |
Object |
Whether |
The value of the form element for the second drop-down box |
Headerkey |
String |
Whether |
If you select the header to submit only the first drop-down box |
Headervalue |
String |
Whether |
The contents of the header option that the user sees, only the first applicable |
Emptyoption |
Boolean |
Whether |
Whether a space is placed between the table and the content, the first drop-down box |
Multiple |
Boolean |
Whether |
Set to True to allow the user to select multiple values |
Size |
String |
Whether |
Set the length of the drop-down box |
(Ten). ComboBox Label: Struts2 's ComboBox label is used to generate a text box and a drop-down box, the drop-down box appears below the text box, only the input value of the text box is submitted at the end of the submission, and the drop-down box is used when its options change. That is, when the onchange event is triggered, the value of its selected item is assigned to the text box. The properties of the ComboBox are from the text box and drop-down boxes: ~ Properties from text box: maxlength: The maximum text length that can be accommodated in a single-line text box. Size: The length of the single-line text box itself. ReadOnly: Whether a single-line text box is read-only.
~ Properties from the drop-down box: List: The collection used to generate the drop-down box. ListKey: The Value property of the generated option. ListValue: The generated option displays the text.
(one). CheckBox Label: Used to output an HTML check box, equivalent to the HTML code: <input type= "checkbox"/>.
Updownselect tag: Used to create a drop-down box that allows you to move the option up or down freely. The usage of the build option, like the Struts2 Select Label, is set by the list, ListKey, ListValue three properties.
name |
must be |
Default Value |
type |
Description |
List |
Is |
No |
Collection, MAP, enumeration, Iterator, array |
To iterate over the collection, use the elements in the collection to set each option, and if the list's properties are map, then the Value,map value of the map's key becomes the option's content |
ListKey |
Whether |
No |
String |
Specify which property in the collection object as the value of the option |
ListValue |
Whether |
No |
String |
Specifies which property in the collection object is the content of the option |
Headerkey |
Whether |
No |
String |
Sets the value that is committed when the user selects the header option, and cannot set a null value for the property if the property is used |
Headervalue |
Whether |
No |
String |
The contents of the header option displayed in the page |
Emptyoption |
Whether |
False |
Boolean |
Whether to add an empty option after the header option |
Multiple |
Whether |
False |
Boolean |
Whether to select multiple |
Size |
Whether |
No |
Integer |
Number of options displayed |
Moveuplabel |
Whether |
|
String |
Set the text on the move button up |
Movedownlabel |
Whether |
|
String |
Set the text on the move button down |
Selectalllabel |
Whether |
|
String |
Set the text on the Select All button |
Allowmoveup |
Whether |
No |
Boolean |
Set whether to use the Move Up button |
Allowmovedown |
Whether |
No |
Boolean |
Set whether to use the Move Down button |
Allowselectall |
Whether |
No |
Boolean |
Set whether to use the all selection button |
Here are just a few properties to know about the top and bottom actions: ~allowmoveup: Whether the Move Up button is displayed, the default is display. ~allowmovedown: Displays the Move Down button, which is displayed by default. ~allowselectall: Displays the Select All button, which is displayed by default. ~moveuplabel: The text that is displayed by the Move Up button. ~movedownlabel: The text that is displayed by the Move Down button. ~selectalllabel: The text displayed by the Select All button.
Optiontransferselect Tags: used to generate two drop-down boxes, these two drop-down boxes left and right, there are buttons to control, the option to move between two drop-down boxes, under each drop-down box there are buttons, you can move up and down like the Updownselect Label control options.
The main attributes of the optiontransferselect tag can be divided into 4 groups:
~ ~ Control the Left drop-down box name and data source:
Name: The Name property of the left drop-down box.
List: The collection used to generate the left drop-down box.
ListKey: Generates the option's Value property for the left drop-down box.
ListValue: Generates the text for the options displayed on the left drop-down box.
Headerkey: In the left drop-down box all options are added with an additional option as their caption, and Headerky is set to the title's Value property.
Headervalue: In the left drop-down box all options are added with an additional option as their caption, Headervalue is set to the caption's display text.
~ ~ Control the right drop-down box name and data source:
Doublename: The Name property of the right drop-down box.
Doublelist: The collection used to generate a right drop-down box.
Doublelistkey: Generates the option's Value property for the right drop-down box.
Doublelistvalue: Generates the text for the options displayed on the right drop-down box.
Doubleheaderkey: After all options in the right drop-down box are added with an additional option as its caption, Headerky sets the title's Value property.
Doubleheadervalue: After all options in the right drop-down box are added with an additional option as its caption, Headervalue is set to the caption's display text.
~ ~ Control the left and right move buttons between two drop-down boxes:
Allowaddalltoleft: Specifies whether the move all to left button appears.
Allowaddtoleft: Specifies whether the move to left button appears.
Allowaddtoright: Specifies whether the move to right button appears.
Allowaddalltoright: Specifies whether the move all to right button appears.
Addalltoleftlabel: Specifies the text that appears on the move all to left button.
Addalltorightlabel: Specifies the text that appears on the move all to right button.
Addtoleftlabel: Specifies the text on the move to left button.
Addtorightlabel: Specifies the text on the move to right button.
~ ~ Control two drop-down boxes to move up and down buttons respectively.
Allowupdownonleft: Specifies whether the left drop-down box has a move-up button.
Allowupdownonright: Specifies whether the up and down buttons appear on the right drop-down box.
Leftuplabel: Specifies the text that appears on the left drop-down box on the move-up button.
Leftdownlabel: Specifies the text that appears on the drop-down button in the left-hand drop-down box.
Rightuplabel: Specifies the text that appears on the move-up button on the right drop-down box.
Rightdownlabel: Specifies the text that appears on the drop-down button on the right-hand drop-down box.
Allowselectall: Specifies whether the two drop-down boxes show All buttons selected.
Introduction to the form labels for UI tags in Struts2