• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Henry Sun
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
 
Junilu Lacar
Bartender
Posts: 7607
54
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic