I'm trying to dynamically render some composition/templates based on the presence of a query string or the absence of a query string. For example:
localhost:9080/myWonderfulApp/test.xhtml?foo=bar
This works, A.xhtml gets pulled in.
localhost:9080/myWonderfulApp/test.xhtml
This doesn't work, B.xhtml does not get pulled in.
I'm having problems with the absence of a query string part. I can render A.xhtml when I pass ?foo=bar, but I can't seem to get B.xhtml rendered when I have no query string. I've tried some variations, I initially figured #{param['foo'] != 'bar' would work, but I think that's not working because I don't have a foo query param at all. I've tried checking if param == null but that didn't work either.
Is it possible to set my rendered attribute based on NO query string?
I can't just set another query string for B.xhtml, either as I'm working on a legacy app that gets 2 different skins, so retrofitting all the old apps that link in isn't an option. New apps will use a query string, old ones need to get an old skin linking in with no query string.
<!--This works-->
<h:panelGrid rendered="#{param['foo'] == 'bar' ? true : false}">
<ui:composition template="A.xhtml">...</ui:composition>
</h:panelGrid>
<!--This doesn't work-->
<h:panelGrid rendered="#{param == null ? true : false}">
<ui:composition template="B.xhtml">...</ui:composition>
</h:panelGrid>
This doesn't seem to work, either:
<h:panelGrid rendered="#{empty facesContext.externalContext.requestParameterMap.foo ? true : false}">