Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to do that in EL?  RSS feed

 
Gabriel Beres
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'.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 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
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!