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:
- create own
javax.el.elresolver, methods can return null/false. - open source of class
org.apache.myfaces.el.unified.resolver.scopedattributeresolver, copy methodsfacescontext(elcontext),findscopedmap(facescontext, object)(sincescopedattributeresolverfinal, can't extend it). 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; }edit
faces-config.xmlregister resolver:<application> <el-resolver>com.mypackage.debugelresolver</el-resolver> </application>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>- 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
Post a Comment