Is there a way to find out the button click if a onchange is triggered

213 Views Asked by At

I have two date fields (from / to) that render the whole creatingPanel (id="createPanel") with for Example ratiobuttons(id="wiederholungsSelect") for (monthly, daily, weekly, none) depending on date range. If the "from" or "to"-date is changed the possibility for selection a ratiobutton should be updated. And if everything is filled out the user clicks a commandButton to save it.

So what happens in practice?

The User types in the from (id="gueltigAb") and to(id="gueltigBis") date and then directly clicks on the commandbutton (id="newSave"). But the click is only to trigger the onchange event of the ajax and not to trigger the button. The User now have to click the button a secound time which is very anoying.

What has been tested?

I tested although:

  • <f:ajax event="change" execute="@this" render="form:createPanel" />
  • <f:ajax event="valueChange" execute="@this" render="form:createPanel" />
  • <f:ajax event="blur" execute="@this" render="form:createPanel" />
  • <f:ajax event="change" execute="form:createPanel" render="form:createPanel" />

Is there a way to trigger the onchange and the clicked button?

<h:panelGroup id="createPanel" layout="block">
    <!-- Links Spalte -->
    <h:selectOneMenu id="grund"
        items="#{mybean.grundItems}"
        value="#{mybean.unterbrechungsgrund}">
        <rich:ajax event="change" execute="@this" render="form:createPanel"  />

    <rich:calendar id="gueltigAb"
        value="#{myBean.gueltigAb}">

        <rich:ajax event="change" execute="@this" render="form:createPanel"/>
    </rich:calendar>

    <rich:calendar id="gueltigBis"
        label="#{ui['fallverwaltung.pflegefall.unterbrechungen.erfassen.bis']}"
        value="#{myBean.unterbrechungBis}">

        <rich:ajax event="change" execute="@this" render="form:createPanel"/>
    </rich:calendar>

    <o:importConstants type="...LocalDateUtils.TerminWiederholung"/>

    <h:selectOneRadio id="wiederholungsSelect" label="#{ui['wiederholung.label']}" 
        layout="pageDirection" value="#{myBean.terminWiederholung}">
        <f:selectItem itemValue = "#{TerminWiederholung.KEINE_WIEDERHOLUNG}" 
            itemLabel="#{ui['wiederholung.keineWiederholung']}"  />
        <f:selectItem itemValue = "#{TerminWiederholung.WOECHENTLICH}" 
            itemLabel="#{ui['wiederholung.woechentlich']}" 
            itemDisabled="#{not myBean.woechentlichMoeglich()}" />
        <f:selectItem itemValue = "#{TerminWiederholung.MONATLICH}" 
            itemLabel="#{ui['.wiederholung.monatlich']}" 
            itemDisabled="#{not myBean.monatlichMoeglich()}" /> 
        <rich:ajax event="change" execute="@this" render="form:createPanel" />
    </h:selectOneRadio>

    <rich:calendar id="endDatum"
        label="#{ui['wiederholung.enddatum']}"
        value="#{myBean.terminEnddatum}">
        <rich:ajax event="change" execute="@this" render="form:createPanel" "/>
    </rich:calendar>

    <h:inputTextarea rows="6"
        maxlength="200" showRemainingCharacters="true"
        value="#{myBean.notiz}">
    </h:inputTextarea>

</h:panelGroup>

    <h:commandButton id="abortBtn"
        value="#{ui['aktion.abort']}">
        <f:ajax
            listener="#{myBean.abort()}"
            execute="@this" render="@form" />
    </h:commandButton>

    <!-- Save Button -->
    <h:commandButton id="newSave" role="submit"
        value="#{ui['aktion.save']}">
        <f:ajax
            listener="#{myBean.save()}"
            execute="@form" render="@form" />
    </h:commandButton>


0

There are 0 best solutions below