• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem using EL function from taglib defined using jsp:root tag  RSS feed

 
Marcos Wendell
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a problem when I define a taglib using the <jsp:root xmlns:fn="...">, and then I try to use a function from that taglib inside an EL expression.

For example, this is my jsp code:



With that code I receive this exception:
org.apache.jasper.JasperException: /index.jsp(15,9) PWC6287: The attribute prefix fn does not correspond to any imported tag library


If I use this other code:


Then it runs ok. What am I doing wrong?


Thanks in advance,

Alejandro Arriola
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66149
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using the JSP document notations at all? That format is not intended for hand coding and this is just one of the many problems types that you will run into because the markup requirements are so stringent. Just use normal JSP notation.
 
Marcos Wendell
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using the JSP document notations at all?


I'm using facelets in my project, and requires valid xml markup.


I need to do a test to decide render or not a component. I have coded a custom taglib with a function that returns true or false. I have seen that you can define it in this way inside the jsp:

<html xmlns:etl="urn:jsptld:/WEB-INF/MyTagLib.tld">
...


But I have not managed to use a function defined in MyTagLib inside an EL expression, something like:




Anybody knows if that can be done? Just in case, I'm making the test in a glassfish v2.1 server.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcos Wendell wrote:
Why are you using the JSP document notations at all?


I'm using facelets in my project, and requires valid xml markup.
True, but Facelets actually doesn't require those jsp:root things and so on. Just write valid XHTML.
Read its own documentation for details: https://facelets.dev.java.net/nonav/docs/dev/docbook.html
 
Marcos Wendell
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hum, you are right. I have test the ${fn:contains("blah", "blah")} and it returns ok!

And I managed to solve the problem thanks to the facelets documentation you have send. The problem was in the taglib definition. You have to do two things:

. First, define the taglib definition using the facelets schema.
. Second, define the taglib in the web.xml

For the taglib definition, I have write the /WEB-INF/tld/MyTagLib.taglib.xml:




Then, I have added this to my web.xml:




And this is the jsp page:




Thanks a lot!

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!