This is the xhtml part of my composite component:
<cc:interface componentType="partnerSelComp">
<cc:attribute name="value" type="java.lang.Long"/>
<cc:attribute name="disabled" type="java.lang.Boolean" default="#{false}"/>
<cc:attribute name="service"/>
</cc:interface>
<cc:implementation>
<span id="#{cc.clientId}" style="white-space:nowrap">
<p:inputText id="id" type="hidden" binding="#{cc.partnerId}"/>
<p:inputText id="code"
binding="#{cc.partnerCode}"
disabled="#{cc.attrs.disabled}" >
<p:ajax event="blur" update="code name msg" listener="#{cc.validate}" />
</p:inputText>
<p:inputText id ="name"
disabled="true"
binding="#{cc.partnerName}" />
<p:message id="msg" for="code"/>
</span>
</cc:implementation>
I call it this way:
<my:PartnerSelComp id="partnerSel" value="#{myBean.partner}" service="#{partnerService}" disabled="true"/>
When component rendered initially the code
component appears editable event though disabled="true"
specified. But after the first ajax blur event (I guess because the update
) it will get the the correct disabled state. Querying it's value in backing component getAttributes().get("disabled")
I can see the correct value. Why is it? How can I set initial appearance of the component?
I was able to fix it. I wouldn't say a solution rather a not too elegant workaround:
@Override
public void encodeAll(FacesContext context) throws IOException {
Boolean b = (Boolean) getAttributes().get("disabled");
partnerCode.setDisabled(b);
super.encodeAll(context);
}
I would be pleased if I could understand what is the problem with original one.