I've come across the need to override a request parameter for setting
the "selected" value of a Select list (when used in conjunction with
Struts in this instance).  Since I cannot req.setParameter(), I want to
use req.setAttribute(), which isn't currently supported:
===============================================================
// get the current selection
String[] selected = req.getParameterValues(name);

// begin "patch"
/* override the request parameters if an attribute is set */
if (req.getAttribute(name) != null) {
    if (req.getAttribute(name) instanceof String) {
        selected = new String[] { (String)req.getAttribute(name) };
    }
    else if (req.getAttribute(name) instanceof String[]) {
        selected = (String[]) req.getAttribute(name);
    }
}
// end "patch"

if (selected != null && selected.length > 1 &&
===============================================================
I've tested this code change and it works for both String and String[].



=====
Lance Lavandowska
Http://www.brainopolis.com/

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

Reply via email to