在CommandLink中使用时不会触发操作行为

时间:2012-05-16 18:59:50

标签: java jsf-2 primefaces facelets

我遇到了使用<p:commandLink>的问题,我使用了

<p:commandLink action="#{commonOrgPage.preCreateCommonOrg}" 
               immediate="true" 
               update=":createCommonOrgForm:addCommonOrg" 
               oncomplete="addDlg.show();"> 

要显示一个Add对话框,在它之前,我应该调用action并更新对话框。但现在不调用该操作并显示对话框。

homepage.xhtml     

    <ui:define name="mainLayoutTitle">Home Page</ui:define>
    <ui:define name="bodyName">
        <ui:decorate template="/pages/commons/layouts/contentLayout.xhtml">
            <ui:define name="leftContentName">
                <ui:include src="/maintainCodeMenu.xhtml"></ui:include>
            </ui:define>
            <ui:define name="rightContentName">
                    <p:outputPanel id="rightContentPanel" >
                        <p:outputPanel rendered="${commonOrgPage.commonOrgTypeName !=null}">
                            <ui:include src="/pages/admin/commonorg/viewCommonOrgList.xhtml"></ui:include>
                        </p:outputPanel>
                    </p:outputPanel>
            </ui:define>
        </ui:decorate>
    </ui:define>    

</ui:composition>

maintainCodeMenu.xhtml

<h:form id="codeMenu">
<div>Common Organisations</div>
<p:separator />
<div>
    <p:commandLink id="Bank" value="Add Bank" action="#{commonOrgPage.listCommonOrgByCriteria}"
            update=":rightContentPanel" ajax="false">
        <f:param name="commonOrgTypeCode" value="B" />
        <f:param name="commonOrgTypeName" value="Bank"/>        
    </p:commandLink>
</div>  
<div>
    <p:commandLink id="School" value="Add School" action="#{commonOrgPage.listCommonOrgByCriteria}"
            update=":rightContentPanel" >
        <f:param name="commonOrgTypeCode" value="SH" />
        <f:param name="commonOrgTypeName" value="School"/>      
    </p:commandLink>
</div>
</h:form>
</ui:composition>

viewCommonOrgList.xhtml

<h:form id="commonOrgList">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td class="pgHdr">
                <div style="float: right">
                    <p:commandLink action="#{commonOrgPage.preCreateCommonOrg}" immediate="true" update=":createCommonOrgForm:addCommonOrg" oncomplete="addDlg.show();" styleClass="button">
                        <span>Add</span>
                    </p:commandLink>
</div></td></tr></tbody></table></h:form>
<p:dialog header="Add Common Organisation"  appendToBody="true" draggable="false" widgetVar="addDlg" resizable="false" id="addDialog" showEffect="fade" modal="true" >
    <h:form id="createCommonOrgForm">
    <h:panelGroup id="addCommonOrg">
    <ui:include src="/pages/admin/commonorg/createOrUpdateCommonOrg.xhtml"></ui:include>
    </h:panelGroup>
    </h:form>
</p:dialog>

预览问题已解决,因为将PageBean范围设置为“session”。但是,如果我放置<h:outputFormat value="#{commonOrgPage.commonOrgTO.orgEffectiveFrom}"/>而不是

,则会出现另一个问题
<ui:include src="/pages/admin/commonorg/createOrUpdateCommonOrg.xhtml"></ui:include>

我们可以在调用#{commonOrgPage.preCreateCommonOrg}操作后获取新值。但是当我们使用<ui:include>时,对话框无法获得新值。

0 个答案:

没有答案