Since Primefaces upgrade to 6.0 I have a small problem with a commandButton:
When I put in the commandButton the disabled attribute = true and click on the button once it has been enabled by another event, instead of performing the action configured, it reloads the page and does not perform that action.
commandButton fails when disabled=true
Code: Select all
<p:inputText id="globalFilter" widgetVar="globalFilter"
style="width:150px" placeholder="Buscar...">
<p:ajax event="keyup" onstart="applyGlobalFilter();"
update="toolButtons" global="false"/>
</p:inputText>
<p:commandButton id="resetBtn" widgetVar="resetBtn" disabled="true"
icon="fa fa-close" styleClass="BottonClearFilter"
update="globalFilter" oncomplete="applyGlobalFilter();">
<p:resetInput target="globalFilter" />
</p:commandButton>
<script type="text/javascript">
function applyGlobalFilter() {
if (PF('globalFilter').jq.val().length == 0) {
PF('tablePF').clearFilters();
PF('resetBtn').disable();
} else {
PF('tablePF').unselectAllRows();
PF('tablePF').filter();
PF('resetBtn').enable();
}
}
</script>
PrimeFaces 12.0 | JSF 2.3 | Barcelona Theme 5.0.0
- andyba
- Expert Member
- Posts: 2473
- Joined: 31 Mar 2011, 16:27
- Location: Steinfeld, near Bremen/Osnabrück, DE
- Contact:
The button disabled state is initially set explicity set to true, this means that its state in the server side component tree will never change and the client rendered button might be enabled but the server side equivalent never will be.
Change the state on the server side and update the button via ajax.
Change the state on the server side and update the button via ajax.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Thanks for share your code.You can use onkeyup method in your code.
Code: Select all
<p:inputText id="inputt" onkeyup="
if (this.value.length>0) {
PF('resetBtn').enable();
} else {
PF('resetBtn').disable();
}
">
</p:inputText>
<p:commandButton id="resetBtn" widgetVar="resetBtn" disabled="true"
icon="fa fa-close" styleClass="BottonClearFilter"
update="globalFilter" oncomplete="applyGlobalFilter();" value="Button">
<p:resetInput target="globalFilter" />
</p:commandButton>
-
- Information
-
Who is online
Users browsing this forum: No registered users and 51 guests