You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Dennis Hörsch <ho...@his.de> on 2012/03/26 13:20:22 UTC

Problem with composite components and tag handler

Hey,

I have a problem with composite components. The scenario is as follows:

<his:someCompositeComponent id="outer">
     <h:inputText id="first" ... />

     <his:someTagHandlerTag condition="bla">
         <h:inputText is="second" ... />
     </his:someTagHandlerTag>
</his:someCompositeComponent>

The problem is, only the first input field is rendered. The second is 
not. After building the component tree, the first is a child of the 
'composite component'-facet of the surrounding UINamingContainer 
(outer), the second ends as child of the UINamingContainer. The 
'HtmlCompositeComponentRenderer' renders only the children of the facet.

The 'someTagHandlerTag' is handled by a subclass of TagHandler. If the 
condition is true, it calls the nextHandler (second-input field) which 
adds the input as child to the composite component.

It is the same with the JSTL-Tags: If I have a 'c:if' inside a composite 
component, it will not be rendered in any case.

Is this how it should be? Or should this tags also be rendered (handled) 
as childs using composite components?

I hope that I could clarify the problem :-)

Thank you,
dennis hoersch



-- 

HIS Hochschul-Informations-System GmbH
Goseriede9| 30159 Hannover | _www.his.de_ <http://www.his.de/>

Dennis Hörsch
Unternehmensbereich Hochschul-IT
Arbeitsbereich Entwicklung
Telefon +49 (0)511 1220-403 | Fax +49 (0)511 1220-250
E-Mail hoersch@his.de <ma...@his.de>

Registergericht: Amtsgericht Hannover, HRB 6489
Geschäftsführer: Prof. Dr. Martin Leitner
Vorsitzender des Aufsichtsrats: Ministerialdirigent Peter Greisler


Re: Problem with composite components and tag handler

Posted by Leonardo Uribe <lu...@gmail.com>.
Hi Dennis

I have checked the code and I think we can consider all UserTagHandler
instances as containers of components (just like DecorateHandler and
IncludeHandler). That means if <cc:insertChildren> is used, all
instances of UserTagHandler should be executed in the place when
<cc:insertChildren> is called. So we just need to increase the list
to:

- javax.faces.view.facelets.ComponentHandler.class
- InsertChildrenHandler.class
- InsertHandler.class
- DecorateHandler.class
- IncludeHandler.class
- TextHandler.class
- UserHagHandler.class

After looking carefully this issue, it seems we need to include <c:if>
and <c:choose> too.

Could you please create an issue for this one in

https://issues.apache.org/jira/browse/MYFACES

so I can fix it?

regards,

Leonardo

