eclipse - Show warning when EL not found -


i'm creating jsf applikation , kind of warning (preferably console) if make typos in el-expression.

example: on page wanted show text localized. locale-config in faces-config.xml set , works var 'msgs'.

i used code on page:

<h:outputtext value="#{msg.title_edit_customer}"/> 

when checked page in browser, nothing got showed. took me while realize made typo - #{msgs.... worked expected.

can activate kind of debug-output, can see directly there invalid el somewhere?

my setup: eclipse 4.4.2, tomcat 8, myfaces 2.2.8

thanks @sjuan76 figure out:

  1. create own javax.el.elresolver, methods can return null/false.
  2. open source of class org.apache.myfaces.el.unified.resolver.scopedattributeresolver , copy methods facescontext(elcontext) , findscopedmap(facescontext, object) (since scopedattributeresolver final, can't extend it).
  3. edit getvalue-method:

    @override public object getvalue(elcontext context, object base, object property) {     if(!context.ispropertyresolved()){       //douple check false-positives       boolean foundinscope = false;       final map<string, object> scopedmap = findscopedmap(             facescontext(context), property);       if (scopedmap != null) {         object object = scopedmap.get(property);         if (object != null) {             foundinscope = true;         }       }       if (!foundinscope) {         log.warn(string.format("el-property %s couldn't resolved",                 property));     } }     return null; } 
  4. edit faces-config.xml register resolver:

    <application> <el-resolver>com.mypackage.debugelresolver</el-resolver> </application>

  5. since there many resolvers , each 1 little bit of resolving, our new resolver should come last. add following web.xml:

    <context-param> <param-name>org.apache.myfaces.el_resolver_comparator</param-name> <param-value>org.apache.myfaces.el.unified.customlastelresolvercomparator</param-value> </context-param>

  6. now you'll log-output, every time expression couldn't resolved:

03.07.2015 07:34:21 com.mypackage.debugelresolver [http-nio-8080-exec-2] warn el-property msgx couldn't resolved

i couldn't figure out how actual el-expression (e.g. #{msgx.title_edit_customer}.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -