Shash:

> You are right, the ResponseElement interface does not allow lookup of a
> specific nested object.  I don't believe that it was a particular design
> decision, probably just overlooked.  Also, the default implementation of
> response elements stores the nested elements in a private ArrayList, so there
> is no way to extend and cast it and then lookup by name as a workaround either.
> 
> The only thing I can think of is if you add the nested object using the
> setAttribute(String key, Object value) method (instead of add(ResponseElement
> re), then there is a getAttribute(String key) method.  Although, sematically
> this may not be the correct way to nest elements, it might work.
> 
> In the future, we probably ought to consider adding a get(String name) method
> to the interface.  Mike, what do you think?

You're quite right that there's no way to look up a particular nested element by name. 
Nested elements don't have to have a unique name, so there was really no way to easily 
do it in any case - other than returning a collection.

Also, typically there's no need: A Model usually builds a response in reaction to a 
request, it seldom has a need to fish through the response directly for nested 
elements. Aleks, maybe you can tell us a bit more about the context of the issue so we 
can help - there may be a different way to get where you're going.

I have no particular objection to adding a method to retrieve nested elements (or a 
collection of them) by name, but I'm having a hard time imagining when I'd want to use 
it :-)


> 
> Shash
> 
> > Hi all,
> > 
> > I would like to nest some output(out) and input(in) objects like this:
> > 
> > forms
> > |---form1(out)
> > |---form2(out)
> > |---form3(out)
> > |---+form4(out)
> >     |---block1(out)
> >     |---block2(out)
> >     |---block3(out)
> >     |---+block4(out)
> >         |---input1(in)
> >         |---input2(in)
> >         |---input3(in)
> >         |---input4(in)
> > 
> > The process I have right now is like this:
> > 1. create a "forms" output if not contained in "ModelResponse"
> > 2. create form output if not contained in "forms"
> > 3. create block output if not contained in selected form
> > 4. create input if not contained in selected block
> > 
> > Espececially the task "if not contained" is giving me a hard time... 
> > with the response object this is easy to do (res.get("name")), but 
> > "ResponseElement" objects don't have a "get" method. So... here are 
> > my questions...
> > 
> > 1. How can I find out if an output object is contained in another one?
> > 2. Do I really have to do a "out.getAll().iterate()" and go over all 
> > entries (this is what I'm doing now)?
> > 3. Is there another way to perform this task?
> > 
> > Thanks in advance...
> > 
> > Aleks
> > http://keelframework.org/documentation
> > Keelgroup mailing list
> > [EMAIL PROTECTED]
> > http://lists.keelframework.com/listinfo.cgi/keelgroup-keelframework.com
> 
> 
> 
> http://keelframework.org/documentation
> Keelgroup mailing list
> [EMAIL PROTECTED]
> http://lists.keelframework.com/listinfo.cgi/keelgroup-keelframework.com


Michael Nash

JGlobal Ltd 
Next-Generation Web Application Development and Open Source Support
http://www.jglobal.com

Bahamas Commerce and Trade
Offshore eCommerce Hosting and Business Services
http://www.bahamascommerce.com

http://keelframework.org/documentation
Keelgroup mailing list
[EMAIL PROTECTED]
http://lists.keelframework.com/listinfo.cgi/keelgroup-keelframework.com

Reply via email to