Rick, what is the real problem here? I ask because what your trying to
do seems reasonable to me and I'd probably do something similar,
although I probably wouldn't use LazyList (I'd probably build the list
manually), but that doesn't really matter. I would *not* use session
for this as I can't think of a single good reason to do so (well, aside
from maing it WORK of course!).
I noticed your comments about the phone numbers part still not working.
Is *that* the problem your really trying to solve?
I personally think people are too quick to use session for too many
things these days, and many times (arguably at least) inappropriate
things. Until someone can convince to me that it doesn't have
performance impacts in a distributed environment (and if you aren't
building your apps to be distributed-friendly your setting yourself up
for trouble later), I still favor request scope whenever possible. At
least, I wouldn't want to see it stated as a best practice as I still
think the best practice is to avoid session whenever possible (sometimes
it isn't possible of course).
Frank
Rick Reumann wrote:
I'm still stumped with the best way to handle cases where your nesting
goes a bit deeper than just into one list in your ActionForm (and you
want to use Request scope for your ActionForm). Yes, I know many of you
state that it means you have a complicated UI, but I've had numerous
questions come to me personally about master-detail forms where you do
edit several records from a single form, so I'm going to write up a
tutorial on it.
For example lets assume you want to edit on a single JSP a list of
Employees - where you want to be able to edit their "name" AND "phone
numbers":
(imagine data below in editable text fields)
Employee Phone Numbers
-------- -------------
John Doe 888-888-8888
888-111-1111
222-222-2222
Bill Boo 111-111-3333
444-333-3333
[Submit Button]
So we might have a List of Employee objects where Employee has:
String name;
List phoneNumbers;
And our ActionForm bean thus has a single property:
List employees;
Here's the problem.... in the reset method you can set a LazyList to
wrap the Employees but there is still the problem of the internal List
of phoneNumbers in each Employee.
I was trying:
public void reset(ActionMapping actionMapping, HttpServletRequest
httpServletRequest) {
employees = ListUtils.lazyList(new java.util.ArrayList(), new
Factory() {
public Object create() {
return buildEmployee();
}
});
}
private Employee buildEmployee() {
//This really isn't working,
//I'll still get an index out of bounds, when
//trying to set an index of the phoneNumbers list
Employee emp = new Employee();
List phoneNumbers = ListUtils.lazyList(new java.util.ArrayList(),
new Factory() {
public Object create() {
return new String();
}
});
emp.setPhoneNumbers( phoneNumbers );
return emp;
}
Of course all of these problems go away if I just use the Session to
store the form (which at this point, I'm about to say that simply is THE
BEST PRACTICE for this kind of stuff), but I really want to figure out
if there is a semi-nice way to get this to work using the Request.
I've looked at:
http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html
http://wiki.apache.org/struts/StrutsCatalogLazyList
But I'm still a bit stumped here on how to best implement this since
most of those example seem to only deal with nesting one List deep.
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]