0

I created a Composite Component to emulate the Primefaces's Column, which instead render to components, its renderize to (I also created other components to emulate Primefaces's PanelGrid and Row to use DIVs instead Table and TR). The code is the following:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui" 
    xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
    <cc:attribute name="id" type="java.lang.String" required="false"/>
    <cc:attribute name="span" type="java.lang.Integer" required="false" default="1" />
</cc:interface>
<cc:implementation>
    <p:outputPanel id="#{cc.attrs.id}" layout="block"
        styleClass="ui-grid-col-#{cc.attrs.span}">
        <cc:insertChildren />
    </p:outputPanel>
</cc:implementation>
</html>

My problem happens when I use a outputLabel referrecing a component to an outside's component:

<ipem:column span="2">
    <p:outputLabel value="#{msg['precadastro.titulo.nome_fantasia']}" for="fantasia"/>
</ipem:column>
<ipem:column span="10">
    <p:inputText id="fantasia" size="80" maxlength="100"
        value="#{preCadastroMB.preCadastro.nomeFantasia}" />
</ipem:column>

When I wrote this, I got the message Cannot find component with identifier "fantasia" referenced from "painelCadastro:j_idt80:j_idt82:j_idt84". I need remove the for attribute in outputLabel.

I found some questions here in StackOverflow which are near my doubt. For example, in How to make a grid of JSF composite component? we have an outputLabel in the parent page which references a component inside a composite. However, in my case, both label as inputText are inside its own composite. In How to create a composite component for a datatable column? the label and inputText are both in the same composite.

We don't have this problem Column's Primefaces. How do they manage this?

Thanks,

Rafael Afonso

Community
  • 1
  • 1
Rafael Afonso
  • 595
  • 1
  • 10
  • 28
  • The code in this answer does what you need: http://stackoverflow.com/questions/15002441/primefaces-outputlabel-for-composite-component – Yamada Sep 12 '14 at 14:36
  • @Yamada: Thanks, but this answer falls in the same problem as _How to make a grid of JSF composite component?_: An outputLabel in the parent page which references a component inside a composite, when I want both label as inputText are inside their own composites. – Rafael Afonso Sep 12 '14 at 15:05
  • Can you confirm that you have tested using for="myTargetCompositeComponent:fantasia" in the p:outputLabel and set id="myTargetCompositeComponent" in the target cc ()? – Yamada Sep 12 '14 at 15:25
  • @Yamada: What I really want is discover how to make a reference to a component outside a composite in the same way as we would do in a panelGrid. For example, ` ... ... `. I don't want to appeal to references using ":". – Rafael Afonso Sep 12 '14 at 18:45
  • Well, if you don't want to define and use the full component identifier, another alternative would be using JQuery selectors. Primefaces has some support for it. Have a look in http://blog.primefaces.org/?p=1867 – Yamada Sep 12 '14 at 19:38
  • I'm relatively new to JSF but it appears that this is what `composite:editableValueHolder` is for. Have you tried using that? It will let you pass in a reference to another component. See http://docs.oracle.com/javaee/6/tutorial/doc/giqzr.html or https://www.ibm.com/developerworks/library/j-jsf2fu0111/ for more info. – Frans Apr 24 '17 at 09:51

0 Answers0