Passing bean properties and action methods via <ui:param>
In the previous example, you saw how to exploit <ui:param>
for sending literal strings to a template or included page, but <ui:param>
can be used for more than this. Let's suppose that we have the following code of the bean, TemplatesBean
:
@Named @ViewScoped public class TemplatesBean implements Serializable { private String msgTopDefault=""; private String msgBottomDefault=""; private String msgCenterDefault="No center content ...press the below button!"; //getters and setters public void topAction(String msg){ this.msgTopDefault = msg; } public void bottomAction(String msg){ this.msgBottomDefault = msg; } public void centerAction(){ this.msgCenterDefault="This is default content"; } }
Further, we want to display the value of the msgCenterDefault
property in contentDefault.xhtml
. Of course, this is very easy to accomplish...