I 'm facing a problem with JSF 2.2, richfaces 4.3.2 on Tomcat 7 .
My page is annoted ViewScoped
.
I display a first form. When i change the value and select a specific one , i display by ajax a rich:panel
element inside an a4j:outputPanel
.
Inside this a4j:outputPanel
and rich:panel
component, i have a h:commandButton
who execute the forms.
I want to retrieve messages error for the form if the fields are empty for example (or other stuffs)
But when i click h:commandButton
, the view is re instancied and @postcontruct
method is re executed. It should be executed one time only in the view scope, am i wrong ?
I don't want the view to be reactualised, i want keep the ajaxoutputPanel
displayed when i click the h:commandButton
inside.(and i want to see the h:messages
next to my forms fields...not much asking :-) )
I read about some bug... is there a way to change this behavior without passing to SessionScoped for example.
Thanks dudes.
<fieldset>
<h:form>
<h:panelGrid columns="3">
<h:outputText value ="Nom de l'étude : "></h:outputText>
<h:inputText id="study_name" value="#{analyse.study_name}" size="20" required="true" label="Nom de l'étude" />
<h:message for="study_name" style="color:red" />
<h:outputText value ="Analyse : "> </h:outputText>
<h:selectOneMenu id = "analyse" value="#{analyse.analyse_type}">
<f:selectItems value="#{analyse.analyse_type2Value}" />
<f:ajax execute="analyse" render=":ajaxOutputPanelAnalyse" />
</h:selectOneMenu>
</h:panelGrid>
</h:form>
</fieldset>
<a4j:outputPanel id="ajaxOutputPanelAnalyse" layout="block" ajaxRendered="true" >
<rich:panel id="richPanelAnalyse" rendered="#{analyse.analyse_type == 'NGS' and request.isUserInRole('ROLE_ADMIN_PROFILER_NGS')}" >
<h:form id ="NGS_form" >
<h:panelGrid columns="4">
<h:outputText value ="Run # :"> </h:outputText>
<h:inputText id="run_number" value="# {analyse.run_number}" size="20" required="true" label="Run" />
<h:message for="run_number" style="color:red" />
<h:outputText></h:outputText>
</h:panelGrid>
<h:commandButton value="Submit" action="#{analyse.addAnalyse}"/>
</h:form>
</rich:panel>
</a4j:outputPanel>
In the bean...
@PostConstruct
public void setFlashParam(){
System.out.println("POST CONSTRUCT MON POTE");
FacesContext facesContext = FacesContext.getCurrentInstance();
return;
}
public String addAnalyse(){
System.out.println("Kikou");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(" - Ajout de l'analyse ?"+" pour le patient ?"+" dans l'étude "+ study_name +" -"));
return "pretty:home";
}
Resolve thanks to this post from BalusC (as always) http://balusc.blogspot.fr/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichContainsAnotherForm
EDIT : But it's no more working when you try to add an rich:fileupload neither with h:inputFile... It will displayed strange html code in a newly textarea when you click the button....It's weird...