• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How to replace a if(boolean) script with struts tag?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, friends,
I have a bean with a boolean property "isPrimary" inside. I want to use it as a condition in my jsp page just like this:
<% if(myBean.isPrimary){
.... %>
My question is how can I replace this script by using struts tag, like <html:equal> or something else?
thanks.
henry
 
Marshal
Posts: 17010
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use the logic tag:
<logic:equal name="myBean" property="primary" value="true">
...
</logic:equal>
 
Henry Sun
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Junilu Lacar:
use the logic tag:
<logic:equal name="myBean" property="primary" value="true">
...
</logic:equal>


In my bean, I am following the javabean rules for boolean property by defining the getter method like this: public boolean isPrimary(). But <html:equal> seems like to get any property by using exactly "public boolean getIsPrimary()". I've tested this way, it works. But is there any other way or tags to get it working?
Thanks your reply.
henry
 
Henry Sun
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Sun:

In my bean, I am following the javabean rules for boolean property by defining the getter method like this: public boolean isPrimary(). But <html:equal> seems like to get any property by using exactly "public boolean getIsPrimary()". I've tested this way, it works. But is there any other way or tags to get it working?
Thanks your reply.
henry


Forget my last post. It works with your suggestion by <logic:equal name="myBean" property="primary">. I was still using "isPrimary" in the tag, so it doesn't work.
Thanks.
Henry
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic