Skip to content
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

All inputs inside composite component executed when using <f:ajax> execute="@this" #5032

Closed
codylerum opened this issue Jan 7, 2022 · 5 comments

Comments

@codylerum
Copy link
Contributor

After upgrading from Wildfly 24 to Wildfly 26 have run into a regression in mojarra. This was an upgrade from mojarra 2.3.14 to 2.3.17

What is happening is that I'm using a simple composite component as a layout.

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:cc="http://xmlns.jcp.org/jsf/composite">
    <cc:interface>
        <cc:attribute name="header" required="true"/>
    </cc:interface>
    <cc:implementation>
        <div class="card">
            <div class="card-header">
                #{cc.attrs.header}
            </div>
            <div class="card-body">
                <cc:insertChildren/>
            </div>
        </div>
    </cc:implementation>
</ui:composition>

This has worked fine up until now. However now I am seeing that if I have a <f:ajax anywhere within the inserted children then an execute value of @this means the entire contents of the composite component. For example

<demo:card header="This is a composite component">
      <div class="col-md-4">
          <h:outputLabel for="compositeFirstName"
                         styleClass="form-label">First Name</h:outputLabel>
          <h:inputText id="compositeFirstName" value="#{backingBean.firstName}"
                       styleClass="form-control" required="true"/>
          <div class="invalid-feedback d-block">
              <h:message for="compositeFirstName"/>
          </div>
      </div>
      <div class="col-md-4">
          <h:outputLabel for="compositejob"
                         styleClass="form-label">Job</h:outputLabel>
          <h:selectOneMenu id="compositejob" value="#{backingBean.job}"
                           styleClass="form-control"
                           required="true">
              <f:selectItem itemValue="Butcher"/>
              <f:selectItem itemValue="Baker"/>
              <f:selectItem itemValue="Candlestick Maker"/>
              <f:ajax execute="@this" render="@form"/>
          </h:selectOneMenu>
          <div class="invalid-feedback d-block">
              <h:message for="compositejob"/>
          </div>
      </div>
</demo:card>

When a value is selected in the selectOneMenu it executes both compositejob and compositeFirstName which may cause things to fail if compositeFirstName is required=true and unset.

I've prepared a repo project at https://github.com/codylerum/execute-this which shows the issue. If you deploy this on Wildfly 24 both pages will work and if you deploy it on Wildfly 26 then the composite version will fail.

I'm assuming this is a result of #4915

@BalusC is what I'm seeing the expected behavior, or should it only apply to all the contents of the composite if the f:ajax is a direct child of the composite, like

<my:inputLocalTime>
    <f:ajax execute="@this" />
</my:inputLocalTime>
@codylerum codylerum changed the title All inputs inside composite component executed when using f:ajax execute="@this" All inputs inside composite component executed when using <f:ajax> execute="@this" Jan 7, 2022
@BalusC
Copy link
Contributor

BalusC commented Jan 13, 2022

Point taken. This should indeed not happen.

@BalusC
Copy link
Contributor

BalusC commented Jan 13, 2022

While implementing the IT, I noticed that a work around is to simply omit the execute="@this". It will then be correctly implied.

BalusC added a commit that referenced this issue Jan 13, 2022
Implement integration test for issue 5032
BalusC added a commit that referenced this issue Jan 13, 2022
Fix case when f:ajax is handled by cc:insertChildren
BalusC added a commit that referenced this issue Jan 13, 2022
@codylerum
Copy link
Contributor Author

@BalusC Thanks for the quick response.

If anyone else runs in to this you can also just directly reference the client id that would be the correct @this

<h:selectOneMenu id="compositejob" value="#{backingBean.job}" styleClass="form-control" required="true">  
    <f:selectItem itemValue="Butcher"/>
    <f:selectItem itemValue="Baker"/>
    <f:selectItem itemValue="Candlestick Maker"/>
    <f:ajax execute="compositejob" render="@form"/>
</h:selectOneMenu>

BalusC added a commit that referenced this issue Jan 13, 2022
Merge remote-tracking branch 'origin/2.3' into 3.0
@BalusC
Copy link
Contributor

BalusC commented Jan 13, 2022

All merged now.

@BalusC BalusC closed this as completed Jan 13, 2022
@BalusC
Copy link
Contributor

BalusC commented Jul 30, 2023

FYI impl has been further improved in #5294

BalusC added a commit that referenced this issue Sep 7, 2023
…adoc_errors

Fix javadoc errors on #5032 (com.sun.faces.* is also checked in 4.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants