miercuri, 18 martie 2015

[OmniFaces utilities (2.0)] Get/set a Facelet attribute value


[OmniFaces utilities] The getFaceletAttribute() method returns the Facelet attribute value associated with the given name. This basically returns the value of the <ui:param> which is been declared inside the Facelet file, or is been passed into the Facelet file by e.g. an <ui:include>.
[OmniFaces utilities] The setFaceletAttribute() method sets the Facelet attribute value associated with the given name. This basically does the same as an <ui:param> which is been declared inside the Facelet file, or is been passed into the Facelet file by e.g. an <ui:include>.

Method - get Facelet attribute value

Method - set Facelet attribute value
Usage:

Suppose that we have this snippet:

<ui:composition template="template/layout.xhtml">              
 <ui:param name="playername" value="Rafael Nadal" />          
</ui:composition>

Now, we programmatically get the value of the playername like this:

import org.omnifaces.util.Faces;
...
// 'playernamevalue' will have the value 'Rafael Nadal'
String playernamevalue = Faces.getFaceletAttribute("playername");

Further, we programmatically set the value of the playername like this:

import org.omnifaces.util.Faces;
...
// 'playernamevalue' will have the value ' Roger Federer'
Faces.setFaceletAttribute("playername", "Roger Federer");

Niciun comentariu:

Trimiteți un comentariu