我正在使用IBM JSF 1.2。 这是主jsp页面的片段:
<hx:panelBox rendered="#{pc_DispositionDOTVC.forEdit.type ne pc_DispositionDOTVC.VIEW}">
<h:outputLabel styleClass="outputLabel" for="selectCargoWarehouse" value="#{msg.lblWarehouse}" />
<h:selectOneMenu id="selectCargoWarehouse" styleClass="selectOneMenu" required="true"
value="#{pc_DispositionDOTVC.forEditCargo.cargo.warehouse.warehouseName}">
<f:selectItems value="#{selectItemsFactory.warehousesByCompanyTerminalSpecial}" />
</h:selectOneMenu>
<h:message styleClass="message" for="selectCargoWarehouse" />
<hx:commandExButton type="submit" styleClass="commandExButton" value="#{msg.buttonAttachNewCargo}" id="cargoButtonAdd">
<hx:behavior event="onclick" behaviorAction="get;show" onActionFunction="openDialog()" id="cargoBehaviorAdd"
targetAction="addCargoDialog;addCargoDialog" /></hx:panelBox>
<hx:panelBox id="helpBox2">
<hx:ajaxRefreshSubmit id="ajaxRefreshSubmitCargo" target="helpBox2" />
</hx:panelBox> <%-- insert new cargo --%>
<jsp:include page="addCargoFromWarehouseDialog.jsp" />
这是对话框jsp页面(addCargoFromWarehouseDialog.jsp):
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
<%-- insert new cargo --%>
<hx:panelDialog type="modal" id="addCargoDialog" styleClass="panelDialog" showTitleCloseButton="false"
onshow="openDialog()" onhide="closeDialog()" noKeybindings="true" title="#{msg.buttonAttachNewCargo}">
<h:panelGroup style="display:block; height:400px; overflow-y:scroll; overflow-x:hidden;" >
<h:panelGrid id="addCargoGrid1" styleClass="panelGrid">
<h:outputText id="cargoText01" styleClass="outputText" value="#{pc_DispositionEditCargoDialog.incomingCargosByWarehouseNameAndCargoCompany}"></h:outputText>
<hx:dataTableEx border="0" cellpadding="2" cellspacing="0" columnClasses="columnClass" headerClass="headerClass"
footerClass="footerClass" rowClasses="rowClass1, rowClass2" id="addCargoTable1"
rendered="#{!empty pc_DispositionEditCargoDialog.incomingCargosByWarehouseNameAndCargoCompany}"
value="#{pc_DispositionEditCargoDialog.incomingCargosByWarehouseNameAndCargoCompany}"
styleClass="dataTableEx2" var="freeCargo">
<hx:columnEx id="cargoColumnEx1">
<f:facet name="header">
<h:outputText id="cargoText01" styleClass="outputText" value="#{msg.lblCargoId}"></h:outputText>
</f:facet>
<h:outputText id="cargoDynText01" styleClass="outputText" value="#{freeCargo.cargoId}"></h:outputText>
</hx:columnEx>
<hx:columnEx id="cargoColumnEx41">
<f:facet name="header">
<h:outputText id="cargoText041" styleClass="outputText" value="#{msg.lblDispositionWeightOfGoods}"></h:outputText>
</f:facet>
<h:outputText id="cargoDynText041" styleClass="outputText" value="#{freeCargo.availableWeightOfGoods}">
<hx:convertNumber maxFractionDigits="2" type="number" pattern="#,###,###,###,##0.00" />
</h:outputText>
</hx:columnEx>
<hx:columnEx id="cargoColumnEx5">
<f:facet name="header">
</f:facet>
<h:panelGroup id="addCargoGroup1" styleClass="buttonGroup">
<h:commandLink id="saveCargoLink1" immediate="true" styleClass="positive"
action="#{pc_DispositionEditCargoDialog.addDispositionCargo}" value="#{msg.buttonAddCargo}">
<f:param id="paramCargoId" name="cargoId" value="#{freeCargo.cargoId}"/>
</h:commandLink>
</h:panelGroup>
</hx:columnEx>
</hx:dataTableEx>
</h:panelGrid>
</h:panelGroup>
<h:panelGroup id="addCargoGroup2" styleClass="buttonGroup">
<hx:commandExButton id="buttonCancelCargoAdd" immediate="true" styleClass="negative" value="#{msg.buttonCancel}"
action="#{pc_DispositionEditCargoDialog.clearCargos}" type="submit">
<hx:behavior event="onclick" behaviorAction="get;hide"
id="cargoBehavior2"
targetAction="subview1:panelForm:helpBox2;subview1:panelForm:addCargoDialog">
</hx:behavior>
</hx:commandExButton>
</h:panelGroup>
</hx:panelDialog>
<hx:ajaxRefreshSubmit id="ajaxRefreshSubmitCargo2" target="addCargoDialog" />
<%-- / insert new cargo --%>
我有一个组合框来选择仓库和按钮来打开对话框,并从仓库中可用货物的货物清单中选择货物。
当我选择有货物的仓库并选择添加货物按钮时,会出现货物清单
当我选择没有货物的仓库时,它会打开一个空的对话框(这没关系)。但是再次选择有货物的仓库,我得到空列表(这是不行的)。如果我单击浏览器刷新按钮,则正常显示货物列表
这只发生在Mozilla Firefox和Chrome中,在IE 11中它可以正常工作
在我看来,jsf ajaxRefreshSubmit无法正常工作
请看一下,非常感谢任何帮助。
提前致谢,
mismas
[EDIT1]: Web控制台或firebug中没有任何异常(当我单击F12时) 这是我在两种情况下都得到的回复(200 POST http://localhost:8080/ExtComConWeb/pages/secure/disposition/dispositionDOTVC.faces?%24%24ajaxid=subview1%3ApanelForm%3AaddCargoDialog&%24%24ajaxmode=axfull):
<div id="subview1:panelForm:addCargoDialog" class="panelDialog" style="position:absolute; display:none;"><div id="subview1:panelForm:addCargoDialog_tb" title="Dodaj teret">Dodaj teret</div><div id="subview1:panelForm:addCargoDialog_ca"><span style="display:block; height:400px; overflow-y:scroll; overflow-x:hidden;"> <table id="subview1:panelForm:addCargoGrid1" class="panelGrid">
<tbody>
<tr>
<td><span id="subview1:panelForm:cargoText01" class="outputText"> [hr.combis.comcon.persistency.hibernate.impl.crg.Cargo@58996c54, hr.combis.comcon.persistency.hibernate.impl.crg.Cargo@2468c3d]</span></td>
</tr>
<tr>
<td><table id="subview1:panelForm:addCargoTable1" class="dataTableEx2" border="0" cellpadding="2" cellspacing="0" ><thead ><tr ><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText01" class="outputText">Broj tereta</span></th><th class="headerClass" scope="col" ><span class="outputText">K447</span></th><th class="headerClass" scope="col" ><span class="outputText">JCD</span></th><th class="headerClass" scope="col" ><span class="outputText">MRN</span></th><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText02" class="outputText">Standardni opis tereta</span></th><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText031" class="outputText">Br.ul. disp.</span></th><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText03" class="outputText">Tip pakiranja</span></th><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText04" class="outputText">Tip mjere</span></th><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText041" class="outputText">Težina robe</span></th><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText042" class="outputText">Volumen</span></th><th class="headerClass" scope="col" ><span id="subview1:panelForm:addCargoTable1:cargoText043" class="outputText">Komada</span></th><th class="headerClass" scope="col" ><img src="/ExtComConWeb/.ibmjsfres/img/1x1.gif" ></img></th></tr>
</thead><tbody >
<tr class="rowClass1" ><td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText01" class="outputText">72369</span></td>
<td class="columnClass" ><span class="outputText"></span></td>
<td class="columnClass" ><span class="outputText"></span></td>
<td class="columnClass" ><span class="outputText"></span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText02" class="outputText">Antracit</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText031" class="outputText">00007/06/2015</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText03" class="outputText">Nepakirani</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText04" class="outputText">Mjeren po volumenu</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText041" class="outputText">121,00</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText042" class="outputText">1.465,000</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:cargoDynText043" class="outputText">12</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:0:addCargoGroup1" class="buttonGroup"><a id="subview1:panelForm:addCargoTable1:0:saveCargoLink1" href="#" onclick="if(typeof jsfcljs == 'function') {jsfcljs(document.getElementById('subview1:panelForm'),{'subview1:panelForm:addCargoTable1:0:saveCargoLink1':'subview1:panelForm:addCargoTable1:0:saveCargoLink1','cargoId':'72369'},'');}return false" class="positive">Dodaj teret</a></span></td>
</tr>
<tr class="rowClass2" ><td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText01" class="outputText">72454</span></td>
<td class="columnClass" ><span class="outputText"></span></td>
<td class="columnClass" ><span class="outputText"></span></td>
<td class="columnClass" ><span class="outputText"></span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText02" class="outputText">Banane</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText031" class="outputText">00014/06/2015</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText03" class="outputText">Palete</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText04" class="outputText">Mjeren na komade</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText041" class="outputText">1.213,00</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText042" class="outputText">121,000</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:cargoDynText043" class="outputText">12</span></td>
<td class="columnClass" ><span id="subview1:panelForm:addCargoTable1:1:addCargoGroup1" class="buttonGroup"><a id="subview1:panelForm:addCargoTable1:1:saveCargoLink1" href="#" onclick="if(typeof jsfcljs == 'function') {jsfcljs(document.getElementById('subview1:panelForm'), {'subview1:panelForm:addCargoTable1:1:saveCargoLink1':'subview1:panelForm:add CargoTable1:1:saveCargoLink1','cargoId':'72454'},'');}return false" class="positive">Dodaj teret</a></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</span><span id="subview1:panelForm:addCargoGroup2" class="buttonGroup"> <input type="submit" value="Odustani" id="subview1:panelForm:buttonCancelCargoAdd" name="subview1:panelForm:buttonCancelCargoAdd" class="negative" /></span> </div></div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id103:j_id105" /><script type="text/javascript">
hX_6.addComponent("subview1:panelForm:addCargoDialog", new hX_6.JSFDialog("no-keybindings:true", "onshow:openDialog()", "onhide:closeDialog()"));
hX_6.addBehavior("subview1:panelForm:buttonCancelCargoAdd", "onclick", new hX_6.JSFBehaviorGeneric("action:get;hide", "target:subview1:panelForm:helpBox2;subview1:panelForm:addCargoDialog"));
if(hX_6.getBehaviorById("subview1:panelForm:addCargoDialog", "ajaxsubmit", "onget"))hX_6.getBehaviorById("subview1:panelForm:addCargoDialog", "ajaxsubmit", "onget").setAttribute("href:/ExtComConWeb/pages/secure /disposition /dispositionDOTVC.faces?$$ajaxid=subview1:panelForm:addCargoDialog&$$ajaxmode =axfull");
</script>
不同的是,如果选择仓库的货物,在空的货物之后,我不会得到结果表...
在其他情况下,当第一次选择有货物的仓库时,它工作正常......我看不出会导致货物清单无法呈现的差异......
请帮忙......
[EDIT2]
我也注意到在打印pc_DispositionEditCargoDialog.incomingCargosByWarehouseNameAndCargoCompany列表时:
<h:outputText id="cargoText01" styleClass="outputText" value="# {pc_DispositionEditCargoDialog.incomingCargosByWarehouseNameAndCargoCompany}" ></h:outputText>
我明白了:
当仓库有货物时:[hr.combis.comcon.persistency.hibernate.impl.crg.Cargo@71b78ef4,hr.combis.comcon.persistency.hibernate.impl.crg.Cargo@517ce92d]
[]当仓库有货物时,但是在没有货物的仓库之后点击。这很奇怪,因为响应有货物清单,我知道服务器端功能getIncomingCargosByWarehouseNameAndCargoCompany也返回非空列表。我无法理解为什么这个列表没有呈现......
[EDIT3]
我注意到当从addCargoFromWarehouseDialog.jsp中删除helpBox2时,货物表通常会在对话框中呈现。
这是从addCargoFromWarehouseDialog.jsp(删除了helpBox2项)改变了一段代码:
<h:panelGroup id="addCargoGroup2" styleClass="buttonGroup">
<hx:commandExButton id="buttonCancelCargoAdd" immediate="true" styleClass="negative" value="#{msg.buttonCancel}"
action="#{pc_DispositionEditCargoDialog.clearCargos}" type="submit">
<hx:behavior event="onclick" behaviorAction="hide"
id="cargoBehavior2"
targetAction="subview1:panelForm:addCargoDialog">
</hx:behavior>
</hx:commandExButton>
但现在,点击取消按钮后,我重新加载了整个页面。之前,当使用helpBox2时,单击取消按钮将使用ajax再执行一次POST,因此孔页面不会再次重新加载。
任何人都可以建议如何实现这种影响,而不必使用这个helpBox2技巧?或者如何改变它以免干扰货物表渲染?
这是带有ajax的附加POST的响应:
<table id="subview1:panelForm:helpBox2"><tr><td></td></tr></table> <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id104:j_id120" /><script type="text/javascript">
if(hX_6.getBehaviorById("subview1:panelForm:helpBox2", "ajaxsubmit", "onget"))hX_6.getBehaviorById("subview1:panelForm:helpBox2", "ajaxsubmit", "onget").setAttribute("href:/ExtComConWeb/pages/secure/disposition /dispositionDOTVC.faces?$$ajaxid=subview1:panelForm:helpBox2&$$ajaxmode=axfull");
</script>
我也注意到这种行为真的很奇怪 如果我先做空仓库 - 工程,那么全部工作 但是全部工作,空洞的工作,全部工作,没有工作 我不明白,这里的诀窍是什么?
请帮忙。谢谢!