views:

25

answers:

1

Hi, My requirement is like this: I am having a text input and whenever a value change event occurs, a select many list box has to be populated. If there is no matching records found, then a text input has to appear instead of a select many list box.

    <h:column>
<h:selectManyListbox size="3" value="#{hostInfoBean.gateKeeperendPointReference}" rendered="#{hostInfoBean.selectManyRendered}"                             id="gateKeeperendPointReference">
<f:selectItems value="#{hostInfoBean.gateKeeperendPointReferenceItems}" />
</h:selectManyListbox>
<h:inputText id="gateKeeperendPointReferenceText" size="30" rendered="#{!hostInfoBean.selectManyRendered}">
</h:inputText>
</h:column>

Also I am using a4j for the value change listener,

<a4j:support event="onchange"                   reRender="hostInfo:gateKeeperendPointReference" focus="GFacPath"
                    ajaxSingle="true" />

'selectManyRendered' is a boolean value which I am determining in the JAVA bean. The program works only for the default value of the boolean variable. If the boolean value is changed during runtime, then the toggle between the visibility of selectManyListbox and inputText is not working. Please help to fix this. Am i missing something?

regards, Suresh

+1  A: 

If the "rendered" attribute resolves to false, then the component isn't in your tree and can't be found as a "rerender" target. When you have components that are rendered conditionally you want to wrap them in a component that is always available as a target, like so:

<h:inputText value="#{myBean.text}" >
  <a4j:support event="onkeyup" reRender="listZone" ajaxSingle="true" />
</h:inputText>
<h:panelGroup id="listZone">
  <h:selectManyListbox value="#{myBean.list}" rendered="#{myBean.renderList}" >
    <f:selectItems value="#{myBean.listItems}" />
  </h:selectManyListbox>
  <h:inputText size="30" rendered="#{!myBean.renderList}/>
<h:panelGroup id="listZone">
Naganalf
Thanks a lot for the update. I will try this and update
Suresh