apex:commandButton在apex:panelBar中

时间:2012-07-20 00:50:19

标签: controller action salesforce apex-code visualforce

我有一个项目列表,我在panelBar中显示,每个项目都有一个调用控制器上的动作的comandButton,问题是动作方法永远不会被调用! 帮助

以下是代码:

<apex:panelBar id="eventBarSeller" switchType="client" items="{!relatedEventsSeller}" var="event" rendered="true">
    <apex:panelbarItem label="{!event.SUBJECT__c}">
        <apex:outputText escape="false" value="{!event.BODY__c}" />
        <br/>
        <br/>
        <apex:commandButton value="View details" action="{!showPopup}" rerender="popup" immediate="true" rendered="true"/>
    </apex:panelBarItem>
</apex:panelbar>

弹出outputPanel:

<apex:outputPanel id="popup">
       <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopup}"/>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopup}">
                This is where I would put whatever information I needed to show to my end user.<br/><br/><br/>
                <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="popup"/>
       </apex:outputPanel>
</apex:outputPanel>

在控制器中我有以下内容:

public boolean displayPopup {get; set;}     

public void closePopup() {
    System.Debug(LoggingLevel.INFO, 'Close Popup...');
    displayPopup = false;    
}

public void showPopup() {
    System.Debug(LoggingLevel.INFO, 'Show Popup...');
    displayPopup = true;
}

函数showPopup从未被调用因为我签入了日志,会发生什么? 提前谢谢!

2 个答案:

答案 0 :(得分:0)

不确定,但您可能会尝试将switchtype从客户端更改为服务器或ajax:

<apex:panelBar id="eventBarSeller" switchType="server/ajax" items="{!relatedEventsSeller}" var="event" rendered="true">

Server和ajax switchTypes可能比客户端慢一点,但它应该可靠地处理服务器端操作方法。 rerender属性受此影响。来自VF开发人员指南:

enter image description here

答案 1 :(得分:0)

试试这个(适合我):

页:

<apex:form>

    <apex:panelBar>
        <apex:panelbarItem>
            <apex:commandButton value="View details" action="{!showPopup}" reRender="myPopup"/>
        </apex:panelBarItem>
    </apex:panelbar>

    <apex:outputPanel id="myPopup">
           <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopup}">
                    Your Information Here
           </apex:outputPanel>
    </apex:outputPanel>

</apex:form>

控制器:

public Boolean displayPopup { get; set; }

public PageReference showPopup() {
    System.Debug(LoggingLevel.INFO, 'Show Popup...');
    displayPopup = true;
    return null;
}