Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try to replace xhtml code with the following code</p> <pre><code>&lt;!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j"&gt; &lt;h:head&gt; &lt;/h:head&gt; &lt;h:form prependId="false"&gt; &lt;h:selectOneRadio id="type" label="Type" value="#{testBean.type}"&gt; &lt;f:selectItem itemLabel="Type1" itemValue="type1" /&gt; &lt;f:selectItem itemLabel="Type2" itemValue="type2" /&gt; &lt;f:ajax execute="@all" render="selectInputPanel"/&gt; &lt;/h:selectOneRadio&gt; &lt;h:panelGroup id="selectInputPanel"&gt; &lt;h:selectOneMenu id="selectBox" label="Service" value="#{testBean.service}" rendered="#{testBean.isType1}" style="width:285px"&gt; &lt;f:selectItem itemLabel="Medium" itemValue="medium" /&gt; &lt;f:selectItem itemLabel="Basic" itemValue="basic" /&gt; &lt;f:selectItem itemLabel="Premium" itemValue="premium" /&gt; &lt;/h:selectOneMenu&gt; &lt;h:inputText id="inputBox" size="50" value="#{testBean.custom}" rendered="#{!testBean.isType1}" /&gt; &lt;/h:panelGroup&gt; &lt;/h:form&gt;&lt;/ui:composition&gt; </code></pre> <p>Main problem in your code is,</p> <ol> <li>Missing h:head to import jsf.js which is required for jsf ajax.</li> <li>Please wrap your component into a panelGroup as suggested by @BaluC because once the component not rendered (not available on page) then the ajax on it will not work with its id.</li> </ol> <p>And regarding number of time getIsType1() method calling is due to the rendered attribute, for more information check @Baluc's answer <a href="https://stackoverflow.com/questions/4281261/why-is-the-getter-called-so-many-times-by-the-rendered-attribute?lq=1">here</a></p>
 

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