Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Struts when tag question

    I've got a struts when tag that is part of a choose statement:
    Code:
    <c:when test="${(pta.nlt==1)&&!(pta.name.contains(pta.lang))}">
    pta.name is a string as is pta.lang.

    and it throws the following error:
    Code:
    ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhos
    t].[/mptutoring].[action]:119] Servlet.service() for servlet action threw exception javax.servlet.jsp.JspException: ServletException in 'admin.assigntutors.jsp': <h3>Validation error messages from TagLibraryValidator for c in /admin.assigntutors.jsp</h3><p>32: tag = 'when' / attribute = 'test': 
    An error occurred while parsing custom action attribute "test" with value "${(pta.nlt==1)&&!(pta.name.contains(pta.lang))}": Encountered "(", expected one of [".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", ")", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||"]</p>
    I feel like I'm missing something really simple, but I can't figure it out.
    Last edited by sjones25; 02-23-2011 at 10:24 PM.

  • #2
    Regular Coder
    Join Date
    Jan 2009
    Location
    india
    Posts
    145
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Try


    <c:when test="${pta.nlt==1 && !pta.name.contains(pta.lang)}">


    Just give it a try, I guess it may not work too, i think you can't use method calls (pta.name.contains)

    Note: It's not a struts tag, it's a JSTL tag

  • #3
    New Coder
    Join Date
    Feb 2011
    Posts
    48
    Thanks
    1
    Thanked 2 Times in 2 Posts
    The only difference between sjones25's and servlet's version is the presence or absence of a parantezis around the operands. I don't see any logical difference, only a difference in the syntax. Why should a parantezis around a logical operand cause an exception?

  • #4
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried it without the parenthesis and just got the same error. The error seems to be pointing to the open parenthesis from the method call. When I take out the method call it works fine

    I guess they're not allowed, I'll just have to put it somewhere outside the tag. Seems weird to do it that way, but oh well.

  • #5
    New Coder
    Join Date
    Feb 2011
    Posts
    48
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Try this one (I think this should work):

    Code:
    <c:when test="${(pta.nlt==1)&&((pta.name.indexOf(pta.lang) < 0))}">

  • #6
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No. You just can't put function calls in the <when> tag, it has nothing to do with the contains method in particular.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •