Sebi
Sebi

Reputation: 2584

Define an alias for a controller property in the view

I have a PersonController that has the property person. The person itself has the properties firstName, lastName, etc.

When I access them in the view i always have to write:

<h:outputText value="#{personController.person.firstName}"/>
[...]

To simplify i created an "alias" via

<c:set var="p" value="#{personController.person}"/>

and now I can write

<h:outputText value="#{p.firstName}"/>

Here is written that you should avoid c:set if possible.

Question 1: Why should I avoid it?

Question 2: What is the alternative for my "problem"?

Upvotes: 2

Views: 231

Answers (1)

BalusC
BalusC

Reputation: 1109570

There the <ui:param> can be used for.

<ui:param name="p" value="#{personController.person}" />

See also:

Upvotes: 2

Related Questions