jsf 2 - JSF2 updating composite elements using ajax -
there's input element , want update once user enters in there.
input element:
<h:form id="form"> <h:inputtext value="#{message.message}"> <f:ajax event="keyup" render="form:compelem"/> </h:inputtext> <compositeoutputcomponents:test2 id="compelem" message="#{message.message}"/> </h:form>
and how composite element looks like:
<?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:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"> <h:head> </h:head> <h:body> <fieldset> <composite:interface> <composite:attribute name="id"/> <composite:attribute name="message" required="true"/> </composite:interface> <composite:implementation> <span id="#{cc.attrs.id}"> <h:outputtext value="#{cc.attrs.message}"/> </span> </composite:implementation> </fieldset> </h:body>
i tried pass id composite element balus in jsf updating composite component (primefaces) suggested (i dont use primefaces), still page yields error : "malformedxml: during update: form:compelem not found". when use non composite element works fine.
you need #{cc.clientid}
instead of #{cc.attrs.id}
in composite implementation.
<span id="#{cc.clientid}">
otherwise end <span id="compelem">
instead of <span id="form:compelem">
, javascript can't find anymore, resulting in malformedxml error.
once fix part, can reference in <f:ajax render>
usual way reference other non-composite component in same form:
<f:ajax ... render="compelem" />
or if insist in specifying absolute client ids reason (but unnecessary):
<f:ajax ... render=":form:compelem" />
Comments
Post a Comment