column
이 dataTable
인 경우 이벤트를 실행할 수없는 것 같습니다. 여기 내 간단한 demostration이 Primefaces 버그 또는 Mojarra/MyFaces 버그입니까
<h:form id="form">
<!--This section of p:tree here seems to be the reason causing the event not fired when click the command button-->
<p:tree value="#{viewBean.root}" var="node" dynamic="true" cache="false"
selectionMode="checkbox" selection="#{treeBean.selectedNode}">
<p:ajax event="expand" update=":form:messages" listener="#{viewBean.onNodeExpand}" />
<p:ajax event="collapse" update=":form:messages" listener="#{viewBean.onNodeCollapse}" />
<p:ajax event="select" update=":form:messages" listener="#{viewBean.onNodeSelect}" />
<p:ajax event="unselect" update=":form:messages" listener="#{viewBean.onNodeUnselect}" />
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
<h:panelGroup id="mygroup">
<p:dataTable id="mytable" value="#{viewBean.foodList}" var="item">
<p:column>
#{item}
</p:column>
<p:column>
<p:commandButton value="delete"
action="#{viewBean.delete}"
update=":form:mygroup">
<f:setPropertyActionListener target="#{viewBean.selectedFood}"
value="#{item}"/>
</p:commandButton>
</p:column>
</p:dataTable>
</h:panelGroup>
</h:form>
및 내 관리 빈
@ManagedBean
@ViewScoped
public class ViewBean {
private TreeNode root;
private TreeNode selectedNode;
private List<String> foodList;
private String selectedFood;
@PostConstruct
public void init(){
foodList = new ArrayList<String>();
foodList.add("Pizza");
foodList.add("Pasta");
foodList.add("Hamburger");
root = new DefaultTreeNode("Root", null);
TreeNode node0 = new DefaultTreeNode("Node 0", root);
TreeNode node1 = new DefaultTreeNode("Node 1", root);
TreeNode node2 = new DefaultTreeNode("Node 2", root);
TreeNode node00 = new DefaultTreeNode("Node 0.0", node0);
TreeNode node01 = new DefaultTreeNode("Node 0.1", node0);
TreeNode node10 = new DefaultTreeNode("Node 1.0", node1);
TreeNode node11 = new DefaultTreeNode("Node 1.1", node1);
TreeNode node000 = new DefaultTreeNode("Node 0.0.0", node00);
TreeNode node001 = new DefaultTreeNode("Node 0.0.1", node00);
TreeNode node010 = new DefaultTreeNode("Node 0.1.0", node01);
TreeNode node100 = new DefaultTreeNode("Node 1.0.0", node10);
}
public void delete(){
foodList.remove(selectedFood);
}
//setter and getter
public void onNodeExpand(NodeExpandEvent event) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Expanded", event.getTreeNode().toString());
FacesContext.getCurrentInstance().addMessage(null, message);
}
public void onNodeCollapse(NodeCollapseEvent event) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Collapsed", event.getTreeNode().toString());
FacesContext.getCurrentInstance().addMessage(null, message);
}
public void onNodeSelect(NodeSelectEvent event) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Selected", event.getTreeNode().toString());
FacesContext.getCurrentInstance().addMessage(null, message);
}
public void onNodeUnselect(NodeUnselectEvent event) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Unselected", event.getTreeNode().toString());
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
내 문제가 delete
호출되지는 결코 의미하는 이벤트가 발생되지 않도록 할 것입니다.
나는 주변을 둘러 보았고 Mojarra에는 중첩 된 UIData 구성 요소와 관련된 문제점이 있으므로 Mojarra 2.1.4를 시도했지만 여전히 문제를 해결하지 못했습니다. 나는 Myfaces 2.1.5를 시도했지만 여전히 작동하지 않는다 !! 이것은 Primefaces 버그입니까? 심지어 h:panelGroup
을 update
에 대한 래퍼로 사용하지만 여전히 작동하지 않습니다.
편집 : 그것은 dataTable
위의 p:tree
가 commandButton
을 클릭하지 않을 경우 해고 이벤트의 근본 원인이라고 판명. p:tree
을 제거하면 즉시 작동합니다. p:tree
자체가 훌륭하게 작동합니다. 체크 아웃을 클릭하면 내 관리 대상 Bean에서 이벤트가 실행됩니다.
앞으로는 "작동하지 않는다"와 관련하여 좀 더 구체적으로 설명하십시오. 예 : "selectedFood는'delete()'메쏘드 안에서'null '입니다. – BalusC
@BalusC : 죄송합니다. '게시물이 작동하지 않습니다.'라는 말의 의미를 명확히하기 위해 게시물을 편집했습니다. –
좋습니다, 청어 청어를 피하려면 처음에 답을 게시 한 버그를 수정하는 것을 잊지 마십시오. 당신은 여전히 "작동하지 않습니다"에 분명하지 않습니다. "해고 당하지 않는 사건"이란 정확히 무엇을 의미합니까? 예를 들어 Firebug/Chrome에 따라 아약스 요청이 전혀 전송되지 않았습니까? – BalusC