Odwołujący identyfikator komponentu kompozytowego w renderowaniu f: ajax
Piszę komponent złożony, który ma zawijać element wejściowy i rozszerzać go o oznaczenie „pole opcjonalne” i element h: message poniżej. Oto komponent (w pliku input.xhtml):
<composite:interface/>
<composite:implementation>
<div>
#{component.children[1].setStyleClass(component.children[1].valid ? '' : 'inputError')}
<composite:insertChildren/>
</div>
<h:panelGroup styleClass="optional"
rendered="#{!component.parent.children[1].required}"
layout="block" >
#{msgs['common.optional.field']}
</h:panelGroup>
<h:message id="msgId"
for="#{component.parent.children[1].id}" errorClass="error"/>
</composite:implementation>
Ponownie, zamierzonym zastosowaniem komponentu jest zawinięcie elementu h: input *, który ma być pierwszym i bezpośrednim dzieckiem tego elementu na stronie używanej.
W używanej stronie napisałbym wtedy:
<h:form id="f1">
<h:panelGrid border="0" columns="2" style="width: 80%">
<f:facet name="header">
<col width="40%" />
<col width="60%" />
</f:facet>
<h:outputLabel styleClass="sectionBody" for="i1"
value="Input 1"></h:outputLabel>
<my:input id="ii1">
<h:inputText id="i1" size="20" maxlength="20" tabindex="0"
required="true" label="Input 1">
</h:inputText>
</my:input>
<h:outputLabel styleClass="sectionBody" for="i2"
value="Input 2"></h:outputLabel>
<my:input id="ii2">
<h:inputText id="i2" size="20" maxlength="20" tabindex="0"
label="Input 2">
</h:inputText>
</my:input>
</h:panelGrid>
<br />
<h:commandButton value="Submit" tabindex="1">
<f:ajax listener="#{terminalImportBean.addTerminal}"
execute="@form" render="@form"/>
</h:commandButton>
</h:form>
To działałoby dobrze przy zwykłych postach. Jeśli jednak dodam add f: ajax sprawdzanie poprawności dla „Input 1” (id = „i1”) i spróbuję ponownie renderować kompozyt (ii1), używając następujących:
...
<h:outputLabel styleClass="sectionBody" for="i1"
value="Input 1"></h:outputLabel>
<my:input id="ii1">
<h:inputText id="i1" size="20" maxlength="20" tabindex="0"
required="true" label="Input 1">
<f:ajax listener="#{myBean.checkInput1}"
event="blur"
render="ii1"/>
</h:inputText>
</my:input>
...
Zgłaszam błąd w przeglądarce podczas przetwarzania odpowiedzi ajax:
malformedXML: During update: f1:ii1 not found
Próbowałem użyćf1:ii1
, :f1:ii1
, ale bez skutku. Kiedy używammsgId
lub:f1:ii1:msgId
to działa. Czy ktoś wie dlaczego?
Używam Mojarra 2.1.3
Dzięki