1

i am beginner in JSF ,i have a problem with selectonemenu item.When i choose the an item ,for example ' FirstLabel',outputpanel should be shown.However ,selectone menu does not update my choice.I use primefaces 3.1 library.How can i solve this problem.Thanks for helps.

            <p:selectOneMenu value="#{denemeView.str}" effect="fold" editable="true"  >  
                <f:selectItem itemLabel="Please choose!." itemValue="" /> 
                <f:selectItem itemLabel="FirstLabel" itemValue="1" /> 

                <f:selectItem itemLabel="SecondLabel" itemValue="2" /> 

                <p:ajax   process="@this"  update=":Form2:panel1"/>
                <p:ajax process="@this" update=":Form2:panel2"/>
            </p:selectOneMenu> 


        </p:outputPanel> 


        <p:outputPanel id="panel1" rendered="#{denemeView.str=='1'}">

            <h:outputText value="Output: * " />
            <p:inputText id="out" value="#{denemeView.islem}" />



        </p:outputPanel>

        <p:outputPanel id="panel2" rendered="#{denemeView.str=='2'}">

            <h:outputText value="True choice! " />

        </p:outputPanel>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Deniz
  • 127
  • 1
  • 5
  • 14

1 Answers1

1

If a JSF component has rendered="false" set then it's not redered (the component object is not present in the object tree) and cannot be updated using <p:ajax update="someId"/> or <f:ajax render="someId"/>. What you need to do is wrap these two panels in an outer panel and update that one. Something like this:

<p:ajax   process="@this"  update="outerPanel"/>
...
<p:outputPanel id="outerPanel">
 <p:outputPanel id="panel1" rendered="#{denemeView.str=='1'}">
        <h:outputText value="Output: * " />
        <p:inputText id="out" value="#{denemeView.islem}" />
 </p:outputPanel>

 <p:outputPanel id="panel2" rendered="#{denemeView.str=='2'}">
        <h:outputText value="True choice! " />
 </p:outputPanel>
</p:outputPanel>

See here for a similar problem.

Community
  • 1
  • 1
dratewka
  • 2,104
  • 14
  • 15
  • Thank you for help.I tried wrap with your suggestion and – Deniz Aug 06 '13 at 11:30
  • I've checked the code and it works in my case - does the bean value set properly? – dratewka Aug 06 '13 at 11:58
  • ın bean ,there is string str and it has setter and getter.My friend was coding like this with primefaces 2.2.1 library,also it works.Does this problem arised from library ?? I used primefaces 3.1. – Deniz Aug 06 '13 at 12:23