JSF Composite pass all events -


i want create custom composite component in jsf (with primefaces) shows label in front of input adds message @ end.

in order here source code:

the composite:

<?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"         "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"       xmlns:h="http://java.sun.com/jsf/html"       xmlns:p="http://primefaces.org/ui"       xmlns:composite="http://java.sun.com/jsf/composite">     <composite:interface componenttype="custominput">         <composite:attribute name="label" />         <composite:attribute name="value" />     </composite:interface>      <composite:implementation>         <h:panelgrid columns="3">             <h:outputtext value="#{cc.attrs.label}:" />             <p:inputtext id="abcde" value="#{cc.attrs.value}" />             <p:message for="abcde" />         </h:panelgrid>     </composite:implementation> </html> 

the backing bean:

@facescomponent(value = "custominput") public class custominput extends inputtext implements namingcontainer {     @override     public string getfamily() {         return uinamingcontainer.component_family;     } } 

so far, good. want use events inherited p:inputtext component. example:

<pch2:pchinputtext2 label="name" id="test2" value="#{testbean.test}">     <p:ajax event="blur" listener="#{chantierformbean.updatemap()}" />     <p:ajax event="change" listener="#{chantierformbean.updatemap()}" /> </pch2:pchinputtext2> 

i know pass these events adding

<composite:clientbehavior name="change" event="change" targets="abcde" /> 

to composite:interface part, have add 1 client behavior every event (in future). isn't there method pass events inherited primefaces inputtext?

thanks in advance

that's not possible.

a composite in first place not right tool job. it's not intented dry out , refactor repeated xhtml code. it's intented create whole new (input) component tied single model value. example, <p:fileupload> , <p:imagecropper> togeher tied single com.example.image property. or 3 <p:selectonemenu> tied single java.time.localdate property.

use tagfile instead.

<ui:composition ...>     <h:outputlabel for="#{id}" value="#{label}:" />     <p:inputtext id="#{id}" value="#{value}">         <ui:insert />     </p:inputtext>     <p:message for="#{id}" /> </ui:composition> 

see also:


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -