Using some style sheet logic in conjunction with JSTL is an elegant solution. Here's a quick snip of code to do just that (the arraylist should come from the action, and the style sheet should be in it's own file, but you get the idea).
<*snip*> <style type="text/css"> <!-- .negative_true { color: #ff0000; } .negative_false { color: #000000; } --> </style> <% String dataValues[] = {"500", "-200", "100", "20", "5", "-7", "0", "800"}; pageContext.setAttribute("dataValues", dataValues); %> <table cellpadding="4" cellspacing="0" border="1"> <tr> <td><strong>Values</strong></td> </tr> <c:forEach var="dataValue" items="${dataValues}"> <tr> <%-- This next line is really the only logic that needs included for negative value checking. My personal opinion is that this code has a small footprint, and I wouldn't mind having this presentation logic duplicated in multiple places throughout my app. --%> <td class="negative_<c:out value="${dataValue < 0}" />"><c:out value="${dataValue}" /></td> </tr> </c:forEach> </table> </*snip*> Have fun. Regards, Jarrod Lugo -----Original Message----- From: Edgar Dollin [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 26, 2003 5:14 PM To: 'Struts Users Mailing List' Subject: RE: Struts custom tags tutorial In the case, the user described below, I didn't. What he wanted to do was, based on data values, guarantee a color scheme and other criteria, i.e. maybe all negative numbers should be in red. This is view based logic, but one of the priciples we all use is try not to write the same code twice. I might be missing something but, JSTL, and most view technologies (except custom tags, source includes and tiles), don't have the ability to modularize common code or have strange syntax to achieve the modularization. So to say just use the standard technologies and let the view have the view logic is a bit of a cop out. I suspect that most of what he wants to do is already in struts-layout so there is a work around without writing his own tags. Edgar > -----Original Message----- > From: Bill Chmura [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 26, 2003 12:53 PM > To: 'Struts Users Mailing List' > Subject: RE: Struts custom tags tutorial > > > > I am not sure if you agreed with me or not on that one. In > case you did not, to clarify: I think that the view should > handle all the logic for presenting the data. It should not > be tied into the business logic.... For example, the business > logic should know how to get all the parts from the database > that are active. The View logic should cover how to make > them into rows, colors, highlighting. > > The display should really only know what data is coming back. > From then on it should have the responsibility of making it > pretty and paginating and such. > > I think we may be on the same page > > > > -----Original Message----- > > From: Edgar Dollin [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, August 26, 2003 10:07 AM > > To: 'Struts Users Mailing List' > > Subject: RE: Struts custom tags tutorial > > > > > > Logic in the display which needs to know anything about the > > specifics of business logic, makes no sense to me, although > > there seem to be very few of us who have this attitude. > > Examples of this include field size; required fields; > > number logic (internationalization), etc. > > > > Edgar > > > > > -----Original Message----- > > > From: Bill Chmura [mailto:[EMAIL PROTECTED] > > > Sent: Tuesday, August 26, 2003 4:26 AM > > > To: 'Struts Users Mailing List' > > > Subject: RE: Struts custom tags tutorial > > > > > > > > > > > > Here are two easy ways out... > > > > > > http://edhill.its.uiowa.edu/display-examples/ > > > (Wonderful, worked great for me) > > > > > > or > > > > > > http://jakarta.apache.org/velocity > > > (Simple templating, integrates nicely) > > > > > > > my code corresponding to these struts tags else where. This > > > > way the logic to display the data will not be there on the > > > > JSP page. > > > > > > Why don't you want the display logic there? I always > > > considered that the view should control how the data is > > > displayed... I could (and often are wrong about these > > > things) but it strikes me as strange. If you are trying to > > > keep it simple for HTML developers, try velocity. Most > > > anyone can do templates in that. > > > > > > Me > > > > > > > > > > > > > -----Original Message----- > > > > From: Seshadhri Srinivasan [mailto:[EMAIL PROTECTED] > > > > Sent: Tuesday, August 26, 2003 2:51 AM > > > > To: 'Struts Users Mailing List' > > > > Subject: RE: Struts custom tags tutorial > > > > > > > > > > > > Hi Steve, > > > > Let me clarify: > > > > I know some of the basic concepts of struts and I have > > > > been using things like the Action class, the Form class > > > > etc. But the point is, after having finished the work on > > > > the backend logic, I have to present my data in the form of > > > > tables on the page. Now the table dimensions, the colours > > > > used, etc. can vary based on the data generated. So I > > > > wanted to use custom Struts tags on the page where the > > > > table has to be generated and displayed. Then I want to put > > > > my code corresponding to these struts tags else where. This > > > > way the logic to display the data will not be there on the > > > > JSP page. This is my problem. I have tried to get the right > > > > tutorial for this but my search has noy yielded the right > > > > results. Can you please help me. > > > > > > > > Thanks, > > > > Seshadhri Srinivasan > > > > > > > > -----Original Message----- > > > > From: Steve Raeburn [mailto:[EMAIL PROTECTED] > > > > Sent: Tuesday, August 26, 2003 11:50 AM > > > > To: Struts Users Mailing List > > > > Subject: RE: Struts custom tags tutorial : urgent!! > > > > > > > > > > > > I do appreciate that when you are completely new to a > > > > subject it can be difficult to know where to look. However, > > > > you'll get a much more sympathetic response if you > > > > demonstrate that you have at least tried to find things out > > > > for yourself before asking for help. > > > > > > > > Start with the Struts web site: > > > > - http://jakarta.apache.org/struts/userGuide/index.html > > > > - http://jakarta.apache.org/struts/resources/tutorials.html > > > > - http://jakarta.apache.org/struts/resources/examples.html > > > > > > > > And also try Google: > > > > - http://www.google.com/search?q=Struts+tutorial > > > > - http://www.google.com/search?q=Struts+examples > > > > > > > > Also, there are at least seven books specifically on Struts > > > > and several others that offer some coverage. > > > > > > > > <rant to="everyone that uses URGENT!! to get attention" > > > > priority="URGENT!!"> > > > > Flagging your messages as URGENT!! gives the impression > > > > that you somehow > > > > think your problem is so important that others should > > > > stop what they are > > > > doing and tend to your needs. In reality, URGENT!! tends > > > > to get your > > > > message ignored. > > > > > > > > Please, don't use URGENT!! unless your house is on fire. > > > > And even then > > > > you'd probably be better off calling the fire service > > > > than emailing me :-) </rant> > > > > > > > > > > > > Steve > > > > > > > http://www.ninsky.com/struts/ > > > > > > > > > > -----Original Message----- > > > > From: Seshadhri Srinivasan [mailto:[EMAIL PROTECTED] > > > > Sent: August 25, 2003 10:30 PM > > > > To: 'Struts Users Mailing List' > > > > Subject: RE: Struts custom tags tutorial : urgent!! > > > > > > > > > > > > Hi, > > > > I have a JSP page in which I am supposed to add content > > dynamically > > > > based on some logic. I came to know that using custom > > > struts tags in > > > > the jsp page can > > > > aid in making the presentation logic modular. However I > > have no idea > > > of > > > > custom Struts tags. Can some one suggest a good > > tutorial to cover up > > > this > > > > portion as quickly as possible? > > > > Thanks in advance > > > > > > > > Seshadhri Srinivasan > > > > > > > > > > > > > > > > > ------------------------------------------------------------ > > --------- > > > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------ > > --------- > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > > ------------------------------------------------------------ > > --------- > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > > > > ------------------------------------------------------------ > > --------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]