我页面上的保存按钮的格式不同于p:tree
,此按钮可以正常工作,直到您对树进行拖放,然后不仅是此按钮,还包括页面中的所有其他按钮将不再工作。
他们的onstart
和oncomplete
有效,但他们的listeners
无效。
<p:panel header="#{bundle.GaStructNode}">
<div class="ui-g">
<div class="ui-g-4">
<h:form id="GaStructNode_listForm" styleClass="GaStructNode_listForm">
<p:panel header="#{bundle.GaStructNodetree}"
rendered="#{gaStructNodeController.selectedGroupActor != null and gaStructNodeController.selectedGaStruct != null}">
<p:tree id="GaStructNode_listForm_tree" var="gsn" orientation="vertical"
style="width: 100%; border-radius: 0;" draggable="#{gaStructNodeController.gaStructNodeEditable}"
selection="#{gaStructNodeController.selectedGaStructNode}" droppable="#{gaStructNodeController.gaStructNodeEditable}"
value="#{gaStructNodeController.root}" dir="#{i18n.direction}" animate="true"
selectionMode="single">
<p:ajax event="select"
update=":GaStructNode_editForm GaStructNode_listForm:GaStructNode_listForm_btnsPanel GaStructNode_listForm:GaStructNode_editTreeForm :GaStructNode_picklist_form"/>
<p:ajax event="unselect"
update=":GaStructNode_editForm GaStructNode_listForm:GaStructNode_listForm_btnsPanel GaStructNode_listForm:GaStructNode_editTreeForm :GaStructNode_picklist_form"/>
<p:ajax event="dragdrop" listener="#{gaStructNodeController.treeOnDrop}" />
<p:treeNode>
<h:outputText value="#{gsn.unit.name}"/>
</p:treeNode>
</p:tree>
<p:outputPanel id="GaStructNode_editTreeForm">
<p:panelGrid rendered="#{gaStructNodeController.selectedGaStructNode != null}"
style="width: 100.5%;">
<p:row>
<p:column>
<p:outputLabel value="#{bundle.GaUnit}" for="@next"
style="margin-left: 15px"
styleClass="template-labels"/>
<p:selectOneMenu id="GaStructNode_editTreeForm_gaUnit"
value="#{gaStructNodeController.selectedGaStructNodeData.unit}"
style="margin-bottom: 10px"
disabled="#{!gaStructNodeController.gaStructNodeEditable}">
<f:selectItem itemValue="#{gaStructNodeController.selectedGaStructNodeData.unit}" itemLabel="#{gaStructNodeController.selectedGaStructNodeData.unit.name}"/>
<f:selectItems value="#{gaStructNodeController.findGaUnitByOwner()}"
var="gu"
itemLabel="#{gu.name}" itemValue="#{gu}"/>
<p:ajax update="GaStructNode_save :GaStructNode_editForm:GaStructNode_listForm_dataTable:GaStructNode_listDataTableForm_createBtn GaStructNode_listForm_tree"/>
</p:selectOneMenu>
</p:column>
</p:row>
</p:panelGrid>
</p:outputPanel>
<f:facet name="footer">
<p:outputPanel id="GaStructNode_listForm_btnsPanel"
style="text-align: center;background-color: #DDECF5 !important;">
<p:commandButton id="GaStructNode_listForm_createBtn" icon="ui-icon-plus"
title="#{bundle.Create}" disabled="#{gaStructNodeController.gaStructNodeEditable}"
actionListener="#{gaStructNodeController.prepareCreate}"
update="GaStructNode_save GaStructNode_listForm:GaStructNode_listForm_btnsPanel :GaStructNode_editForm GaStructNode_listForm:GaStructNode_editTreeForm"/>
<p:commandButton id="GaStructNode_listForm_editBtn" icon="ui-icon-pencil"
title="#{bundle.Edit}"
actionListener="#{gaStructNodeController.edit}"
update="GaStructNode_save GaStructNode_listForm:GaStructNode_listForm_btnsPanel :GaStructNode_editForm GaStructNode_listForm:GaStructNode_editTreeForm GaStructNode_listForm_tree"
disabled="#{empty gaStructNodeController.selectedGaStructNode or gaStructNodeController.gaStructNodeEditable}"/>
<p:commandButton id="GaStructNode_listForm_deleteBtn" icon="ui-icon-trash"
title="#{bundle.Delete}"
actionListener="#{gaStructNodeController.destroy}"
update="GaStructNode_listForm :GaStructNode_editForm"
disabled="#{empty gaStructNodeController.selectedGaStructNode or gaStructNodeController.gaStructNodeEditable}">
<p:confirm header="#{bundle.ConfirmDialog_title}"
message="#{bundle.ConfirmDialog_message}" icon="ui-icon-alert"/>
</p:commandButton>
<p:commandButton id="GaStructNode_listForm_refreshBtn" icon="fa fa-refresh"
actionListener="#{gaStructNodeController.refresh}"
update="@form :GaStructNode_editForm"
disabled="#{gaStructNodeController.gaStructNodeEditable}"/>
</p:outputPanel>
</f:facet>
</p:panel>
<p:outputPanel id="GaStructNode_save" style="height: 45px;">
<h:panelGroup id="GaStructNode_editForm_panel"
styleClass="saveCancelBtnPanel" style="display: inline-block;"
rendered="#{gaStructNodeController.selectedGaStructNode != null and gaStructNodeController.gaStructNodeEditable}">
<p:commandButton id="GaStructNode_editForm_save"
disabled="#{gaStructNodeController.selectedGaStructNodeData.unit == null}"
update="@form :GaStructNode_listForm :GaStructNode_picklist_form GaStructNode_editForm"
process="@form GaStructNode_editForm"
actionListener="#{gaStructNodeController.save(false)}"
styleClass="editForm-btns" icon="fa fa-save" onstart="alert('start')" oncomplete="alert('comp')"
title="#{bundle.Save}"/>
<p:commandButton actionListener="#{gaStructNodeController.cancel}"
styleClass="editForm-btns" immediate="true" style="margin-left: 36px"
title="#{bundle.Cancel}" icon="ui-icon-cancel"
update="@form :GaStructNode_editForm :GaStructNode_listForm :GaStructNode_picklist_form"/>
</h:panelGroup>
</p:outputPanel>
</h:form>
</div>
.
.
.
在拖放时:
public void treeOnDrop(TreeDragDropEvent event) {
GaStructNode dropData = (GaStructNode) event.getDropNode().getData();
GaStructNode dragData = (GaStructNode) event.getDragNode().getData();
if(dragData != null) {
dragData.setParent(dropData);
}
}