You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2005/07/20 19:13:34 UTC

[Myfaces Wiki] Update of "SubmitPageOnValueChange" by MikeKienenberger

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by MikeKienenberger:
http://wiki.apache.org/myfaces/SubmitPageOnValueChange

New page:
##language:en
== How To Submit a page when an input control value changes ==
Note:  This task requires javascript.

To submit a page when an input control value changes, add an onchange attribute to call a javascript function which will click a commandButton.   The commandButton submits the form which contains the control.  The javascript function must reference the fully-qualified button name (in the example below, `myForm:myUpdateButton`)

Optionally, you can use a hidden commandButton to invoke an action other than the default form submit button.  (display:none or visibility:hidden)

=== Example ===
{{{
<script language="javascript">
    function pulldownChanged(){
        document.getElementById("myForm:myUpdateButton").click();
    }
</script>

[...]

<f:view>
    <h:form id="myForm">

        <h:selectOneMenu
            id="namedLocationInput"
            onchange="pulldownChanged()"
            value="#{page.physicalLocation}"
            title="No location selected"
            required="true">
            <f:selectItems
                value="#{page.locationItems}"/>
        </h:selectOneMenu>

        <h:commandButton
            id="myUpdateButton"
            value="Submit"
            action="#{page.update}"/>

    </h:form>
</f:view>

}}}

Thanks to Slawek for this tip.