remove id="{widget.id}" from the div

h:selectOneRadio value="#{field}" id="#{widget.id}_checkbox" =>
h:selectOneRadio value="#{field}" id="#{widget.id}"

On 27 October 2011 16:41, Jesus Ibañez <[email protected]> wrote:
> Hello Anahide!
>
> Thanks a lot for you rapid response, i took a look at my other widget
> template "reintegra_boolean_radio_widget_template.xhtml" and the tag holding
> the id="#{widget.id}" was "f:subview" and after change it to a div now it
> can get the atributes but still can't found the component, the old error on
> the screen has disappeared but now the stack trace show just the following
> error:
>
> ERROR [mx.org.reintegra.Validate] Cannot validate grupo etnico: input(s) not
> found (component)
>
> My template reintegra_boolean_radio_widget_template.xhtml now looks as
> follows:
>
> <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";
>   xmlns:a4j="https://ajax4jsf.dev.java.net/ajax";
>   xmlns:nxu="http://nuxeo.org/nxweb/util";
>   xmlns:nxdir="http://nuxeo.org/nxdirectory";
>   xmlns:nxl="http://nuxeo.org/nxforms/layout"; id="#{widget.id}">
>
>   <c:if test="#{widget.mode == 'edit' }">
>     <h:selectOneRadio value="#{field}" id="#{widget.id}_checkbox"
> onclick="evalua(this);">
>       <f:selectItem itemValue="#{true}" itemLabel="#{messages['label.yes']}"
> />
>       <f:selectItem itemValue="#{false}" itemLabel="#{messages['label.no']}"
> />
>     </h:selectOneRadio>
>     <h:message styleClass="errorMessage" for="#{widget.id}_checkbox"
>       id="#{widget.id}_message" />
>   </c:if>
>
>   <c:if test="#{widget.mode == 'view' }">
>     <h:outputText rendered="#{field}" value="#{messages['label.yes']}" />
>     <h:outputText rendered="#{! field}"
>       value="#{messages['label.no']}" />
>   </c:if>
>
> </div>
>
>
>
>
> On Thu, Oct 27, 2011 at 4:59 AM, Anahide Tchertchian
> <[email protected]> wrote:
>>
>> Hi,
>> The stack trace could help but i think your validation template is
>> giving the id of a JSF component which is not the input component
>> holding the value you need to perform the validation on.
>> You should check the widget template
>> "/widgets/reintegra_boolean_radio_widget_template.xhtml" and see what
>> tag holds the attribute id="#{widget.id}" => this should be the input
>> component instead (h:selectOnRadio i guess).
>> After that, if it still does not work and your component is not found,
>> check if it holds a f:subview tag and try to remove it by a non-naming
>> container tag (like a div, as done in your other widget template), as
>> it may interfere with the lookup strategy implemented by
>> UIComponent#findComponent.
>> I guess you took example on the default
>> boolean_radio_widget_template.xhtml file, it was not conceived to be
>> used in a cross validation check.
>>
>> On 27 October 2011 07:37, Jesus Ibañez <[email protected]> wrote:
>> > 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/
>> >
>
>
>
> --
> Jesus Ibañez
>
>
---
Mailing list: [email protected]
Forum: http://forum.nuxeo.org/f/1/

Reply via email to