Thanks Craig,

That makes sense. But the problem here is that generictable will be called
from many views, and not just the myfiles view. So I would love the
injection to be handled from the myfiles view, backing bean or managed-bean
declaration. Is this possible?

So basically I want my s:view to pass instantiated objects to its
s:subview's

Thanks,
Joost 

JS Portal - Support
Dasstraat 21
2623CB Delft
the Netherlands
E: [EMAIL PROTECTED]
W: www.jsportal.com 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Craig
McClanahan
Sent: Sunday, January 14, 2007 1:08 PM
To: [email protected]
Subject: Re: How to pass object between backing beans

On 1/13/07, JS Portal support team <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a view (myfiles.jsp) plus backing bean (myfiles). myfiles.jsp has
> an jsp:include (filestable.jsp) in an s:subview which is backed by my
> generictable bean. How can I best pass the List of file Objects from
> myfiles to generictable. Something like <jsp:param name="fileList"
> value="#{myfiles.files}"> would be great.
>
> Or is this not the right way to setup my architecture?


As a matter of fact, something very similar to this is available ... but
it's done in the managed bean definition instead of in the view:

    <managed-bean>
        <managed-bean-name>generictable</managed-bean-name>
        <managed-bean-class>...</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>fileList</property-name>
            <value>#{myfiles.files}</value>
        </managed-property>
    </managed-bean>

The expression will be evaluated when this managed bean is created, and
setFileList() will be called with the result.

This general technique is known as dependency injection, and JSF supports
the variant called "setter injection" which (as the name implies) uses
property setters to actually insert the values.  The only restriction on
what kind of expressions you can evaluate are that you cannot inject a value
from a shorter scope (such as request) into a bean in a longer scope
(session or application).  The other way around (longer-scoped bean into
shorter-scoped bean property), or the same scope, is fine.

Thank you
>
>
Craig

Reply via email to