Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>JSF generates HTML. JS/Ajax works on HTML. JS/Ajax updates HTML elements by finding it in HTML DOM tree by <code>document.getElementById()</code> and replacing its contents based on Ajax response. However, if a JSF component is instructed to not render HTML, then JS/Ajax cannot find it in the HTML DOM tree and thus can't replace anything.</p> <p>You can only ajax-update the HTML representation of a JSF component which is <strong>always</strong> rendered. So, wrap them in e.g. a <code>&lt;h:panelGroup&gt;</code>.</p> <pre><code>&lt;h:selectOneRadio ...&gt; &lt;f:ajax ... render="selectAndInputBox" /&gt; &lt;/h:selectOneRadio&gt; &lt;h:panelGroup id="selectAndInputBox"&gt; &lt;h:selectOneMenu ... rendered="..." /&gt; &lt;h:inputText ... rendered="..." /&gt; &lt;/h:panelGroup&gt; </code></pre> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/9010734/why-do-i-need-to-nest-a-component-with-rendered-some-in-another-component-w/">Why do I need to nest a component with rendered=&quot;#{some}&quot; in another component when I want to ajax-update it?</a></li> </ul> <hr> <p><strong>Unrelated</strong> to the concrete problem, that <code>getIsType1()</code> method is clumsy. Just do the comparison directly in the view so that you can get rid of it.</p> <pre><code>&lt;h:selectOneMenu ... rendered="#{testBean.type == 'type1'}" /&gt; &lt;h:inputText ... rendered="#{testBean.type != 'type1'}" /&gt; </code></pre> <p>or perhaps, more matching your initial question,</p> <pre><code>&lt;h:selectOneMenu ... rendered="#{testBean.type == 'type1'}" /&gt; &lt;h:inputText ... rendered="#{testBean.type == 'type2'}" /&gt; </code></pre>
    singulars
    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.
    1. VO
      singulars
      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