1

I want to parse the URL

title.xhtml?id=1

My code within "title.xhtml" should look like

...
<h:outputText value="#{titles.getTitle(${param.id}).id}"></h:outputText>
...

But unfortunatelly this does not work, since nested "#" and "$" is not accepted. So my question is: Can I use an URL parameter and hand it over to a bean function without to store it separately within the bean?

Alex004
  • 785
  • 2
  • 10
  • 25

1 Answers1

1

That's invalid EL syntax. You can't and don't need to nest EL expressions in any way. Even nesting ${} is invalid. The only difference between #{} and ${} is that the #{} can perform a set operation as well (where applicable), while the ${} can do only a get operation.

This is valid EL syntax:

<h:outputText value="#{titles.getTitle(param.id).id}" />

Note that #{param.id} is fully legal JSF EL syntax. To avoid future confusions, it would be a good idea to make sure that you never use the old JSP EL syntax ${} in JSF anymore. See also Difference between JSP EL, JSF EL and Unified EL.

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