Visualforce页面apex:commandXXXX的rerender使用注意事项

Visualforce页面apex:commandXXXX的rerender使用注意事项


 rerender 可以指定页面重画区域,这个其实就是visualforce中的AJAX 技术。

但是,要保证这个有效果,有些注意事项。

1. rerender可以指定的区域,目前只发现apex:outputpanel 标记好用。 用DIV的话不行。

   通常的写法例子如下:

<apex:page controller="SearchController">

<apex:form>
    <apex:inputText value="{! freeWord }" size="60" />
    <apex:commandLink value=" 搜索 " title=" 搜索 " rerender="opSearchResultByFreeWord"
       id="searchBtn" action="{! doFreeWordSearch }" />

    <!-- 下面是显示搜索结果的区域 -->
    <apex:outputPanel id="opSearchResultByFreeWord">
        <apex:pageBlock id="resultBlock"  >
            <apex:pageBlockTable value="{! searchRsltByFreeWord }" var="item"
                <apex:column headerValue="名称" >
                    <apex:outputField value="{!item.name}" />
                </apex:column>
                <apex:column headerValue="说明" >
                    <apex:outputField value="{!item.describe__c}" />
                </apex:column>
           </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:outputPanel>

</apex:form>
</apex:page>

2. 如果outputPanel里面有rendered指定的话,这个区域也是没有办法重画的。

 简单的处理办法是,在这个outputPanel外面再嵌套一层outputPanel,并设置Id,这样就可以用了。


猜你喜欢

转载自blog.csdn.net/sitebus/article/details/52814742