我在面临一个问题,JSF 2.2,在Tomcat 7的RichFaces 4.3.2。
我的页面annoted ViewScoped
。
我显示第一种形式。当我改变的价值和选择具体的一个,我显示由阿贾克斯富人:一个
。
在这个 A4J内面板
元素:outputPanel A4J:outputPanel
和丰富:面板
部分,我有一个 H:的commandButton
谁执行的形式。
我想检索邮件错误的形式,如果该字段为空,例如(或其他东西)
但是当我点击 H:的commandButton
的观点是再重新执行instancied和 @postcontruct
方法。它应该只在视图范围内被执行一次,我错了?
我不希望的看法被reactualised,我想保持 ajaxoutputPanel
显示,当我点击 H:的commandButton 里(我希望看到
H:消息
旁边,我的形式领域...没有太大的要求:-))
我读到了一些错误。 ..有没有办法来改变这种行为,而不传递到SessionScoped为例。
感谢帅哥。
<字段集>
< H:形式GT;
&所述; H:panelGrid的列=3>
< H:的outputText值=喃DE L'练习曲:>< / H:的outputText>
< H:inputText的ID =study_name值=#{analyse.study_name}大小=20需要=真的标签=喃DE L'练习曲/>
< H:消息=study_name的风格=颜色:红色/>
< H:的outputText值=分析:> < / H:的outputText>
< H:selectOneMenu用于ID =分析值=#{analyse.analyse_type}>
< F:selectItems的值=#{analyse.analyse_type2Value}/>
< F:AJAX执行=分析渲染=:ajaxOutputPanelAnalyse/>
< / H:selectOneMenu用于>
< / H:panelGrid的>
< /小时:形式GT;
< /字段集>
< A4J:outputPanel ID =ajaxOutputPanelAnalyse布局=块ajaxRendered =真正的>
<丰富:面板ID =richPanelAnalyse呈现=#{analyse.analyse_type ==农工商和request.isUserInRole('ROLE_ADMIN_PROFILER_NGS')}>
< H:格式ID =NGS_form>
&所述; H:panelGrid的列=4>
< H:的outputText值=运行#:> < / H:的outputText>
< H:inputText的ID =run_number值=#{analyse.run_number}大小=20需要=真的标签=运行/>
< H:消息=run_number的风格=颜色:红色/>
< H:的outputText>< / H:的outputText>
< / H:panelGrid的>
< H:的commandButton值=提交行动=#{analyse.addAnalyse}/>
< /小时:形式GT;
< /富:面板>
< / A4J:outputPanel>
在豆...
@PostConstruct
公共无效setFlashParam(){
的System.out.println(POST CONSTRUCT MON POTE);
FacesContext中的FacesContext = FacesContext.getCurrentInstance();
返回;
}
公共字符串addAnalyse(){
的System.out.println(纪行);
。FacesContext.getCurrentInstance()方法addMessage(空,新的FacesMessage( - Ajout DE L'分析?+倒乐病人?+丹斯欧莱雅练习曲+ study_name + - ));
回归pretty的:家;
}
解决方案
解决由于此帖来自BalusC(一如既往)http://balusc.blogspot.fr/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichContainsAnotherForm
编辑:但它没有更多的,当您尝试添加丰富的工作:文件上传既不符合H:INPUTFILE ...这将显示奇怪的HTML code在一个新的textarea当你点击按钮....这很奇怪......
<丰富的:文件上传ID =上传fileUploadListener =#{analyse.test}acceptedTypes =咣当,PDF,PNGontyperejected =警报('Seulement LES fichiers AVEC L'扩展咣等PDF SONTacceptés');。 maxFilesQuantity =3>
< A4J:AJAX事件=uploadcomplete执行=@无渲染=上传/>
< /富:文件上传>
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...
<rich:fileUpload id="upload" fileUploadListener="#{analyse.test}" acceptedTypes="bam,pdf,png" ontyperejected="alert('Seulement les fichiers avec l'extension bam et pdf sont acceptés.');" maxFilesQuantity="3">
<a4j:ajax event="uploadcomplete" execute="@none" render="upload" />
</rich:fileUpload>