users@javaserverfaces.java.net

RE: Binding UIForm components and encoding children

From: Jason Lee <lee_at_iecokc.com>
Date: Fri, 16 Feb 2007 08:15:43 -0600

Guy, I haven't used 1.1 in a while, but I think I hit a similar problem
with component binding in 1.2. If I tried to add the some UIComponent
instance to two different parents, the second parenting would always
undo the first. What you're doing is fairly similar, though you create
each component anew with each invocation of getForm(), so it may not be
quite the same. Have you tried duplicating getForm(), say, getForm2(),
and binding each form to a different method just to see what happens?

-----
Jason Lee, SCJP
Programmer/Analyst
http://www.iec-okc.com
 

> -----Original Message-----
> From: Guy Coleman [mailto:guy.coleman_at_prolog.uk.com]
> Sent: Friday, February 16, 2007 4:41 AM
> To: users_at_javaserverfaces.dev.java.net
> Subject: Binding UIForm components and encoding children
>
> Hi there,
>
> I'm having a problem with a bound form component and its
> children not getting rendered. I'm using JSF 1.1_01.
>
> Managed Bean:
>
> public class MyBean {
>
> public HtmlForm getForm() {
> FacesContext context = FacesContext.getCurrentInstance();
> HtmlForm form = new HtmlForm();
> HtmlCommandButton button = new HtmlCommandButton();
> button.setValue("Button");
> button.setId(context.getViewRoot().createUniqueId());
> form.getChildren().add(button);
> return form;
> }
>
> public void setForm(HtmlForm form) {
> // Do nothing
> }
> }
>
> JSP:
>
> <h1>Form 1 (bound)</h1>
> <h:form binding="#{MyBean.form}" id="form1"> </h:form>
>
> <h1>Form 2 (bound, inside panelGroup)</h1> <h:panelGroup>
> <h:form binding="#{MyBean.form}" id="form2">
> </h:form>
> </h:panelGroup>
>
>
> The button inside form2 gets rendered, while the button
> inside form1 doesn't.
>
> I've tried to work this out but haven't got very far. My best
> guess is that this is because the panelGroup recursively
> renders its children and the form doesn't, and since the
> neither button has a JSP tag the form1's button's encode
> methods don't get called by anything.
>
> Do I have to work around this by putting all bound forms in a
> panelGroup?
>
> Thanks,
> -Guy Coleman.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail:
> users-help_at_javaserverfaces.dev.java.net
>
>