Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

pdf / 6-jsf

.pdf
Скачиваний:
41
Добавлен:
06.06.2015
Размер:
354.87 Кб
Скачать

Core Tags

view, subview

attribute

Adds configurable attributes to a parent component

facet

Signifies a nested component that has a special relationship to its enclosing tag

param

Substitutes parameters into a MessageFormat instance and adds query string name-value pairs to a URL

Validator tags

validateDoubleRange, validateLength, validateLongRange, validator

selectItem, selectItems

verbatim

Generates a UIOutput component that gets its content from the body of this tag

UI Component Tag Attributes

id: Uniquely identifies the component.

immediate

rendered

style: Specifies a Cascading Style Sheet (CSS) style for the tag.

styleClass: Specifies a CSS stylesheet class that contains definitions of the styles.

value: Identifies an external data source and binds the component’s value to it.

binding: Identifies a bean property and binds the component instance to it.

UIInput component tags

converter

converterMessage

dir (text direction)

label

lang

required

requiredMessage

validator

validatorMessage

valueChangeListener

Data-Bound Table Component

<h:dataTable id="items" footerClass="..." headerClass="..." rowClasses="..." styleClass="..." summary="#{bundle.ShoppingCart}" value="#{cart.items}" var="item">

<h:column>

<f:facet name="header">

<h:outputText value="#{bundle.ItemQuantity}" /> </f:facet>

<h:inputText id="quantity" size="4" value="#{item.quantity}" /> </h:column>

<h:column>

<f:facet name="header">

<h:outputText value="#{bundle.ItemTitle}"/> </f:facet>

<h:commandLink action="#{showcart.details}"> <h:outputText value="#{item.item.title}"/>

</h:commandLink>

</h:column>

</h:dataTable>

Data-Bound Table Component

A list of beans

An array of beans

A single bean

javax.faces.model.DataModel

java.sql.ResultSet

javax.servlet.jsp.jstl.sql.ResultSet

javax.sql.RowSet

javax.faces.convert

BigDecimalConverter

BigIntegerConverter

BooleanConverter

ByteConverter

CharacterConverter

DateTimeConverter

DoubleConverter

FloatConverter

IntegerConverter

LongConverter

NumberConverter

ShortConverter

Convertor

String getAsString(FacesContext ctx, UIComponent c, Object val) throws ConverterException

Object getAsObject(FacesContext ctx, UIComponent c, String newVal) throws ConverterException

Использование

Связать с нужным свойством бина

Integer age = 0;

public Integer getAge(){ return age;}

public void setAge(Integer age) {this.age = age;}

Указать конвертор

<h:inputText converter="javax.faces.convert.IntegerConverter" />

Использовать вложенный тэг

<h:inputText value="#{LoginBean.Age}" /> <f:converter converterId="Integer" />

</h:inputText>

<h:outputText value="#{cashier.shipDate}"> <f:convertDateTime pattern="EEEEEEEE, MMM dd, yyyy" />

</h:outputText>

Standard Validators

validateDoubleRange

validateLength

validateLongRange

Custom:

Implement a backing bean method that performs the validation.

Provide an implementation of the Validator interface to perform the validation + Custom Tag (ValidatorELTag). void validate(FacesContext context, UIComponent component, Object toValidate)

<h:inputText id="quantity" size="4" value="#{item.quantity}" > <f:validateLongRange minimum="#{setting.min}"/>

</h:inputText>

<h:message for="quantity"/>

Implicit Objects

applicationScope

cookie

facesContext

header

headerValues

initParam

param

paramValues

requestScope

sessionScope

view

Backing Bean

Свойства

A component value

A component instance

A Converter implementation

A Listener implementation

A Validator implementation

Методы

Handle Navigation: public Object nav()

Handle an Action Event:

public void aaa(ActionEvent event)

Perform Validation:

public void vvv(FacesContext ct, UIComponent c, Object val)

Value-Change Event:

public void aaa(ValueChangedEvent e)

Соседние файлы в папке pdf