jsf includeable fragment with parameter: how do I make Intellij know the object type?
I'm working on a JSF project, using .xhtml files.
Now, I extracted a part of one .xhtml file into an includeable fragment, specifying the object as parameter. The include statement looks similar to this:
<ui:include src="/fragments/my_new_fragment.xhtml">
<ui:param name="contactPerson" value="#{contactPersonBean.currentContactPerson}"/>
</ui:include>
and in the new fragment I use the passed object like this:
<h:outputText value="#{contactPerson.firstName}"/>
This works perfectly at runtime, but the extracted fragment is cumbersome to edit, because Intellij does not know what object type "contactPerson" is. And this disables e.g. auto completion for the fields of contactPerson.
When editing the fragment, Intellij proposes "Declare external variable as <jsp:useBean>" but this does not work, because "Namespace 'jsp' is not bound".
So, I either need to bind this namespace (but I could not find the URL to bind it to) or use another way to declare the object. I'm also a bit confused about the "jsp:" despite I'm not working on a jsf (not jsp) project.
I'm also unsure if using "jsp" tags will break the application at runtime. At least while it's not bound, it produces an error.
It's important that I only want to declare the type of the variable, not set a value as in <c:set> (jstl).
Please sign in to leave a comment.
Hi Markus,
You need to press Alt+Enter and activate the following quick fix:
which will get you this result:
OK, that worked. Thank you very much.
Just out of curiosity ... why is the <jsp:useBean> option available at all in a jsf project? Does that mean I could have a misconfguration?
Happy to help Markus.
Not necessarily. Let me check internally on how exactly the <jsp:useBean> quick fix is applied (what it changes, adds, etc.), and get back to you.
Hi Markus,
Turns out it is a bug after all: https://youtrack.jetbrains.com/issue/IDEA-286375
Feel free to follow it for updates and leave additional comments in the issue thread.
See this article if you are not familiar with YouTrack.
OK, thank you for the info about it being a bug.
I'm a bit familiar with YouTrack, just did not find that bug. It's sometimes a bit difficult if the search terms I have in mind are not the same that are being used in the bug report. :-)