Question

just was wondering if there is a way to access a method from my class without creating a custom taglib.

Example I got a class which provides 4 methods: hasDisplay(), hasCreate(), hasDelete() and hasEdit() - all of them just returning a boolean value.

From my jsp I just want to

<c:if test="{ar.hasEdit}"></c:if>

But this only works with getter and setter methods, am I right?

Was it helpful?

Solution

If you don't want to write your own tags you could provide a decorator for the object that provides a "beanish" interface. So you wrap hasedit() with isHasEdit() that way cou can keep your jsps clean and still use the desired syntax, but you end up with "dirty" wrappers.

I'd go for a custom taglib. It's not that complicated.

OTHER TIPS

Correct, JSP EL can only access bean properties. Anything else needs a custom taglib. It's not good enough, but there it is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top