Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > STRUTS/JSTL: Need Match \ Equals tag that compares multiple values

Reply
Thread Tools

STRUTS/JSTL: Need Match \ Equals tag that compares multiple values

 
 
groovyjman21@gmail.com
Guest
Posts: n/a
 
      04-23-2007

Hi all,

Struts 1.3.8 Websphere 5.1 web app, wondering how to test my
Customer bean properties in my JSP against multiple values.

I have a business rule which reads "If (the customer is from AZ,
CA, MS, NE, or WA), and (either their total sales or total credits are
greater than zero) then display the following paragraph."

Pseudocodishly:

if((customer.state == AZ || customer.state == CA || customer.state ==
MS || customer.state == NE || customer.state == WA) &&
(customer.totalsales > 0 || customer.totalcredits > 0){
showParagraph;
}

I can't find an efficient way to do this with struts as the equals and
match tags only take one value at a time. I have read that JSTL might
be a way to do this (ie <c:if test = ${...}>) but can't find
sufficient documentation Any help greatly appreciated.

 
Reply With Quote
 
 
 
 
Richard Senior
Guest
Posts: n/a
 
      04-24-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> I have a business rule which reads "If (the customer is from AZ,
> CA, MS, NE, or WA), and (either their total sales or total credits are
> greater than zero) then display the following paragraph."

....
> I can't find an efficient way to do this with struts as the equals and
> match tags only take one value at a time. I have read that JSTL might
> be a way to do this (ie <c:if test = ${...}>) but can't find
> sufficient documentation Any help greatly appreciated.


The nearest you would get would be the choose tag in JSTL. See
http://java.sun.com/j2ee/1.4/docs/tu...4.html#wp74001

BUT if this is a business rule, it should be implemented in your
business layer rather than in your presentation layer.

Looking at your description I can't see what "location in (AZ, CA, MS,
NE, WA) and (sales > 0 or credits > 0)" means from a business logic
point of view. You'd probably comment it in your JSP.

For the sake of argument, lets say it means it's an "important"
customer. If you gave your customer bean a method like this:

public boolean isImportant() {
return ("AZ".equals(location) || ...
}

You get to (a) code your logic in Java, (b) keep your business logic in
the model where it belongs, (c) re-use your logic elsewhere and (d)
create a much more readable view:

<c:if test="${customer.important}">
... do something important!
</c:if>

Regards,

Richard



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
specified that delete command compares all values on SqlDataSource =?Utf-8?B?RWQ=?= ASP .Net 0 04-18-2006 08:52 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Function that compares 2 alpha-numeric values? success_ny@yahoo.com Javascript 3 07-22-2005 10:10 AM
does String.equals breaks the equals contract? Edward A Thompson Java 4 02-11-2004 11:33 PM



Advertisments