Weird behaviour with p:commandButton in composite component

UI Components for JSF
Post Reply
Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

06 Nov 2017, 18:01

Hi,

there is something wrong with commandButton-Renderer. In the following case it will not render correctly under the right position.
I have downstripped the example to the minimum, so please do not ask why i put only a form into this custom component :roll:

Using a composite component (form.xhtml):

Code: Select all

<html
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://xmlns.jcp.org/jsf/html"
        xmlns:composite="http://xmlns.jcp.org/jsf/composite">

    <composite:interface name="form" displayName="form">
        <composite:facet name="functions" />
    </composite:interface>

    <composite:implementation>
        <h:form>
            <composite:renderFacet name="functions" />
        </h:form>
    </composite:implementation>
</html>
Now using it with different buttons:

Working:

Code: Select all

<ui:composition
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:cc="http://xmlns.jcp.org/jsf/composite/cc"
    <cc:form>
        <f:facet name="functions">
            <p:button value="Reload 1 (works)" />
            <h:commandButton value="Reload 2 (works)" />
            <h:commandButton value="Reload 3 (works)">
                <f:ajax execute="@this" resetValues="true" render="@form" />
            </h:commandButton>
        </f:facet>
    </cc:form>
</ui:composition>
Not working:

Code: Select all

<ui:composition
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:cc="http://xmlns.jcp.org/jsf/composite/cc"
    <cc:form>
        <f:facet name="functions">
            <p:commandButton value="Reload (failed)" ajax="false" />
            <p:commandButton value="Reload 2 (failed)" process="@this" update="@form" />
        </f:facet>
    </cc:form>
</ui:composition>
In this case the following expception will be thrown:
CommandButton : "2017-11-06 15:44:54,399 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] (default task-58) CommandButton : "j_idt90:j_idt91" must be inside a form element: javax.faces.FacesException: CommandButton : "j_idt90:j_idt91" must be inside a form element
at org.primefaces.component.commandbutton.CommandButtonRenderer.buildRequest(CommandButtonRenderer.java:136)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:69)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:54)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
...
Does anybody else had this problem and know what caused it or better how to fix it?

Wbr,

Daniel
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

06 Nov 2017, 20:54

Can you check the JSF impl code how or if they lookup the form on the server side?
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

07 Nov 2017, 12:21

I have looked up a little bit, but what i've found out makes me more and more suspicious:
  • The tree looks wrong (should be nc1:form:j_id91, but is nc1:j_id90:j_id91)
  • so the clientId will be generated wrong
  • form lookup cannot succeed, because form ID is not in clientId
But my main problem is to understand when/where the elements of a facet will be created an put into that JSF tree?

Wbr,

Daniel

PS: But the form will be created corretly (as nc1:form) and put into JSF tree before, which i checked by having a breakpoint in UIComponentBase#getClientId().
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests