我有一个丰富的:模态面板(下面的代码)。我想将#{currentLeg}
传递给action="#{legHandler.assignAndInitLoadPlanning}
中调用的方法。但是当我调试时,在方法legHandler.assignAndInitLoadPlanning
,resolveVariable("currentLeg");
返回一个对象,其所有属性值都等于null。它的属性不应为null。
此外,在同一个jsp文件中从a4j:commandLink onclick="showUnitDialog();
调用此rich:modal。如果我改变这个说onclick到onclick="#{legHandler.assignAndInitLoadPlanning}"
currentleg将正确传递但我不能这样做因为我需要有一个弹出窗口(这是一个rich:modalpanel
)来显示。我正在使用JSF 1。
我已经尝试过保持活力并设置变量,但仍然不起作用。似乎currentLeg
未正确通过。你知道为什么吗?
<rich:modalPanel id="unitDialog" width="400" height="100">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Please Select Unit for the Leg"></h:outputText>
<h:outputText value="#{currentLeg.legId}"></h:outputText>
</h:panelGroup>
</f:facet>
<h:panelGrid width="100%" columns="2" columnClasses="colStyle1, colStyle2">
<h:selectOneRadio value="legHandler.unit">
<f:selectItem itemValue="kg" itemLabel="kg" />
<f:selectItem itemValue="lb" itemLabel="lb" />
</h:selectOneRadio>
</h:panelGrid>
<h:panelGrid style="text-align: center" columns="3"
columnClasses="col1, col2" width="100%">
<a4j:commandButton value="Apply" styleClass="big_btn"
id="applyButton" immediate="true"
action="#{legHandler.assignAndInitLoadPlanning}"
oncomplete="{#{rich:component('unitDialog')}.hide();}">
</a4j:commandButton>
<a4j:commandButton value="Cancel" styleClass="big_btn"
immediate="true"
id="closeUnitPopupDialog"
onclick="#{rich:component('unitDialog')}.hide();"/>
</h:panelGrid>
</rich:modalPanel>
答案 0 :(得分:0)
如果你正在使用EL 2.2+,你可以简单地将值作为参数传递:
<a4j:commandButton action="#{legHandler.assignAndInitLoadPlanning(currentLeg)}" … />
否则使用a4j:actionparam
并将值保存到bean
<a4j:commandButton …>
<a4j:actionparam name="currentLeg" value="#{currentLeg}" assignTo="#{legHandler.currentLeg}" />
<a4j:commandButton>