2012/3/27 Dennis Hörsch <ho...@his.de>:
> Hi,
>
> I was expecting that composite components behave like any other.
>
> I am currently updating a big project from JSF1 to 2. We have many usages of
> JSTL as 'child'-components. And our 'old-fashioned' facelets components now
> are UserTagHandlers in the end. This ones will also be ignored...
>
> I had a look an at CompositeComponentResourceTagHandler and changed it in
> the way that 'newly' added childs are stored and will later be added to the
> right component. My simple test scenario works, but I have no clue about
> Partial State Saving and if there are any other cases that may be affected.
>
> I attached it, can you have a look?
>
> Thank you,
> dennis hoersch
>
>
> Am 26.03.2012 22:42, schrieb Leonardo Uribe:
>
> Hi
>
> Difficult question. You should avoid that trick, or at least use c:if
> inside you custom tag to make it work properly. Really there are some
> details that will not work as expected.
>
> First of all, <c:if> code has changed since the original code inside
> facelets, to ensure proper operation with JSF 2.0 Partial State
> Saving. It is very complex to explain, but in resume, no component
> like c:if can be created without rely in some implementation details.
>
> The second part is composite component algorithm cannot recognize the
> tag as a tag containing component instances, so if the composite
> component uses cc:insertChildren, the part related to the tag will not
> be applied correctly. The solution in this case is use a composite
> component or a normal component instead a facelets user tag. Anyway,
> maybe we can do something better in this part (
> org.apache.myfaces.view.facelets.tag.composite.CompositeComponentResourceTagHandler),
> and try to detect better cases like the one described here.
>
> regards,
>
> Leonardo Uribe
>
> 2012/3/26 Dennis Hörsch <ho...@his.de>:
>
> Hey,
>
> I have a problem with composite components. The scenario is as follows:
>
> <his:someCompositeComponent id="outer">
>     <h:inputText id="first" ... />
>
>     <his:someTagHandlerTag condition="bla">
>         <h:inputText is="second" ... />
>     </his:someTagHandlerTag>
> </his:someCompositeComponent>
>
> The problem is, only the first input field is rendered. The second is not.
> After building the component tree, the first is a child of the 'composite
> component'-facet of the surrounding UINamingContainer (outer), the second
> ends as child of the UINamingContainer. The 'HtmlCompositeComponentRenderer'
> renders only the children of the facet.
>
> The 'someTagHandlerTag' is handled by a subclass of TagHandler. If the
> condition is true, it calls the nextHandler (second-input field) which adds
> the input as child to the composite component.
>
> It is the same with the JSTL-Tags: If I have a 'c:if' inside a composite
> component, it will not be rendered in any case.
>
> Is this how it should be? Or should this tags also be rendered (handled) as
> childs using composite components?
>
> I hope that I could clarify the problem :-)
>
> Thank you,
> dennis hoersch
>
>
>
> --
>
> HIS Hochschul-Informations-System GmbH
> Goseriede 9 | 30159 Hannover | www.his.de
>
> Dennis Hörsch
> Unternehmensbereich Hochschul-IT
> Arbeitsbereich Entwicklung
> Telefon +49 (0)511 1220-403 | Fax +49 (0)511 1220-250
> E-Mail hoersch@his.de
>
> Registergericht: Amtsgericht Hannover, HRB 6489
> Geschäftsführer: Prof. Dr. Martin Leitner
> Vorsitzender des Aufsichtsrats: Ministerialdirigent Peter Greisler
>
>
>
> --
>
> HIS Hochschul-Informations-System GmbH
> Goseriede 9 | 30159 Hannover | www.his.de
>
> Dennis Hörsch
> Unternehmensbereich Hochschul-IT
> Arbeitsbereich Personalmanagement
> Telefon +49 (0)511 1220-403 | Fax +49 (0)511 1220-250
>
> E-Mail hoersch@his.de
>
> Registergericht: Amtsgericht Hannover, HRB 6489
> Geschäftsführer: Prof. Dr. Martin Leitner
> Vorsitzender des Aufsichtsrats: Ministerialdirigent Peter Greisler

Re: Problem with composite components and tag handler

Posted by Dennis Hörsch <ho...@his.de>.
Hi,

I was expecting that composite components behave like any other.

I am currently updating a big project from JSF1 to 2. We have many 
usages of JSTL as 'child'-components. And our 'old-fashioned' facelets 
components now are UserTagHandlers in the end. This ones will also be 
ignored...

I had a look an at CompositeComponentResourceTagHandler and changed it 
in the way that 'newly' added childs are stored and will later be added 
to the right component. My simple test scenario works, but I have no 
clue about Partial State Saving and if there are any other cases that 
may be affected.

I attached it, can you have a look?

Thank you,
dennis hoersch


Am 26.03.2012 22:42, schrieb Leonardo Uribe:
> Hi
>
> Difficult question. You should avoid that trick, or at least use c:if
> inside you custom tag to make it work properly. Really there are some
> details that will not work as expected.
>
> First of all,<c:if>  code has changed since the original code inside
> facelets, to ensure proper operation with JSF 2.0 Partial State
> Saving. It is very complex to explain, but in resume, no component
> like c:if can be created without rely in some implementation details.
>
> The second part is composite component algorithm cannot recognize the
> tag as a tag containing component instances, so if the composite
> component uses cc:insertChildren, the part related to the tag will not
> be applied correctly. The solution in this case is use a composite
> component or a normal component instead a facelets user tag. Anyway,
> maybe we can do something better in this part (
> org.apache.myfaces.view.facelets.tag.composite.CompositeComponentResourceTagHandler),
> and try to detect better cases like the one described here.
>
> regards,
>
> Leonardo Uribe
>
> 2012/3/26 Dennis Hörsch<ho...@his.de>:
>> Hey,
>>
>> I have a problem with composite components. The scenario is as follows:
>>
>> <his:someCompositeComponent id="outer">
>>      <h:inputText id="first" ... />
>>
>>      <his:someTagHandlerTag condition="bla">
>>          <h:inputText is="second" ... />
>>      </his:someTagHandlerTag>
>> </his:someCompositeComponent>
>>
>> The problem is, only the first input field is rendered. The second is not.
>> After building the component tree, the first is a child of the 'composite
>> component'-facet of the surrounding UINamingContainer (outer), the second
>> ends as child of the UINamingContainer. The 'HtmlCompositeComponentRenderer'
>> renders only the children of the facet.
>>
>> The 'someTagHandlerTag' is handled by a subclass of TagHandler. If the
>> condition is true, it calls the nextHandler (second-input field) which adds
>> the input as child to the composite component.
>>
>> It is the same with the JSTL-Tags: If I have a 'c:if' inside a composite
>> component, it will not be rendered in any case.
>>
>> Is this how it should be? Or should this tags also be rendered (handled) as
>> childs using composite components?
>>
>> I hope that I could clarify the problem :-)
>>
>> Thank you,
>> dennis hoersch
>>
>>
>>
>> --
>>
>> HIS Hochschul-Informations-System GmbH
>> Goseriede 9 | 30159 Hannover | www.his.de
>>
>> Dennis Hörsch
>> Unternehmensbereich Hochschul-IT
>> Arbeitsbereich Entwicklung
>> Telefon +49 (0)511 1220-403 | Fax +49 (0)511 1220-250
>> E-Mail hoersch@his.de
>>
>> Registergericht: Amtsgericht Hannover, HRB 6489
>> Geschäftsführer: Prof. Dr. Martin Leitner
>> Vorsitzender des Aufsichtsrats: Ministerialdirigent Peter Greisler


