1

I have created a composite component which contains a simple primefaces inputText with some validation attached.

In order to attach ajax events for this composite i defined a composite:clientBehaviour like this:

<composite:interface>
    <composite:attribute name="value" type="java.lang.String" />
    <composite:attribute name="update" type="java.lang.String" />
    <composite:editableValueHolder name="ipAddressInput" targets="#{cc.clientId}:ipAddressInput" />
    <composite:clientBehavior name="update" targets="#{cc.clientId}:ipAddressInput" event="blur" />
</composite:interface>

<composite:implementation>
            <p:inputText placeholder="xxx.xxx.xxx.xxx" id="ipAddressInput" value="#{cc.attrs.value}" validatorMessage="Invalid IPV4 Address">
                <p:keyFilter regEx="/[0-9.]/i" />
                <f:validator validatorId="com.db.nms.app.netappls.validation.faces.IpV4Validator" />
            </p:inputText>
</composite:implementation>

When i add this composite to a page and defining an ajax event like:

<netappls:ipV4Input id="ipInputCC" value="#{addInterfaceIpDialogBean.addressForm.ipAddress}">
    <p:ajax update="maskInput" listener="#{addInterfaceIpDialogBean.onUpdateIp}" />
</netappls:ipV4Input>

The listener will not be called on blur. Just copy the inputText where i use the composite and define the ajax event exactly like this will call the listener.

I also tried to set different process and update filter on the ajax element. Nothing had worked. When i add imediate="true" to the ajax element it will fire but the value will not be updated.

My first idea was that it is related to the validator. But also removing the validator does not change anything.

Any idea what i am doing wrong?

The composite will be used in a dialog page using primefaces dialog framework.

TosKen
  • 481
  • 5
  • 20
  • My comment is more or less off topic, but if you're custom component is meant to only contain an inputText, prefer facelet tag: https://stackoverflow.com/a/14752114/4605161. Composite for this use case does not really make sense. You'll realize it's much more easy to implement your component (since you don't have to bother with CC API) ;) Also consider using Omnifaces as it provides tagAttribute and methodParam tags which are very useful. For your case, simply use `` and you won't have to worry which cc attributes to use – Rapster Aug 21 '18 at 11:41

1 Answers1

0

You have different id mapping in composite:clientBehavior and input id. Try to unify them:

<composite:clientBehavior name="update" targets="ipAddressInput" event="blur" />
Emil Sierżęga
  • 1,785
  • 2
  • 31
  • 38
iabughosh
  • 481
  • 5
  • 19