myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rudy De Busscher <rdebussc...@gmail.com>
Subject [ExtVal] improvement of add-on prototype for lightweight transactional model validation
Date Sun, 24 Jan 2010 19:38:15 GMT
hi all,

The add-on (
http://os890.googlecode.com/svn/trunk/java/web/jsf/extval/transactional_model_validation_light)
implements a model validation without using the Bean validation
infrastructure.
The improvement is located in the 'transactional' part of the code, where
the old values of the backing bean are copied back and the submittedValue of
the component is set.

The current code sets the converted value back but the rendering phase
expects String values in the property and thus a stacktrace is the result.
(a TODO comment is found in the method so it was known that it wasn't
complete)

*Caused by: java.lang.IllegalArgumentException: Expected submitted value of
type String for component : {Component-Path : [Class:
javax.faces.component.UIViewRoot,ViewId: /personEdit.jsp][Class:
javax.faces.component.html.HtmlForm,Id: j_id_jsp_2070182162_2][Class:
javax.faces.component.html.HtmlPanelGrid,Id: j_id_jsp_2070182162_3][Class:
javax.faces.component.html.HtmlInputText,Id: color]}
    at
org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:273)
    at
org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:142)
    at
org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:57)
    at
org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererProxy.encodeEnd(ExtValRendererProxy.java:159)
    at
org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWrapper.encodeEnd(ExtValRendererWrapper.java:409)
    at javax.faces.component.UIComponent*


The following piece of code uses the converter of the component to set the
correct String value for the submittedValue property.
*
    public void revert() {
        // to the following manually to support complex components...
        ModelValidationUtils.invokeSetter(this.baseObject,
this.propertyName,
                this.oldValue);

        Converter componentConverter = component.getConverter();
        if (componentConverter == null) {
            this.component.setSubmittedValue(this.newValue.toString());
        } else {
            this.component.setSubmittedValue(componentConverter.getAsString(
                    FacesContext.getCurrentInstance(), (UIComponent)
this.component,
                    this.newValue));
        }
        this.component.setValid(false);
    }*

The method is located in *
at.gp.web.jsf.extval.validation.model.transactional.RevertableProperty*

I wanted to use the add-on in a demo and found the (known) 'problem' and
liked to share a possible solution.

Regards

Rudy De Busscher

Mime
View raw message