Fragment defines a section that is partially processed whenever an Ajax request is triggered by one of its descendants, without defining component identifiers. Here the button is inside the fragment, so only the content of the fragment is processed and the required input outside of it is ignored. The nested p:autoUpdate updates the fragment.
<div class="card">
<h:form>
<div class="formgrid grid p-fluid">
<div class="field col-12 md:col-6">
<p:outputLabel for="ignored" value="Outside of the fragment"/>
<p:inputText id="ignored" required="true" placeholder="Required field" />
</div>
</div>
<p:divider />
<p:fragment>
<p:autoUpdate/>
<div class="formgrid grid p-fluid">
<div class="field col-12 md:col-6">
<p:outputLabel for="txt" value="Inside of the fragment"/>
<p:inputText id="txt" value="#{fragmentView.text}" placeholder="Fragment Field" />
<small>Value: <h:outputText value="#{fragmentView.text}"/></small>
</div>
</div>
<p:commandButton value="Submit"/>
</p:fragment>
</h:form>
</div>
package org.primefaces.showcase.view.ajax;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;
@Named
@RequestScoped
public class FragmentView {
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}