|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.jakubholy.jeeutils.jsfelcheck.JsfStaticAnalyzer
public class JsfStaticAnalyzer
Perform analysis of (selected) JSF 1.1 JSP files and validate that all EL expressions reference only existing managed beans and their properties/action methods.
For local variables, such as the var produced by h:dataTable, you
must first declare of what type they are as this cannot be determined based
on the code, see
DataTableVariableResolver.declareTypeFor(String, Class).
If there are some EL variables aside of managed beans in faces-config (and
perhaps Spring config) and the local variables you can declare them to the
validator via JsfElValidator.declareVariable(String, Object).
If there are other tags than h:dataTable that can create local variables, you must create and register an appropriate resolver for them as is done with the dataTable.
MockObjectOfUnknownType - if you see it in a failed JSF EL check then you need
to declare the type to use.
- JSF 1.1 (switching to another one requires replacing the Sun's ValueBindingFactory and MethodBindingFactory used by theJsfElValidatorby appropriate alternatives). - Currently it's assumed that a tag can declare only 1 local variable (var in dataTable). - Included files (statically or dynamically) are processed without taking their inclusion into account, i.e. variables defined in the including page aren't available when checking them. We have though all the information for taking inclusions into account available, it would just require more work (filter the included files out not to be processed as top-level files and when an inclusion tag is encountered, process the included file passing the current context on; seeJsfElCheckingVisitorand org.apache.jasper.compiler.Node.Visitor.visit(IncludeAction) , org.apache.jasper.compiler.Node.Visitor.visit(IncludeDirective)).
| Nested Class Summary | |
|---|---|
static class |
JsfStaticAnalyzer.ExpressionFailure
|
| Constructor Summary | |
|---|---|
JsfStaticAnalyzer()
|
|
| Method Summary | |
|---|---|
void |
addElExpressionFilter(ElExpressionFilter elExpressionFilter)
Used to ignore some expressions, i.e. not to validate them. |
Collection<File> |
getFacesConfigFiles()
|
String |
getJspsToIncludeCommaSeparated()
|
Collection<File> |
getSpringConfigFiles()
|
boolean |
isPrintCorrectExpressions()
|
boolean |
isSuppressOutput()
|
static void |
main(String[] args)
|
void |
setFacesConfigFiles(Collection<File> facesConfigFiles)
The faces-config.xml files to read managed beans from. |
void |
setJspsToIncludeCommaSeparated(String jspsToIncludeCommaSeparated)
Process only the given files; set to null to process all. |
void |
setPrintCorrectExpressions(boolean printCorrectExpressions)
|
void |
setSpringConfigFiles(Collection<File> springConfigFiles)
The Spring application context XML files to read managed beans from. |
void |
setSuppressOutput(boolean suppressOutput)
True - do not print results to the standard output / error stream. |
CollectedValidationResults |
validateElExpressions(String jspDir,
Map<String,Class<?>> localVariableTypes,
Map<String,Class<?>> extraVariables,
Map<String,Class<?>> propertyTypeOverrides)
Check expressions in all JSP files under the jspDir and print the failed (or all) ones to System out. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JsfStaticAnalyzer()
| Method Detail |
|---|
public CollectedValidationResults validateElExpressions(String jspDir,
Map<String,Class<?>> localVariableTypes,
Map<String,Class<?>> extraVariables,
Map<String,Class<?>> propertyTypeOverrides)
Notion: Variable - the first element in an EL expression; property: any but the first element. Example: #{variable.propert1.property2['some.key']}
jspDir - (required) where to search for JSP pageslocalVariableTypes - (required) type definitions for local EL variables such as
produced by h:dataTable, see
DataTableVariableResolver.declareTypeFor(String, Class)extraVariables - (required) extra variables/managed beans not defined in
faces-context, see
JsfElValidator.declareVariable(String, Object)propertyTypeOverrides - (required) override the type to use for a property; mostly
useful for properties where the proper type cannot be derived
such as a Collection, see
JsfElValidator.definePropertyTypeOverride(String, Class)
Exceptionpublic void addElExpressionFilter(ElExpressionFilter elExpressionFilter)
elExpressionFilter - (required)
public static void main(String[] args)
throws Exception
Exceptionpublic void setPrintCorrectExpressions(boolean printCorrectExpressions)
public boolean isPrintCorrectExpressions()
public void setJspsToIncludeCommaSeparated(String jspsToIncludeCommaSeparated)
public String getJspsToIncludeCommaSeparated()
public void setFacesConfigFiles(Collection<File> facesConfigFiles)
public Collection<File> getFacesConfigFiles()
public void setSpringConfigFiles(Collection<File> springConfigFiles)
public Collection<File> getSpringConfigFiles()
public void setSuppressOutput(boolean suppressOutput)
public boolean isSuppressOutput()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||