DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7062>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7062 nested:iterate and logic:iterate -- add odd/even and modulus scripting vars Summary: nested:iterate and logic:iterate -- add odd/even and modulus scripting vars Product: Struts Version: Nightly Build Platform: All OS/Version: All Status: NEW Severity: Enhancement Priority: Other Component: Custom Tags AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] nested:iterate (and its cousin, logic:iterate) are incredibly useful tags, but there's one thing that's needlessly hard to do right now: cycle through two or more CSS styles during iteration for purposes like alternating background colors. Two complementary suggestions: PART ONE -- "oddEven" add a new optional property to the iterate tag ("oddEven") whose value will identify a scripting variable that alternates between "odd" and "even", depending upon whether the current index (assigned to a scripting variable identified by the indexId parameter) is odd or even. example use: <style> .odd {background-color: yellow;} .even {background-color: blue;} </style> <nested:iterate id="foo" property="bar" oddEven="oddEven"> <tr class="<%= oddEven %>"><td>The row's output goes here...</td></tr> </nested:iterate> or, if different color schemes need to be used with different iteration blocks: <style> .specific_odd {background-color: red;} .specific_even {background-color: yellow;} .another_odd {background-color: green;} .another_even {background-color: blue;} </style> ... with one iteration specifying its odd/even classes with: <tr class="specific_<%= oddEven %>"><td>row's output goes here...</td></tr> ... and another with: <tr class="another_<%= oddEven %>"><td>the row's output goes here</td></tr> PART TWO -- ARBITRARY CYCLING VALUES going a step beyond cycling between "odd" and "even", we can extend it to cycle through integers between 0 and one less than some value identifying the maximum number of possible values by adding two parameters: iterationClassIdName = name of scripting variable to which the modulus of the maxIterationClassIdValues parameter and indexId will be assigned. maxIterationClassIdValues = number whose modulus with indexId will be stored in the scripting variable specified by the iterationClassIdName parameter. Default value = "2" if omitted. Using the parameter names themselves as examples, for each iteration, <%= iterationClassIdName %> = indexId % maxIterationClassIdValues Example of use: <nested:iterate id="foo" property="bar" iterationClassName="rowClass" maxIterationClassIdValues="3"> <tr class="row_<%=rowClass%>"><td>row output goes here</td></tr> </nested:iterate> Example of extreme nested use: <style> .row_0 {background-color: #ffffff;} .row_1 {background-color: #cccccc;} .col_0 {background-color: #990000;} .col_1 {background-color: #000099;} .col_2 {background-color: #009900;} .row_0_col_0 {background-color: #ffcccc;} .row_0_col_1 {background-color: #ccccff;} .row_0_col_2 {background-color: #ccffcc;} .row_1_col_0 {background-color: #cc9999;} .row_1_col_1 {background-color: #9999cc;} .row_1_col_2 {background-color: #99cc99;} </style> <!-- ... moving along to the iterate blocks...--> <!-- the following isn't quite semantically complete... it's just intended to show how nested nested tags, together with iterationClassIdName and maxIterationClassIdValues, could be used to generate tables with rows of alternating color, and colums of cycling colors influenced by the color of the row they're "passing over" --> <nested:iterate id="rows" property="moot" iterationClassIdName="rowClassId"> <tr> <td class="row_<%=rowClassId%>">something</td> <td class="row_<%=rowClassId%>">another</td> <nested:iterate id="cols property="irrelevant" iterationClassIdName="colClassId" maxIterationClassIdValues="3"> <td class="row_<%=rowClassId%>_col_<%=colClassId%>">one of many columns</td> </nested:iterate> <td class="row_<%=rowClassId%>">more at the end of the row</td> </tr> </nested:iterate> Strictly speaking, there's nothing the first part (odd/even) can do that can't be achieved through the second part alone, but implementing both will provide nearly unlimited flexibility via the cycling integers and simplicity via odd/even. Likewise, the functionality provided by this enhancement can be achieved through alternate means (by adding more custom tags to return the modulus of some arbitrary number and the value of indexId, for example, or getting ugly with scriptlets), but implementing it directly and making the output values easily accessible as scripting variables will make the use of alternating/cycling colors trivially easy to do. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
