1

I am trying to build a problem given in a book.

The author mentions:

Sometimes, the JSTL <c:set> tag can solve issues that the JSF <f:param> tag can't. Probably, you know that we can pass parameters to the <ui:include> tag using the <f:param> tag, as shown in the following code:

<ui:include src="rafa.xhtml">
  <f:param name="rafa" value="Rafael Nadal Page"/>,
</ui:include>

Well, this approach triggers an issue! Now, the Rafael Nadal Page value will be available in the included page through EL, #{rafa}, but will not be available in the constructor of the managed bean of the included page!

It is time for the <c:set> tag to save the situation; therefore, the code will be changed to the following:

<ui:include src="rafa.xhtml">
  <c:set var="rafa" value="Rafael Nadal Page" scope="request"/>,
</ui:include>

When I use <c:set>, it works perfectly with its availibility as #{rafa},

while in case of <f:param>, it gives me an exception like this: enter image description here while the author mentions that the value will be available in the included page through EL, #{rafa}. I am not talking about the value in the bean's constructor, but for the included page. What exactly does he mean?

Farhan stands with Palestine
  • 13,890
  • 13
  • 58
  • 105

1 Answers1

1

That's just an unfortunate typo in the book. It really should have been <ui:param> instead of <f:param>.

<ui:include src="rafa.xhtml">
  <ui:param name="rafa" value="Rafael Nadal Page"/>,
</ui:include>

The <f:param> is intented to add HTTP request parameters to outcome of <h:xxxLink> and <h:xxxButton> components, and to parameterize the message format in <h:outputFormat>. The <ui:param> is intented to pass Facelet context parameters to <ui:include>, <ui:decorate> and <ui:define>.

I have notified the author about this.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555