Note that there are some explanatory texts on larger screens.

plurals
  1. POConditionally render JSF h:panelGrid based on presence of query string (or no query string at all)
    primarykey
    data
    text
    <p>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:</p> <p>localhost:9080/myWonderfulApp/test.xhtml?foo=bar</p> <p>This works, A.xhtml gets pulled in.</p> <p>localhost:9080/myWonderfulApp/test.xhtml</p> <p>This doesn't work, B.xhtml does not get pulled in.</p> <p>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.</p> <p>Is it possible to set my rendered attribute based on NO query string?</p> <p>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.</p> <pre><code>&lt;!--This works--&gt; &lt;h:panelGrid rendered="#{param['foo'] == 'bar' ? true : false}"&gt; &lt;ui:composition template="A.xhtml"&gt;...&lt;/ui:composition&gt; &lt;/h:panelGrid&gt; &lt;!--This doesn't work--&gt; &lt;h:panelGrid rendered="#{param == null ? true : false}"&gt; &lt;ui:composition template="B.xhtml"&gt;...&lt;/ui:composition&gt; &lt;/h:panelGrid&gt; </code></pre> <p>This doesn't seem to work, either:</p> <pre><code>&lt;h:panelGrid rendered="#{empty facesContext.externalContext.requestParameterMap.foo ? true : false}"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload