あるページから別のページにパラメーターを渡したいと思います。
各ページにはViewScoped JSF Backing Bean があります。
ただし、使用しようとする<f:param>
と、次のエラーが表示されます。クリック<h:commandLink>
すると別のページに移動します。
エラー :
] Root cause of ServletException.
com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean ReservationActionBean. The following problems were found:
- The scope of the object referenced by expression #{param.resvDataModel}, request, is shorter than the referring managed beans (ReservationActionBean) scope of view
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:265)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
.........
page1.xhtml
<p:panelGrid style="margin-top:-1px;" id="dashboard">
<ui:repeat value="#{DashBoard.dayList}" var="day">
<p:row>
<p:column style="background:#C1CDCD;width:100px;">
<h:outputText value="#{day}" style="color:#333333;font-size:13px;">
<f:convertDateTime type="date" pattern="EEE, yyyy-MM-dd"/>
</h:outputText>
</p:column>
<ui:repeat value="#{DashBoard.timeSlot}" var="timeSlot">
<p:column style="background:#C1CDCD;text-align: center;">
<h:outputText value="#{timeSlot}" style="font-size:12px;"/>
</p:column>
</ui:repeat>
</p:row>
<ui:repeat value="#{DashBoard.resourceList}" var="res">
<p:row>
<p:column>
<h:outputText value="#{res.name}" style="font-size:12px;"/>
</p:column>
<ui:repeat value="#{DashBoard.getResvDataModelList(day, res)}" var="model">
<p:column style="background:#{model.colour};" colspan="#{model.section}">
<h:commandLink action="reservation" style="display:block;width:#{model.section * 50}px;height:20px;">
<f:param name="model" value="#{ReservationActionBean.resvDataModel}"/>
<!--h:outputText value="#{model.user}"rendered="#{model.resource.name == res.name ? true : false}"style="font-size:12px;"/-->
</h:commandLink>
</p:column>
</ui:repeat>
</p:row>
</ui:repeat>
</ui:repeat>
</p:panelGrid>
page2.xml
<h:form id="reservationEntryFrom">
<f:metadata>
<f:viewParam name="resvDataModel" value="#{ReservationActionBean.resvDataModel}"/>
</f:metadata>
<!-- other -->
</h:form>
ダッシュボード.java
@ManagedBean(name = "DashBoard")
@ViewScoped
public class DashBoard extends BaseBean {
public List<ResvDataModel> getResvDataModelList(
Date date, MeetingRoom meetingRoom) {
// do operation
}
}
ReservationActionBean.java
@ManagedBean(name="ReservationActionBean")
@ViewScoped
public class ReservationActionBean extends BaseBean {
@ManagedProperty("#{param.resvDataModel}")
private ResvDataModel resvDataModel;
//other operations
}
ResvDataModel.java
public class ResvDataModel {
// attribute, getter and sertter
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}