My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

.

.

.

.

.

.

.

.


[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians

Twitter

joi, 1 octombrie 2015

Access a component by using a reference to it

When you need to refer a component from another component, you can use the binding attribute, as below - amongst other things, this attribute is also used to bind the corresponding component to the current view, without the need of a bean (binding to a bean is not even recommended - Bauke Scholtz (aka BalusC) provide a comprehensive explanation on StackOverflow). This is useful to gain access to the state of a component from another component. Binding a component without a bean property will put the component in the EL scope:

<h:selectBooleanCheckbox id="nameId" label="name" binding="#{name}"/> Name
<h:inputText rendered="#{name.value}" a:placeholder="#{name.label}"/>

A great alternative to this approach consist in using the OmniFaces, ResolveComponent.  This component is capable of creating a reference for a component indicated by ID. Moreover, the reference is stored by default in the ʺfacelet scopeʺ but it can be alternatively stored in the request scope (this option can be set via the optional attribute, scope). The name attribute is required and it represents the name under which the referenced component will be made available to EL. The for attribute is also required and it represents the ID of the referenced component.

<h:selectBooleanCheckbox id="nameId" label="name"/> Name
<o:resolveComponent name="nameRef" for="nameId" />
<h:inputText rendered="#{nameRef.value}" a:placeholder = "#{nameRef.label}"/>

Check OmniFaces Showcase for more details.

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Visitors Starting 4 September 2015

Locations of Site Visitors