New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidateBean doesn't update values provided by Composite Components #240

Closed
CSchulz opened this Issue Apr 19, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@CSchulz

CSchulz commented Apr 19, 2016

Consider following component in template

        <r:booleanCheckbox value="#{controller.entity.value}" />

and the following composite component:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://xmlns.jcp.org/jsf/composite"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html">

  <cc:interface>
   ...
    <cc:attribute name="value" required="true" />
   ...
  </cc:interface>

  <cc:implementation>
    <div id="#{cc.clientId}">
   ...
      <div class="form-element-input">
        <p:selectBooleanCheckbox id="checkbox" value="#{cc.attrs.value}" >
          <cc:insertChildren />
        </p:selectBooleanCheckbox>
      </div>
    </div>
  </cc:implementation>
</html>

The ValidateBean class doesn't recognize it as valid property in if (valueReference.getBase().equals(base)) { (source). In my case the base is the nestd ExpressionEvalMap class of CompositeComponentAttributesELResolver (Mojarra).

I think the ValidateBean class should recognize CompositeComponent properties and dive through all "value" attributes.

f.e. in my case the following resolution will work:

if (getValueReference(context.getELContext(), valueReference.getBase().getExpression("value")).equals(base))}

If someone has some ideas how to fix it, I would prepare a pull request.

@BalusC BalusC closed this in f0ca9d9 Apr 28, 2016

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Apr 28, 2016

Member

Fix is available in today's latest 2.4-SNAPSHOT. Can you give it a try and let me know?

Member

BalusC commented Apr 28, 2016

Fix is available in today's latest 2.4-SNAPSHOT. Can you give it a try and let me know?

@CSchulz

This comment has been minimized.

Show comment
Hide comment
@CSchulz

CSchulz Apr 28, 2016

It seems there is a regression bug now (see #144)

21:40:48,693 SEVERE [org.omnifaces.taghandler.ValidateBean] (default task-106) Exception occured while doing validation.: java.lang.IllegalArgumentException: Cannot convert org.omnifaces.el.ExpressionInspector$FinalBaseHolder@ed5de7f of type class org.omnifaces.el.ExpressionInspector$FinalBaseHolder to class java.lang.Boolean
    at com.sun.el.lang.ELSupport.coerceToBoolean(ELSupport.java:191) [javax.el-3.0.1-b05.jar:]
    at com.sun.el.parser.AstChoice.getValue(AstChoice.java:66) [javax.el-3.0.1-b05.jar:]
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) [javax.el-3.0.1-b05.jar:]
    at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at org.omnifaces.el.ExpressionInspector.getValueReference(ExpressionInspector.java:48) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.el.ExpressionInspector.getValueReference(ExpressionInspector.java:54) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.taghandler.ValidateBean$6.invoke(ValidateBean.java:332) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.taghandler.ValidateBean$6.invoke(ValidateBean.java:328) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.util.Components$ForEach$1.visit(Components.java:500) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]

It seems not to be related, it happens for following composite component:

        <r:inputText
                         value="#{controller.create ? null : schadenController.entity.value}"
                         disabled="#{controller.create}" />

CSchulz commented Apr 28, 2016

It seems there is a regression bug now (see #144)

21:40:48,693 SEVERE [org.omnifaces.taghandler.ValidateBean] (default task-106) Exception occured while doing validation.: java.lang.IllegalArgumentException: Cannot convert org.omnifaces.el.ExpressionInspector$FinalBaseHolder@ed5de7f of type class org.omnifaces.el.ExpressionInspector$FinalBaseHolder to class java.lang.Boolean
    at com.sun.el.lang.ELSupport.coerceToBoolean(ELSupport.java:191) [javax.el-3.0.1-b05.jar:]
    at com.sun.el.parser.AstChoice.getValue(AstChoice.java:66) [javax.el-3.0.1-b05.jar:]
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) [javax.el-3.0.1-b05.jar:]
    at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at org.omnifaces.el.ExpressionInspector.getValueReference(ExpressionInspector.java:48) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.el.ExpressionInspector.getValueReference(ExpressionInspector.java:54) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.taghandler.ValidateBean$6.invoke(ValidateBean.java:332) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.taghandler.ValidateBean$6.invoke(ValidateBean.java:328) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]
    at org.omnifaces.util.Components$ForEach$1.visit(Components.java:500) [omnifaces-2.4-20160428.144047-7.jar:2.4-SNAPSHOT]

It seems not to be related, it happens for following composite component:

        <r:inputText
                         value="#{controller.create ? null : schadenController.entity.value}"
                         disabled="#{controller.create}" />
@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Apr 30, 2016

Member

That's not a valid writable value expression in first place. Outside the composite, you'd face a PropertyNotWritableException on submit. Just use value="#{schadenController.entity.value}".

Member

BalusC commented Apr 30, 2016

That's not a valid writable value expression in first place. Outside the composite, you'd face a PropertyNotWritableException on submit. Just use value="#{schadenController.entity.value}".

@CSchulz

This comment has been minimized.

Show comment
Hide comment
@CSchulz

CSchulz Apr 30, 2016

Not real part of the issue, it is value="#{schadenController.entity.embeddable.value}" in my case, but it throw a PNWE because the embeddable doesn't exists.
The idea is for this use case to disable all fields and set the value to null, because it isn't writable.

CSchulz commented Apr 30, 2016

Not real part of the issue, it is value="#{schadenController.entity.embeddable.value}" in my case, but it throw a PNWE because the embeddable doesn't exists.
The idea is for this use case to disable all fields and set the value to null, because it isn't writable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment