Here were few things I found useful that I added to my own BaseBean. Feel
free to add them to the 'real' BaseBean ...

In BaseBean...

***********************************************************************
//nice for display purposes etc returns Odd or Even
    public String getRowType() {
        //rem first index is 0 so add 1
        if ( ( _index + 1 ) % 2 == 0 ) { 
            return "Even";
        }
        else {
            return "Odd";
        }
     }

Some would argue that this shouldn't be in a BaseBean, but I really found
it helpful. I like Ed Hill's Display tag but in some cases I don't use it
(especially when I have a large collection since the Display tag puts the
entire collection in session scope). So if not using the Display tag this
above method comes in handy for alternating the colors of your rows.

for example:

<c:forEach var="element" items="${fb}">
        <tr class="<c:out value="${element.rowType}"/>Row">
        <td .. 

Now you just need to make sure you have in your style sheet something
like:

.OddRow { background-color: #D3D3D3; }
.EvenRow {  background-color: white; }

Works really well IMO. (avoids having to code the logic in the JSP page).

***********************************************************************

In ActionEvent...

***********************************************************************
//came in handy when I needed to stick some parameters in request scope
public void setReqAttribute(String name, Object o ) {
        _req.setAttribute(name, o);
    }

***********************************************************************
I also changed the method "setBean" to:

public void setReqBean(BaseBean bean)  

Which then forces the user to explicity state a call to either the above 

public void setReqBean(BaseBean bean)

or to  

public void setSesBean(String nam, BaseBean bean)

***********************************************************************
Also added....

public void removeSessionBean( String name ) {
        HttpSession session = _req.getSession();
        session.removeAttribute(name);
    }





-- 
Rick

_______________________________________________
MVC-Programmers mailing list
[EMAIL PROTECTED]
http://www.basebeans.net:8080/mailman/listinfo/mvc-programmers

Reply via email to