1

There is an another question just about that, but I couldn't solve my problem with that. jsf and primefaces update problem

What is the correct level to start with :? I just want to update messagePanel-messages, what is wrong with that. I have tried 5 different solutions, but no success.

<ui:composition template="./template.xhtml">

    <ui:define name="title">
        <h:outputText value="#{bundle.editXTZ_title} - #{XTZBean.username} - -->: #{RmaBean.selectedRma.rma}"></h:outputText>
    </ui:define>
    <h:panelGroup id="messagePanel" layout="block">
        <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
    </h:panelGroup>
    <ui:define name="body">
        <h:form id="formi">
            <p:accordionPanel activeIndex="#{XTZBean.activeIndex}">  
                <p:tab title="Muokkaa"> 

......more code and then

                <p:tab title="Avainsanat">  

                        <p:panelGrid id="avainsanaGrid" style="margin-top:20px;" styleClass="noBorders">
                            <p:row>
                                <p:column></p:column>
                                <p:column></p:column>


<p:row rendered="#{XTZBean.suljettu}">
                                <p:column></p:column>
                                <p:column></p:column>
                                <p:column><p:commandButton value="Tallenna" id="btnAvainsana" process="@this,avainsana" update="avainsanaGrid, :messagePanel"  
                                                           actionListener="#{XTZBean.talletaAvainsana}" style="width: 210px;"/></p:column>
                                <p:column></p:column>
                                <p:column></p:column>
                                <p:column></p:column>
                                <p:column></p:column>
                            </p:row> 
                         </p:panelGrid>  
                    </p:tab>

Thanks! Sami

Community
  • 1
  • 1
Sami
  • 2,311
  • 13
  • 46
  • 80

1 Answers1

3

Based on the information given so far (and assuming that the <ui:insert name="body"> is not by itself in another NamingContainer component), the :messagePanel is right.

But the <h:panelGroup id="messagePanel"> is not at the right place. It's completely outside the template definition and thus totally ignored. It has to be placed inside any of the <ui:define>.

E.g.

<ui:define name="body">
    <h:panelGroup id="messagePanel" layout="block">
        <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
    </h:panelGroup>

    <h:form id="formi">
        ...
    </h:form>
</ui:define>

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for answering! I got a javax.faces.FacesException: Cannot find component with identifier ":messagePanel" referenced from "j_idt6:formi:j_idt12:btnAvainsana". – Sami Nov 01 '12 at 13:01
  • Did you fix the template? Well, if you still get this exception, then there's apparently another `NamingContainer` as parent of `` which has according to the exception message most likely the autogenerated ID `j_idt6`. Give it a fixed ID and use `:someId:messagePanel` instead. See also the 1st "See also" link in my answer for details. – BalusC Nov 01 '12 at 13:02
  • Give your form prepend id false – Kerem Baydoğan Nov 01 '12 at 13:02
  • @KeremBaydoğan: no, that won't fix it. The messages are not placed inside the form. – BalusC Nov 01 '12 at 13:04
  • @ BalusC Yes I fixed it as well. – Sami Nov 01 '12 at 13:13
  • @balusC Yes I read it. What can be that another naming container? – Sami Nov 01 '12 at 13:22
  • As said, it's the parent of ``. It's there in your master template. – BalusC Nov 01 '12 at 13:26
  • :j_idt6:messagePanel AND :templateForm:messagePanel works fine. In template:
    Content
    Is this BTW correct way to implement template? Two forms now I think?? Thanks to everyone for helping me!
    – Sami Nov 01 '12 at 13:31
  • As said, you should give the component which is identified by `j_idt6` a **fixed** ID. Otherwise this autogenerated ID will change when you add another component before the particular component and you'd need to fix all those `update` identifiers again. By the way, nesting forms is illegal in HTML. Non-ajax buttons will fail to work this way. – BalusC Nov 01 '12 at 13:32
  • @ BalusC That's why I was asking. I haven't implemented that template so I think that I will delete that form from the template. It should be usefull and like you said, it's illegal. Thanks for helping everyone!! – Sami Nov 01 '12 at 15:11
  • Report it to the template's author so that it gets a fixed ID. As to the nested form, the problem can also be the other way round: perhaps you shouldn't be placing the `` in the template client. – BalusC Nov 01 '12 at 15:12