Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

I had used c: if, c: when JSTL tags in JSP. But I don't know if anything similar is available for visual force pages. just, for example, I am providing sample code for 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....

I am missing this kind of page block preparation in vf pages.

1 Answer

0 votes
by (32.1k points)

You can use some logical functions and operators in Visualforce.

A logical Functions list is needed, which has the same code in VF as given below:

{!IF(salary<=0, "Salary is very low to survive.", "No comment sir")} 

...