-- 

HIS Hochschul-Informations-System GmbH
Goseriede9| 30159 Hannover | _www.his.de_ <http://www.his.de/>

Dennis Hörsch
Unternehmensbereich Hochschul-IT
Arbeitsbereich Personalmanagement
Telefon +49 (0)511 1220-403 | Fax +49 (0)511 1220-250
E-Mail hoersch@his.de <ma...@his.de>

Registergericht: Amtsgericht Hannover, HRB 6489
Geschäftsführer: Prof. Dr. Martin Leitner
Vorsitzender des Aufsichtsrats: Ministerialdirigent Peter Greisler


Re: Problem with composite components and tag handler

Posted by Leonardo Uribe <lu...@gmail.com>.
Hi

Difficult question. You should avoid that trick, or at least use c:if
inside you custom tag to make it work properly. Really there are some
details that will not work as expected.

First of all, <c:if> code has changed since the original code inside
facelets, to ensure proper operation with JSF 2.0 Partial State
Saving. It is very complex to explain, but in resume, no component
like c:if can be created without rely in some implementation details.

The second part is composite component algorithm cannot recognize the
tag as a tag containing component instances, so if the composite
component uses cc:insertChildren, the part related to the tag will not
be applied correctly. The solution in this case is use a composite
component or a normal component instead a facelets user tag. Anyway,
maybe we can do something better in this part (
org.apache.myfaces.view.facelets.tag.composite.CompositeComponentResourceTagHandler),
and try to detect better cases like the one described here.

regards,

Leonardo Uribe

2012/3/26 Dennis Hörsch <ho...@his.de>:
> Hey,
>
> I have a problem with composite components. The scenario is as follows:
>
> <his:someCompositeComponent id="outer">
>     <h:inputText id="first" ... />
>
>     <his:someTagHandlerTag condition="bla">
>         <h:inputText is="second" ... />
>     </his:someTagHandlerTag>
> </his:someCompositeComponent>
>
> The problem is, only the first input field is rendered. The second is not.
> After building the component tree, the first is a child of the 'composite
> component'-facet of the surrounding UINamingContainer (outer), the second
> ends as child of the UINamingContainer. The 'HtmlCompositeComponentRenderer'
> renders only the children of the facet.
>
> The 'someTagHandlerTag' is handled by a subclass of TagHandler. If the
> condition is true, it calls the nextHandler (second-input field) which adds
> the input as child to the composite component.
>
> It is the same with the JSTL-Tags: If I have a 'c:if' inside a composite
> component, it will not be rendered in any case.
>
> Is this how it should be? Or should this tags also be rendered (handled) as
> childs using composite components?
>
> I hope that I could clarify the problem :-)
>
> Thank you,
> dennis hoersch
>
>
>
> --
>
> HIS Hochschul-Informations-System GmbH
> Goseriede 9 | 30159 Hannover | www.his.de
>
> Dennis Hörsch
> Unternehmensbereich Hochschul-IT
> Arbeitsbereich Entwicklung
> Telefon +49 (0)511 1220-403 | Fax +49 (0)511 1220-250
> E-Mail hoersch@his.de
>
> Registergericht: Amtsgericht Hannover, HRB 6489
> Geschäftsführer: Prof. Dr. Martin Leitner
> Vorsitzender des Aufsichtsrats: Ministerialdirigent Peter Greisler