Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems calling a method on a bean with EL  RSS feed

 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I have a problem and I hope someone could give me a pointer

I have a method on a bean (userSession.RoleManager) that is currently sitting on my JSP

public boolean getCanModerateForum( int forumId ) {


I can see the bean on the JSP by calling

${userSession.RoleManager}


I want to call the method using an int I have on a bean on my JSP

${userSession.roleManager.canModerateForum[forum.id]}


forum.id is an int and I can see that on a JSP if I call..

${forum.id}


Problem is I get a NullPointerException and the method is never called, does someone know what is going wrong here?

If I change the method signature and take out the int param it goes into the method but how should I set the int?

Many thanks.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot call general methods using the EL.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let getCanModerateForum() return Map<Long, Boolean> and your approach will work. The map contents is hopefully self-explaining.

Apart from that, boolean getters should in fact be prefixed with "is", not with "get".
 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never actualy wrote the code, it's been passed to me under the premis that it all works, that is why it is all very strange.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is indeed an exception. JBoss Application Server ships with enhanced EL library which allows those constructions.

But as it is not part of the Sun JSP EL specification (although it is most likely to be included in the upcoming EL specification versions), there is no guarantee that it will work in all Java EE environments.

Google "JBoss EL" or something straightforward like that to get more information.
 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers, I will look at that.

The code has been running under a different set of libraries so that is probably the issue.

Actually it's under the JForum3 code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!