Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to do that in EL?

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to determine if a particalar checkbox is checked or not with the following statement:

<c:if test="check${CHECK_ID}"> checked </c:if>

For example, if check3 is checked, i set a pageContext attribute check3=true. However, the statement above does not work. It is always false, wether the pageContext attribute is there or not.

Note that i have to concatenate the EL expression, because i cannot hardwire the name 'check3'.
 
Marshal
Posts: 67415
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not giving us a whole lot of details to go on. Is the statement on the page begin submitted to, or on the page containing the checkbox?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Gabe Beres:

<c:if test="check${CHECK_ID}"> checked </c:if>


Looks strange!Here what is CHECK_ID?

Originally posted by Gabe Beres:

For example, if check3 is checked, i set a pageContext attribute check3=true. However, the statement above does not work. It is always false, wether the pageContext attribute is there or not.


i guess you are setting check3 in pageContext like pageContext.setAttribute("CHECK_ID",check3)

if it is ok,then use like below

<c:if test="${CHECK_ID eq 'true'}">// CHECK_ID is true then process

Hope This Helps
 
Bear Bibeault
Marshal
Posts: 67415
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a scoped variable is a Boolean, the eq 'true' is unnecessary and possibly harmful. Why would you convert a boolean to a String just to find out if it is true?
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic