o:validateBean throws NullPointerException if an Input field is conditionally rendered on the form with EL #150

Closed
exabrial opened this Issue Jul 15, 2015 · 4 comments

Projects

None yet

2 participants

@exabrial

If you have an inputField on your form that's conditionally rendered using EL, o:validateBean will toss an NPE.

Easiest fix I came up with is to do additional null checks inside that method, but there's probably a better way to just check if the component is even rendered first.

            <b:inputText
                id="readOnlyStateInputText"
                value="#{leadMB.lead.findResidenceState()}"
                disabled="true"
                label="State"
                rendered="#{leadMB.lead.findResidenceState() ne null}" />
                                <b:buttonGroup id="pageActionsButtonGroup">
                                    <h:commandButton
                                        id="updateLeadCommandButton"
                                        styleClass="btn btn-default"
                                        action="#{leadMB.updateLead}"
                                        value="Save Changes to Lead"
                                        disabled="#{!leadMB.leadEditMode and leadMB.newLeadNote eq null
                                    and empty leadMB.quotesBeingEdited 
                                    and empty leadMB.policiesBeingEdited and empty leadMB.phonesBeingEdited
                                    and empty leadMB.addressesBeingEdited and empty leadMB.emailsBeingEdited}">
                                        <f:ajax
                                            event="click"
                                            execute="@form"
                                            render="@form" />
                                        <o:validateBean
                                            value="#{leadMB.lead}"
                                            validationGroups="com.xxx.shp.validation.ShpUserValidationGroup" />
                                    </h:commandButton>
Caused by: java.lang.NullPointerException: null
    at org.omnifaces.taghandler.ValidateBean$6.invoke(ValidateBean.java:333) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.taghandler.ValidateBean$6.invoke(ValidateBean.java:326) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.util.Components$ForEach$1.visit(Components.java:492) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.util.Components$ForEach$TypesVisitCallback.visit(Components.java:557) ~[omnifaces-2.1.jar:2.1]
    at org.apache.myfaces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:141) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1016) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1044) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1191) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIForm.visitTree(UIForm.java:345) ~[myfaces-api-2.2.8.jar:2.2.8]
    at org.omnifaces.util.Components$ForEach.invoke(Components.java:525) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.util.Components$ForEach.invoke(Components.java:489) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.taghandler.ValidateBean.forEachInputWithMatchingBase(ValidateBean.java:326) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.taghandler.ValidateBean.access$400(ValidateBean.java:151) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.taghandler.ValidateBean$3.run(ValidateBean.java:286) ~[omnifaces-2.1.jar:2.1]
    at org.omnifaces.taghandler.ValidateBean$ValidateBeanCallback.invoke(ValidateBean.java:430) ~[omnifaces-2.1.jar:2.1]
    ... 43 common frames omitted
@exabrial exabrial pushed a commit to exabrial/omnifaces that referenced this issue Jul 15, 2015
Jonathan S. Fisher Fix omnifaces#150 eff0569
@exabrial exabrial pushed a commit to exabrial/omnifaces that referenced this issue Jul 15, 2015
Jonathan S. Fisher Fix omnifaces#150 36f98ef
@BalusC BalusC closed this in 0a115d0 Aug 10, 2015
@BalusC
Member
BalusC commented Aug 10, 2015

Can you please try today's snapshot to see if that fixes the current problem? (and probably also indirectly #152 — if that doesn't, then we'd still like to see a reproducer for 152)

@BalusC
Member
BalusC commented Aug 30, 2015

Any feedback?

@exabrial

We've been running our patch :) I'll try yours and get back to you

@exabrial

Seems to be fixed. Thanks!

@BalusC BalusC added the bug label Oct 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment