我從RichFaces 3.3.3遷移到4.0,遇到了一個無法解決問題的問題。到目前爲止,我已經使用RichFaces的@ KeepAlive註釋來實現View的作用域,但是新版本4到目前爲止並沒有這樣的功能(據我所知)。所以我認爲@ViewScoped註釋將是自然的(快速的)替換,但它不起作用。 這是相關的代碼給我帶來麻煩。它呈現一張包含客戶名稱作爲鏈接的表格,所以當單擊名稱時,會彈出一個彈出窗口來編輯數據。它在v3.3.3中使用@KeepAlive工作,但不在v4中使用@ViewScoped(彈出窗口不會被調用)。RichFaces 4和@ViewScoped
頁:
<h:form prependId="false">
<rich:dataTable id="table" value="#{myBean.customers}" var="customer">
<!--...headers...-->
<h:column>
<a4j:commandLink action="#{myBean.selectCustomer}"
oncomplete="#{rich:component('popup_customer_editor')}.show();" render="form_customer_editor">
${customer.name}
<f:setPropertyActionListener value="#{customer}" target="#{myBean.selectedCustomer}"/>
</a4j:commandLink>
</h:column>
<h:column>${customer.address}</h:column>
</rich:dataTable>
</h:form>
<rich:popupPanel id="popup_customer_editor>
<h:form id="form_customer_editor">
<!--...form fields...-->
</h:form>
</rich:popupPanel>
豆子:
@ManagedBean
@ViewScoped //It was @KeepAlive before
public class MyBean implements Serializable
{
private String name;
private String address;
private Customer selectedCustomer; //POJO class
//getters and setters
...
public String selectCustomer()
{
name = selectedCustomer.getName();
address = selectedCustomer.getAddress();
return null;
}
}
任何幫助,將不勝感激
感謝您的建議,但方法爲myBean。 selectCustomer(customer)沒有被調用。 – etercap 2011-04-05 16:16:00
只是關於作用域的評論,RichFaces 4將不具有視圖範圍(a4j:keepAlive),因爲它現在可以從JSF 2獲得。 – 2011-04-05 16:25:01
有兩個原因可能導致您的操作不能被調用: 1。您有一個提交的字段,驗證/轉換失敗。如果您有驗證或轉換器錯誤,則不會調用您的操作。你應該有一個''以確保你看到它,或者將開發階段設置爲web.xml中的開發(當我到達辦公室時,我會給你實際的片段)。 2.您在另一個「」內有一個'',並且您正在嘗試提交內部的一個。你可以用螢火蟲追蹤這真的很容易。 PS:我討厭stackoverflow格式。 –
2011-04-06 04:26:53