I am trying to pass id (long) from one.xhtml to another .xhtml.
Both the backing beans are @ViewScoped
and I am trying to share long id between them.
I am getting error with <f:viewParam/>
com.sun.faces.mgbean.ManagedBeanCreationException
: Unable to create managed bean saleOrder. The following problems were found: - The scope of the object referenced by expression#{param.foo}
, request, is shorter than the referring managed beans (saleOrder
) scope of view.
I am have following code.
@ManagedBean
public class InvoiceView{
private long number;
// setter getter.
}
@ManagedBean
@ViewScoped
public SearchInvoice{
private List<InvoiceView> views;
private InvoiceView selectedView; // this is coming from <p:dataTable>
}
@ManagedBean
@ViewScoped
public class SaleOrder {
@ManagedProperty("#{param.foo}")
private String number;
@PostConstruct
public void init(){
//sysout number;
}
}
I have following code in searchInvoice.xhtml
file.
<!-- I have not desclared <f:metadata/> -->
<h:commandButton value="Place Sale Order"
action="#{searchInvoice.forwardToSaleOrder}" <!-- this return saleOrder.xhtml string -->
rendered="#{not empty searchInvoice.views}">
<f:viewParam name="foo" value="#{searchInvoice.selectedView.number}" />
</h:commandButton>