Hi Jeremy,
Firstly, JSF really relies on its component tree being stable when the
page is re-rendered. Any code that tries to add/delete components from
the tree is likely to have problems; the JSF approach is to instead have
the tree stay stable but for components to be marked with rendered=false
if HTML should not be generated from them at the current time.
I'm not saying it is impossible to rearrange the component tree at
runtime, but you'll be in fairly uncharted territory.
If you're determined to follow your current design, then as Mike
Kienenburger says, it's probably just a matter of ensuring the JSP
processor executes the desired sub-pages and not really a JSF issue
(though JSF problems may well occur as a result). When the JSP processor
executes a page that happens to have JSF tags in it, the corresponding
JSF components will be created and attached to the tree. In your case,
you do need them to be attached to the right parent node, though, which
might be tricky. By default, a JSF tag will look for its parent JSF tag,
get the component associated with that parent tag, and make that the
parent of the new component. See the UIComponentTagBase implementation
for details of that. You'll need to work around that somehow as you want
the new components to be attached to the dynamically created child
components, yet by not writing a component you don't have any Tag class
you can put custom code into to make this happen.
Regards,
Simon
Jeremy Sager wrote:
Hi Simon -
I'm not sure that a custom component would really solve my problem. I'm not
going to know what the tabbed panes are until runtime, and there are many
actions that a user could take that would alter the number and types of
panes being displayed dynamically.
We're designing a web client for a product in which the thick client is
built using Eclipse's Rich Client Platform. If you're not familiar with it,
there's an "editor pane" area where editors can be opened and closed, and
the data inside those editors can be manipulated.
I have to allow for a pane to be added or removed, and there are many
different potential types of panes that could be added. I've got the
add/remove functionality working just fine, I just am hoping there's some
way I can add the child content for each pane without having to hand code
all the components for each pane.
The original plan was for me to use the JSTL to iterate across the list of
children and then import the appropriate pages, but as has been explained to
me at length on this list, that doesn't work.
For reasons outside of my control, I'm tied to using JSPs, so facelets are
out, and I'm tied to using J2EE1.4, so going to the most recent version of
glassfish is out, which is why I've been left in the situation where my only
choice is to hand code the pane itself... I'm just hoping we can get back
out of the trap and use JSPs for the pane's contents.
Jeremy Sager
Data Communications Product Manager
Chesapeake System Solutions
410.356.6805 x120
[EMAIL PROTECTED]
-----Original Message-----
From: Simon Kitching [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 22, 2005 6:30 PM
To: MyFaces Discussion
Subject: Re: Importing a JSP inside the setter method of a bound
component...
Jeremy Sager wrote:
Thanks in advance for any help on this one, I think it's a bit tricky.
So, I have a HtmlPanelTabPane that I need to render the children of
dynamically, and I've gotten the binding down pat thanks in large part
to help from Martin M. So now I'm working inside of a java object
instead of a jsp.
I've created the HtmlPanelTab children just fine, and now I am hoping
that I can import a jsp so I don't have to keep rendering child
components with java code instead of using the taglib like I want to.
Now, since I know any import has to be done within an <f:subview>, I
went and figured out that a subview is a UINamingContainer, so I made
one of them.
Now what? It doesn't seem like importing a page is built into any part
of faces for reasons I can't really figure out, so I'm stuck as to what
I need to do next. Do I have to get the external servlet context, find
the jsp writer, and figure out how to use import tag objects?
Or, as I'm hoping, I'm not the first person to run into this challenge
and someone can tell me that it's easily solvable, or, even better,
someone can call me a dummy and show me that importing a page
programmatically in faces and I just missed the boat.
You're trying to do all this inside a "backing bean"? If so, I think
you'll find it all very hard work.
It sounds to me like you are really writing a custom UIComponent. In
this case, by writing a proper component in the normal way the JSF
framework will help you - the hooks are all there for what you're trying
to do.
Regards,
Simon