H
hughes.matt
JSTL is large improvement over JSP scriptlets but one thing that I find
missing is the lack of type safety. Sometimes this can be a nice
thing...you get elements out of a map or out of an object, it doesn't
matter. But when I am working with one of my program's domain objects,
whose getter/setter methods are likely to change over time, I want to
be notified that my JSTL will break.
i.e.
I have a bean called Foo
class Foo {
String getBar() {}
void setBar(String) {}
}
In my JSP code I access a bean called fooBar1 that was stored in the
request context:
<body>
The value of bar in Foo is ${fooBar1.bar}.
</body>
Now...what happens if I changed getBar() to getBarrista(). With
today's IDE's like Eclipse, the IDE will change every method call in
your project to reflect the new name change, but JSTL has no idea it is
even dealing with the class Foo. It is just using reflection.
Is there anyway to give the JSTL a hint that I want it to check
type-saftey and name-safety when I want it to. Something like a JSP
declaration at the top of the page indicating the type
--------------------------
<%@page declareVarType scope="request" varName="fooBar1"
type="com.matt.Foo" @%>
<body>
The value of bar in Foo is ${fooBar1.bar}.
</body>
--------------------------
That way, when Jasper went to generate the JSP source code, and then
compile it, I would get a failure right there and then know I need to
change the method. Basically I want a compile-time check, not a
run-time check.
missing is the lack of type safety. Sometimes this can be a nice
thing...you get elements out of a map or out of an object, it doesn't
matter. But when I am working with one of my program's domain objects,
whose getter/setter methods are likely to change over time, I want to
be notified that my JSTL will break.
i.e.
I have a bean called Foo
class Foo {
String getBar() {}
void setBar(String) {}
}
In my JSP code I access a bean called fooBar1 that was stored in the
request context:
<body>
The value of bar in Foo is ${fooBar1.bar}.
</body>
Now...what happens if I changed getBar() to getBarrista(). With
today's IDE's like Eclipse, the IDE will change every method call in
your project to reflect the new name change, but JSTL has no idea it is
even dealing with the class Foo. It is just using reflection.
Is there anyway to give the JSTL a hint that I want it to check
type-saftey and name-safety when I want it to. Something like a JSP
declaration at the top of the page indicating the type
--------------------------
<%@page declareVarType scope="request" varName="fooBar1"
type="com.matt.Foo" @%>
<body>
The value of bar in Foo is ${fooBar1.bar}.
</body>
--------------------------
That way, when Jasper went to generate the JSP source code, and then
compile it, I would get a failure right there and then know I need to
change the method. Basically I want a compile-time check, not a
run-time check.