Visualforce中的if-else条件块

Ply*_*ock 5 salesforce visualforce

我在jsp中使用c:if,c:when JSTL标签。但是我不知道视觉力页面是否可以使用类似的功能。仅举例来说,我为jsp提供了示例代码。-

    <h1>A Demo conditional section code</h1>
    <c:choose>
       <c:when test="${param.colorField == 'red'}">
         <table border="0" width="150" height="50" bgcolor="#ff0000">
           <tr><td>It is red</td></tr>
         </table>
      </c:when>
      <c:when test="${param.colorField == 'blue'}">
       <table border="0" width="150" height="50" bgcolor="#0000ff">
         <tr><td>It is blue</td></tr>
      </table>
    </c:when>
    <c:when test="${param.colorField == 'green'}">
        <table border="0" width="150" height="50" bgcolor="#00ff00">
          <tr><td>Green table</td></tr>
        </table>
    </c:when>
    <c:otherwise>
      <table border="0" width="150" height="50" bgcolor="#000000">
        <tr><td>No colour changed</td></tr>
       </table>
    </c:otherwise>
</c:choose>
<br/>
and other codes....
Run Code Online (Sandbox Code Playgroud)

我在vf页面中缺少这种页面阻止准备。

Ply*_*ock 7

我发现我们可以<apex:outputpanel>对任何块使用outputpanel(),并使用该rendered属性来处理加载它的条件。

<h1>A Demo conditional section code</h1>
    <apex:outputpanel rendered="{!param.colorField == 'red'}">
         <table border="0" width="150" height="50" bgcolor="#ff0000">
           <tr><td>It is red</td></tr>
         </table>
    </apex:outputpanel>
    <apex:outputpanel rendered="{!param.colorField == 'blue'}">
       <table border="0" width="150" height="50" bgcolor="#0000ff">
         <tr><td>It is blue</td></tr>
      </table>
    </apex:outputpanel>
    :
    :
and other codes....
Run Code Online (Sandbox Code Playgroud)