Tôi muốn thêm linh kiện Primefaces theo kiểu động. Tôi đang sử dụng giải pháp tương tự như this one, đã được thảo luận ở đó sớm hơn:Thêm thành phần Primefaces động
<h:form>
<h:panelGrid columns="2">
<p:dataGrid id="categoriesGrid" value="#{bean.categories}"
var="categoryBean" rowIndexVar="rowIndex">
<p:column>
<p:selectOneMenu id="categorySelect" effect="drop"
value="#{categoryBean.selectedCategory}" >
<f:selectItems value="#{categoryBean.availableCategories}"
var="category" itemLabel="#{category.name}"
itemValue="#{category}" />
</p:selectOneMenu>
</p:column>
</p:dataGrid>
<p:commandButton actionListener="#{bean.addNewCategory}"
value="Add category" update="categoriesGrid"/>
</h:panelGrid>
</h:form>
Nhưng có vấn đề với nó. Có ví dụ về phản ứng tôi nhận được sau khi nút "Thêm thể loại" được nhấp:
<?xml version='1.0' encoding='UTF-8'?>
<partial-response>
<error>
<error-name>
class javax.faces.component.UpdateModelException
</error-name>
<error-message>
<![CDATA[/createTutorial.xhtml @85,65 value=
"#{categoryBean.selectedCategory}":java.util.NoSuchElementException]]>
</error-message>
</error>
</partial-response>
Cảm ơn trước
Như tôi đã tìm thấy [ở đó] (http://code.google.com/p/primefaces/issues/detail?id=1568), 'p: column' phải được thêm vào, nhưng sự cố với ajax vẫn tồn tại – nikagra
Vui lòng đăng giải pháp của bạn dưới dạng câu trả lời (bạn có thể tự chấp nhận sau này). – oers
Có, tất nhiên) – nikagra