Hello!
I´m trying to validate fields of document at creation, but i get the error
at the screen as follows:
/widgets/reintegra_etnico_validation_widget_template.xhtml @8,23
validator="#{valida.grupoEtnico}": java.lang.ClassCastException:
javax.faces.component.UINamingContainer cannot be cast to
javax.faces.component.UIInput
i have my widget template and code as follows:
*
**reintegra_etnico_validation_widget_template.xhtml:*
<div xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jstl/core">
<c:if test="#{widget.mode == 'edit'}">
<h:inputHidden value="needed" validator="#{valida.grupoEtnico}"
id="#{widget.id}">
<f:attribute name="perteneceGrupoEtnicoId"
value="#{layout.widgetMap['perteneceGrupoEtnico'].id}" />
<f:attribute name="grupoEtnicoId"
value="#{layout.widgetMap['grupoEtnico'].id}" />
</h:inputHidden>
<h:message for="#{widget.id}" styleClass="errorMessage" />
</c:if>
</div>
*Layout:*
<widget name="perteneceGrupoEtnico" type="template">
<labels>
<label mode="any">Pertenece a algún grupo étnico?</label>
</labels>
<translated>false</translated>
<fields>
<field>imputado:perteneceGrupoEtnico</field>
</fields>
<properties widgetMode="edit">
<property
name="template">/widgets/reintegra_boolean_radio_widget_template.xhtml</property>
<property name="elementId">etnico</property>
<property name="required">true</property>
</properties>
<properties mode="any"/>
</widget>
<widget name="grupoEtnico" type="selectOneDirectory">
<labels>
<label mode="any">Grupo étnico</label>
</labels>
<translated>false</translated>
<fields>
<field>imputado:grupoEtnico</field>
</fields>
<properties widgetMode="edit">
<property name="localize">false</property>
<property name="directoryName">gEtnicos</property>
<property name="displayIdAndLabel">false</property>
<property name="ordering">label</property>
<property name="notDisplayDefaultOption">false</property>
<property name="displayObsoleteEntries">false</property>
<property name="required">false</property>
</properties>
<properties mode="any"/>
</widget>
<widget name="validaEtnico" type="template">
<labels>
<label mode="any"></label>
</labels>
<translated>false</translated>
<fields/>
<properties widgetMode="edit">
<property
name="template">/widgets/reintegra_etnico_validation_widget_template.xhtml</property>
</properties>
<properties mode="any"/>
</widget>
*Bean:
public void grupoEtnico(FacesContext context, UIComponent component,
Object value) {
Map<String, Object> attributes = component.getAttributes();
String perteneceGrupoEtnicoInputId = (String)
attributes.get("perteneceGrupoEtnicoId");
String grupoEtnicoInputId = (String)
attributes.get("grupoEtnicoId");
if (perteneceGrupoEtnicoInputId == null || grupoEtnicoInputId ==
null) {
log.error("Cannot validate grupo etnico: input id(s) not found
(attributes)");
return;
}
UIInput perteneceGrupoEtnicoComp = (UIInput)
component.findComponent(perteneceGrupoEtnicoInputId);
UIInput grupoEtnicoComp = (UIInput)
component.findComponent(grupoEtnicoInputId);
if (perteneceGrupoEtnicoComp == null || grupoEtnicoComp == null) {
log.error("Cannot validate grupo etnico: input(s) not found
(component)");
return;
}
Object perteneceGrupoEtnico =
perteneceGrupoEtnicoComp.getLocalValue();
Object grupoEtnico = grupoEtnicoComp.getLocalValue();
if (perteneceGrupoEtnico == null || grupoEtnico == null) {
log.error("Cannot validate passwords: value(s) not found
(null)");
return;
}
FacesMessage message = new
FacesMessage(FacesMessage.SEVERITY_ERROR, "testing", null);
throw new ValidatorException(message);
}
*
what am i doing wrong?
Any help would be appreciate, thanks in advanced.
--
Jesus Ibañez
---
Mailing list: [email protected]
Forum: http://forum.nuxeo.org/f/1/