我有 datatable 所在的 mainMenu-xhtml 页面。当我向该表添加一个新对象时,它不会更新,因为使用的托管 bean 是会话范围的。我正在尝试实现 requestScoped wrapperBean 以进行更新。
面孔配置:
<navigation-case>
<from-action>#{RmaBeanWrapper.submit}</from-action>
<from-outcome>refreshedMainMenu</from-outcome>
<to-view-id>/mainMenu.xhtml</to-view-id>
</navigation-case>
<managed-bean>
<managed-bean-name>RmaBeanWrapper</managed-bean-name>
<managed-bean-class>fi.controllers.RmaBeanWrapper</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>rmaBean</property-name>
<value>#{RmaBean}</value>
</managed-property>
</managed-bean>
RmaBeanWrapper
@ManagedBean
@RequestScoped
public class RmaBeanWpapper implements Serializable {
private RmaBean rmaBean;
private RmaBean refreshedBean;
public RmaBean getRmaBean() {
return rmaBean;
}
public void setRmaBean(RmaBean rmaBean) {
this.rmaBean = rmaBean;
}
public RmaBean getRefreshedBean() {
return refreshedBean;
}
public void setRefreshedBean(RmaBean refreshedBean) {
this.refreshedBean = refreshedBean;
}
public String submit() {
System.out.println("#########RmaBeanWpapper.submit#########");
this.refreshedBean = rmaBean;
return "refreshedMainMenu";
}
主菜单.xhtml
<p:panelGrid style="margin-top:20px;" styleClass="noBorders">
<p:row rendered="true">
<p:column></p:column>
<p:column></p:column>
<p:column><p:commandButton action="#{RmaBeanWpapper.submit}" ajax="false" value="Update Table" style="width: 220px;"/></p:column>
<p:column></p:column>
</p:row>
}
What is happening? Nothing! The mainMenu.xhtml page doesn't even open, and there is not even any exceptions in the servers log. Samehow I have to get my table updated, but there is something wrong with my implementation. Any ideas? I can't change rmaBean to sessionScoped, because is is used everywhere in the software and I can't change it.
Cheers, Sami