users@javaserverfaces.java.net

Re: Binding UIForm components and encoding children

From: Guy Coleman <guy.coleman_at_prolog.uk.com>
Date: Fri, 16 Feb 2007 16:27:45 +0000

On 16/02/2007 15:07, Jason Lee wrote:
> OK... I thought that might be the case. Let me chew on that some and
> see if I can cobble together a test app. For what it's worth, can you
> upgrade to the latest 1.1 release
> (https://javaserverfaces.dev.java.net/download.html)?

My quick test shows that the behaviour is the same with 1.1_02-b08 and
MyFaces 1.1.5. Does this mean I'm doing something wrong and this is the
expected behaviour?

Thanks,
-Guy.

> -----
> 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 9:04 AM
>> To: users_at_javaserverfaces.dev.java.net
>> Subject: Re: Binding UIForm components and encoding children
>>
>> Hi Jason,
>>
>> On 16/02/2007 14:15, Jason Lee wrote:
>>> 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?
>>
>> Thanks for the tip. I thought that because I was creating a
>> new form each time, this wouldn't matter. I've just adjusted
>> the code as you suggested and it doesn't fix the problem.
>> Both form elements get rendered correctly, but the child
>> button for form1 doesn't get rendered at all.
>>
>> Thanks,
>> -Guy
>>
>>> -----
>>> 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
>>>>
>>>>
>>>
>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>> users-unsubscribe_at_javaserverfaces.dev.java.net
>>> For additional commands, e-mail:
>>> users-help_at_javaserverfaces.dev.java.net
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
>> For additional commands, e-mail:
>> users-help_at_javaserverfaces.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net
>
>
>