The representation of if-elseif-else in EL using JSF

后端 未结 4 1493
我在风中等你
我在风中等你 2020-12-09 14:44

The following JSF code contains two separate . Let\'s look at it.


<         


        
相关标签:
4条回答
  • 2020-12-09 15:17

    One possible solution is:

    <h:panelGroup rendered="#{bean.row == 10}">
        <div class="text-success">
            <h:outputText value="#{bean.row}"/>
        </div>
    </h:panelGroup>
    
    0 讨论(0)
  • 2020-12-09 15:20

    You can use "ELSE IF" using conditional operator in expression language as below:

     <p:outputLabel value="#{transaction.status.equals('PNDNG')?'Pending':
                                         transaction.status.equals('RJCTD')?'Rejected':
                                         transaction.status.equals('CNFRMD')?'Confirmed':
                                         transaction.status.equals('PSTD')?'Posted':''}"/>
    
    0 讨论(0)
  • 2020-12-09 15:23

    You can use EL if you want to work as IF:

    <h:outputLabel value="#{row==10? '10' : '15'}"/>
    

    Changing styles or classes:

    style="#{test eq testMB.test? 'font-weight:bold' : 'font-weight:normal'}"
    
    class="#{test eq testMB.test? 'divRred' : 'divGreen'}"
    
    0 讨论(0)
  • 2020-12-09 15:28

    The following code the easiest way:

     <h:outputLabel value="value = 10" rendered="#{row == 10}" /> 
     <h:outputLabel value="value = 15" rendered="#{row == 15}" /> 
     <h:outputLabel value="value xyz" rendered="#{row != 15 and row != 10}" /> 
    

    Link for EL expression syntax. http://developers.sun.com/docs/jscreator/help/jsp-jsfel/jsf_expression_language_intro.html#syntax

    0 讨论(0)
提交回复
热议问题