Comparing EL with equalIgnoreCase

How to check equalIgnoreCase in EL?

String a = "hello"; a.equalsIgnoreCase("hello"); 

Now on the JSP page ..

 <h:panelGroup rendered="#{patientNotePrescriptionVar.prescriptionSchedule == patientNotePresBackingBean.sendPrescription}"> ... Some code here .... </h:panelGroup> 

Is there a way to map patientNotePresBackingBean.sendPrescription as equalIgnoreCase?

+6
source share
2 answers

If you are using EL 2.2 (part of Servlet 3.0) or JBoss EL, then you should just call this method in EL.

 <h:panelGroup rendered="#{patientNotePrescriptionVar.prescriptionSchedule.equalsIgnoreCase(patientNotePresBackingBean.sendPrescription)}"> 

If you are not already in EL 2.2, then the best option would be to pass both lines through JSTL fn:toLowerCase() (or fn:toUpperCase() ), and then compare it.

 <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ... <h:panelGroup rendered="#{fn:toLowerCase(patientNotePrescriptionVar.prescriptionSchedule) == fn:toLowerCase(patientNotePresBackingBean.sendPrescription)}"> 

It would be better, however, not to make them case sensitive. If they represent any constants, it is better to make them enumerations or something else.

+17
source

You can convert both operands to lowercase and then equate them.

In the case of JSTL, I would do

 fn:toLowerCase(patientNotePrescriptionVar.prescriptionSchedule) eq fn:toLowerCase(patientNotePresBackingBean.sendPrescription) 

Just check if you can do something like this in JSF. I'm sorry that I was away from the JSF.

+3
source

Source: https://habr.com/ru/post/916094/


All Articles