在渲染panelDialog时,不会调用渲染bean方法吗?

时间:2016-08-30 15:01:25

标签: jsf

我正在使用ibm jsf 1.2。我有主要形式的按钮。按下按钮时,将打开一个新的面板对话框,其中包含一个应根据某些验证进行渲染的字段。

这是我的.jsp文件:

<hx:jspPanel>
<fieldset>
<h:panelGrid
<hx:commandExButton type="button"
value="#{msg.buttonAddContainer}" id="chooseContainerButton">
<hx:behavior event="onclick" behaviorAction="get;show"
id="behavior2" targetAction="gridListContainers;containerDialog" />
</hx:commandExButton>
</h:panelGrid>
</fieldset>
</hx:jspPanel>


<hx:panelDialog type="modal" id="containerDialog"
noKeybindings="true" showTitleCloseButton="false"
onshow="openDialog()" onhide="closeDialog()"
styleClass="panelDialog" title="#{msg.lblContainer}">

<h:panelGrid id="gridContainerNumber">
<h:outputLabel for="inputContainerNumber"></h:outputLabel>
<h:inputText id="inputContainerNumber" styleClass="inputText">
<!-- some other field - container number-->
<h:message for="inputContainerNumber" id="messageInputContainerNumber">    </h:message>

<h:outputLabel id="labelInputBookingNumber" styleClass="outputLabel"
for="inputBookingNumber" value="#{msg.lblBookingNumber}" 
    rendered="#{myBean.isBookingNumberRendered}">
</h:outputLabel>
<h:inputText id="inputBookingNumber" immediate="true"
value="#{myBean.bookingNumber}"
rendered="#{myBean.isBookingNumberRendered}" styleClass="inputText">
</h:inputText>
<h:message id="mesageInputBookingNumber"
styleClass="message" for="inputBookingNumber"
rendered="#{myBean.isBookingNumberRendered}">
</h:message>
</h:panelGrid>

<h:panelGroup id="groupClear" styleClass="buttonGroup">
<hx:commandExButton id="submitButton"
styleClass="positive"
action="#{myBean.saveContainer}"
type="submit" immediate="true" value="#{msg.buttonSave}">
</hx:commandExButton>
<hx:commandExButton id="cancelButton"
styleClass="negative"
action="#{myBean.clearContainer}"
type="submit" immediate="true" value="#{msg.buttonCancel}">
<hx:behavior event="onclick" behaviorAction="get;hide" id="behavior6"
targetAction="helpBox1;containerDialog"></hx:behavior>
</hx:commandExButton>
</h:panelGroup>

<hx:ajaxRefreshSubmit target="gridListContainers" id="ajaxSubmit1"
onstart="showProgressBar();" oncomplete="hideProgressBar();">
</hx:ajaxRefreshSubmit>
</hx:panelDialog>  

在panelDialog上呈现的行为并不像我期望的那样。当对话框第一次打开时,不会调用渲染检查方法isBookingNumberRendered,因此在满足验证标准时不会显示预订编号字段。当我在dialogPanel上输入另一个字段并点击Save按钮(调用isBookingNumberRendered)然后再次点击选择containerButton时,会显示该字段。
为什么在呈现panelDialog时第一次调用isBookingNumberRendered方法? 请帮忙。

最好的问候,
mismas

1 个答案:

答案 0 :(得分:0)

我想通了:) 我有:

<hx:behavior event="onclick" behaviorAction="get;show"
id="behavior2" targetAction="gridListContainers;containerDialog" />

其中gridListContainers,其中不是面板网格<h:panelGrid id="gridContainerNumber">的id 所以我刚刚将它更改为<h:panelGrid id="gridListContainers">并且工作正常 没有任何抱怨是非常忘恩负义的,你只是得到了奇怪的行为......