[ 
https://issues.apache.org/jira/browse/MYFACES-2624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851811#action_12851811
 ] 

Jakob Korherr commented on MYFACES-2624:
----------------------------------------

After digging into to issue, I have to say I am a little confused. The spec 
issue #314 says to automatically add a h:messages as the last child of every 
UIForm if there is no UIMessages in the view.

However there are some problems with this approach. At first the presence of an 
UIMessages does not mean that every FacesMessage is really displayed (e.g. if 
the attribute for is set). Furthermore we would have to traverse the whole tree 
to find out if there really are UIMessages or not, because we can't rely on our 
facelet handlers or JSP tag handlers to find out if there is an h:messages 
component, because the user might use a custom messages component (like e.g. 
the one from tomahawk).

The easiest way to determine if every FacesMessage really has been rendered is 
to check FacesMessage.isRendered() on every FacesMessage, but we can only check 
this after the rendering has happened and thus we won't be able to add the 
h:messages component any more.

Using <ui:debug /> on Mojarra to see how it deals with this scenario I found 
out that it does not add an UIMessages component at all. It seems to hook into 
the rendering phase before the body tag is closed (and not at the end of every 
form like the spec issue says) and to just add the HTML from the h:messages 
renderer to the output without adding the component itself to the tree. Thus, 
Mojarra does not change the component tree at all, which is kinda nice!

I will try some things out to find the best fitting solution to this problem. 
Suggestions are always welcome!!

> Automatically add h:messages if ProjectStage is Development
> -----------------------------------------------------------
>
>                 Key: MYFACES-2624
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2624
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-3
>            Reporter: Jakob Korherr
>            Assignee: Jakob Korherr
>
> If ProjectStage is Development and there is no h:messages component on the 
> current view we should automatically add h:messages to the component tree, 
> because many users often forget about adding this useful (debug) component 
> and wonder why their actions are never called.
> This is also an official JSF 2.0 spec requirement, however I couldn't find it 
> in the spec-pdf or in the javadoc, but in the spec issue tracker [1] and on 
> several blogs like Ryan Lubke's Blog [2]. Furthermore Mojarra also does it.
> [1] 
> https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=314
> [2] http://blogs.sun.com/rlubke/entry/jsf_2_0_new_feature2

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to