• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issues with struts condition tag, lil help please

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gurus,

I am having problems using condition custom tag, based on jakarta struts 1.0
In the example below , the "balance_Amount" is string ( in form bean). The value I compare is with is double ( 0.1).

how do i go about writing?
The below code is not working. what are the laternatives I have here like logic:greaterThan tag?

<xx:if>
<xx:condition> <xx ataValue fieldName="balance_Amount"/> > "0.1" </xx:condition>
<xx:then>
.....
</xx:then>
</xx:if>
[ February 11, 2006: Message edited by: frank xxx ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been working with Struts for a long time, and I've never heard of the xx:if, or xx:condition tags. They must be in some other custom tag library you're using. For Struts, you'll want to use the <logic:equal> tag.

Here's a link to the 1.0 version of these tags:

http://struts.apache.org//struts-doc-1.0.2/api/org/apache/struts/taglib/logic/package-summary.html#package_description

You also have the option of using Java Standard Tag Library (JSTL) for this logic.
 
frank xxx
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for you response Merril, I am new to struts.

Well, when I say <XX:if > its a custom tag and XX stands for company name.
I didnot want to mention that. But How could I use that conditin tag?
I checked the tld file theres nothing there except for definition. No attribues or anything.

How could I use <logical: greaterThan> tag to compare a string value ( eg. "2.0" )to a double value 0.1?
The balance type in my bean account is string.


eg

<logical: greaterThan> name="account" property="balance" value="0.1"
...
<logical: greaterThan>


Tnanks for you help?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The actual logic of a custom tag is in java classes that the .tld file points to. In your TLD, you will find <tagclass) and <teiclass> entries. Look in these classes for the actual logic of the tags.

Regarding the <logic:greaterThan> tag, the answer to your question is in the link that I gave you:

Each of the value comparison tags takes a value and compares it to the value of a comparison attribute. If the value given can be successfully converted to a float or double, then a number comparison is performed on the value given and the value of the comparison attribute. Otherwise a String comparison is performed.



Even if the property is a string, the tag does a number comparison if it can.
 
frank xxx
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merril, I will have to try it on monday
 
reply
    Bookmark Topic Watch Topic
  • New Topic