I finally learned how to use the label.

xiaoxiao2021-03-06  13

The drop-down box is a particularly common HTML component. It is also a more complex TAG in Struts. If you want to realize how MV separation learn how to use tags, it is very important, of course, if it is a high person, there is no problem with yourself. ^ _ ^ On a page of recently used to pull the box, I want to take this opportunity to learn how to use the label to get MV to be separated, so determined that you must put the dunk box in a bean , Then call the bean by tag, then use to call the collection of the LabelValueBean in the bean. It is really easy to use the bean that is specially designed for Selects under this Struts, but it feels that it is easy to use this collection bean during the discussion of colleagues. It is a problem under the framework, that is, poor genericity. What is his relative, I think there is nothing to say is totally common, so I still feel that I will help me to achieve the drop-down box: 1, XXXSELECTOR class, this class It is used to read the down-pull frame from the database, and encapsulate the Vector Collection of LabelValueBean 2, XXXBean class, this class is the bean class to call on the page, I have two drop-down boxes, set two properties, and Corresponding to two getter methods, I don't think it is necessary because it is set by the XXXSELECTOR class. 3, page first declare a bean reference, 4, then refer to this bean on the drop-down box tab, and set the corresponding attribute . I did this: Supplement: This html: optionscollection tag is set only two Item, a bean ID, and the other is an attribute XXXIDS in this bean because it is the benefit of labelvaluebean, or if your collection is defined by Label and Value, then the effect and LabelValueBean is The same, in this label, the default value of Value is 'value', and the default value of Label is 'label'.

Ok, this will be perfectly separated by MV. It looks like a short a few lines of code, but I really gave me confused. Let me write myself in this study process, a total of everyone sharing: I didn't use the OptionsCollection this label, but the Options tag, because I used it, but I have a little indecent, there will be many The Java code is written directly on the page, especially when the drop-down box is very uncomfortable. It's really because I haven't done it last time, this time I am determined to be fine.

This tag differs from the tag in that it makes more consistent use of the name and property attributes, and allows the collection to be more easily obtained from the enclosing form bean above this sentence is in the struts official website. UserGuide is abstracted, this is saying the essence difference between Options and OptionsCollection. Just in OptionsCollection can use the BEAN better package pull-down frame, in my implementation, use a bean using a bean, encapsulates the collection beans that need to be used by the plurality of drop-down boxes, and then get the corresponding drop-down content by setting the property Property. set. Attribute NameDescriptionfilterSet to false if you do NOT want the option labels filtered for sensitive characters in HTML. By default, such values ​​are filtered. [RT Expr] labelThe property of the bean within the collection which represents the label to be rendered for each option. Defaults to "label". [RT Expr] nameThe attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. [RT Expr] propertyThe property of the form bean, or the bean specified by the name attribute, that will return the collection of objects to be rendered for these options. [RT Expr] styleCSS styles to be applied to this HTML element. [RT Expr] styleClassCSS stylesheet class to be applied to this HTML element (renders a "class" attribute). [RT Expr] valueThe property of the bean within the collection which represents the value to be rendered for each option. Defaults to "va "[RT EXPR] is also a little, and the same starters like me, must have something to go to http://struts.apache.org/userguide/ to see the above document, I can help us solve it. Many confused, I didn't think much before, I feel that there is nothing necessary, but I feel very necessary by this time.

转载请注明原文地址:https://www.9cbs.com/read-49919.html

New Post(0)