11package com .baeldung .springintegration .controllers ;
22
33import javax .annotation .PostConstruct ;
4+ import javax .el .ELContextEvent ;
5+ import javax .el .ELContextListener ;
46import javax .el .LambdaExpression ;
57import javax .faces .application .Application ;
68import javax .faces .application .FacesMessage ;
79import javax .el .LambdaExpression ;
810import javax .faces .bean .ManagedBean ;
911import javax .faces .bean .ViewScoped ;
1012import javax .faces .context .FacesContext ;
13+ import java .util .Collection ;
1114import java .util .Random ;
1215
1316@ ManagedBean (name = "ELBean" )
@@ -16,7 +19,6 @@ public class ELSampleBean {
1619
1720 private String firstName ;
1821 private String lastName ;
19- private Collection <Integer > numberList ;
2022 private String pageDescription = "This page demos JSF EL Basics" ;
2123 public static final String constantField = "THIS_IS_NOT_CHANGING_ANYTIME_SOON" ;
2224 private int pageCounter ;
@@ -25,22 +27,28 @@ public class ELSampleBean {
2527 @ PostConstruct
2628 public void init () {
2729 pageCounter = randomIntGen .nextInt ();
30+ FacesContext .getCurrentInstance ().getApplication ().addELContextListener (new ELContextListener () {
31+ @ Override
32+ public void contextCreated (ELContextEvent evt ) {
33+ evt .getELContext ().getImportHandler ().importClass ("com.baeldung.springintegration.controllers.ELSampleBean" );
34+ }
35+ });
2836 }
2937
3038 public void save () {
3139
3240 }
3341
34- public static String getConstantField () {
42+ public static String constantField () {
3543 return constantField ;
3644 }
3745
3846 public void saveFirstName (String firstName ) {
3947 this .firstName = firstName ;
4048 }
4149
42- public String multiplyValue (LambdaExpression expr ){
43- String theResult = (String ) expr .invoke (FacesContext .getCurrentInstance ().getELContext (), pageCounter );
50+ public Long multiplyValue (LambdaExpression expr ) {
51+ Long theResult = (Long ) expr .invoke (FacesContext .getCurrentInstance ().getELContext (), pageCounter );
4452 return theResult ;
4553 }
4654
0 commit comments