Nuxeo IDE Document CrossValidation

Hello, I'm trying to make a validation of a custom document based on a cross validation (make a validation on a field based on what the user has filled on a second one). I made this technique based on a post here : http://www.nuxeo.com/blog/cross-validation-with-jsf/. -> An hidden field, that has two attributes that have the value of the fields I want to check.

This works fine in one case: two fields, a widget of type single vocabulary radio and the other of type single vocabulary But doesn't work with: two fields: a widget document suggestion (that has a “Document page provider name” that will query the database) and the other of type single vocabulary.

Here is the xhtml of template:

<c:if test=“#{widget.mode == 'edit'}“>

When I try the retrieve the value I have a null object on the fields that has the document suggestion: String inputId = (String) attributes.get(componentId); UIInput component = (UIInput) anchor.findComponent(inputId); if(component != null) {

return component.getLocalValue();

}

Can somewone help me?

2 votes

1 answers

2323 views

ANSWER



Here is the xhtml of template:

<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="#{nomenclature_liste_nomenclature.validaterListeEtNomenclatureLiee}"
id="#{widget.id}">
<f:attribute name="firstElt"
value="#{layout.widgetMap['nomenclature_liee'].id}" />
<f:attribute name="secondElt"
value="#{layout.widgetMap['type_de_metadonnees'].id}" />
</h:inputHidden>
<h:message for="#{widget.id}" styleClass="errorMessage" />
</c:if>
</div>

Java code:

    public static Object retrieveInputComponentValue(UIComponent anchor, String componentId) {
        Map<String,Object> attributes = anchor.getAttributes();

        if(attributes != null)
        {
            String inputId = (String) attributes.get(componentId);

            UIInput component = (UIInput) anchor.findComponent(inputId);
            if(component != null)
            {
                return component.getLocalValue();
            }
        }
        return null;
    }
0 votes