views:

67

answers:

1

Hello, From now on, I have this :

.....
<a4j:commandButton  action="#{ChoixContratBean.Submit1}" reRender="suite" value="valider"  > </a4j:commandButton>
        </a4j:outputPanel>

    <a4j:outputPanel display="none" id="suite">
    <jsf:outputText id="reponseeFormule"............

which works. the suite panel is rerendered. But I would like to hide this outputpanel named suite. and show it once the user validated via the commandButton... I can't find out how to do it, anyone has an idea ?

thank you !

A: 

Ok I finally found out after hours. (I posted the question after hours of search, I'm a beginner in richfaces)

It's not very complicated but there's a little trap you don't want to fall in. The final code looks like that :

     ......<a4j:outputPanel id="check">
    <richfaces:panel rendered="#{ChoixContratBean.essaiValid}">
    <jsf:outputText value="#{ChoixContratBean.check}" /></richfaces:panel>
        </a4j:outputPanel>                  
    </td>               
   </tr>                
 </table>
</richfaces:simpleTogglePanel> 
    <a4j:commandButton  action="#{ChoixContratBean.Submit1}" reRender="suite, check" value="valider"> </a4j:commandButton>  
        <a4j:outputPanel id="suite" >
<richfaces:simpleTogglePanel rendered="#{ChoixContratBean.suite}" switchType="ajax"......

First an outputPanel must be rendered= true or ajax won't touch it. That was my first mistake, I thought I could make an outputPanel rendered="#{ChoixContrat.someBool}, and change it in the ajax action linked to the command button. But no, if it's first set rendered = false, ajax won't be able to change it to true, because it's not reachable in the first place! You got to set rendered=some boolean in your back bean in a component wich contains what you want to hide and which is in the outputPanel id= suite as for my example. This way, the outputPanel is always rendered, but the component in it will remain hidden or visible whether your contrainer's attribute rendered is set to false or true in the back, in the ajax method..

hope I'm clear coz I'm french.....

Yaelle