H: commandlink/h: Why commandbutton is not executed

Source: Internet
Author: User
Stackoverflow found a Q & A, a very detailed list of possible situations, I met 7th points, I believe that friends who do JSF development will encounter such problems.
H: commandlink/h: commandbutton is not being invoked

WheneverUICommandComponent fails to invoke the associated action method or
UIInputElement fails to update the model value, then verify the following:

  1. UICommandAndUIInputComponents must be placed inside
    UIFormComponent, e.g..

  2. You cannot nest multipleUIFormComponents in each other. This is namely illegal in HTML. Watch out with include files!

  3. NoUIInputValue validation/Conversion error shoshould have been occurred. You can use
    To show any messages which are not shown by any input-specific
    Components. Don't forget to includeidOf
    In<f:ajax render>, If any, so that it will be updated as well on AJAX requests.

  4. IfUICommandOrUIInputComponents are placed inside an iterating component like
    ,<ui:repeat>, Etc, then you need to ensure that exactly the same
    valueOf the component is been preserved during the apply request values phase of the form submit request. JSF will namely reiterate over it to find the clicked link/button and submitted input values. putting the bean in the view scope and/or making
    Sure that you load the data model in (post) constructor of the bean (and thus not in the getter Method !) Shocould fix it.

  5. TherenderedAttribute of the component and all of the parent components shocould not evaluate
    falseDuring the apply request values phase of the form submit request. JSF will namely recheck It then as part of safeguard against tampered/hacked requests. putting the bean in the view scope and/or making sure that you're preinitializing
    Condition in (post) constructor of the bean shocould fix it. The same applies to
    disabledAttribute of the component, which shocould not evaluate
    true
    During Processing the form submit.

  6. If you're using JSF 2.x<f:ajax>On the Command component, make sure that you have
    In the master template instead of. Otherwise JSF won't be able to auto-include the necessary
    jsf.jsJavascript file which contains the Ajax functions. This wowould result in a javascript error like "mojarra is not defined" in the browser's builtin JavaScript console.

  7. If a parent ofWith
    UICommandButton is been rendered/updated by an Ajax request beforehand, then the first action will always fail. the second and subsequent actions will work. this is caused by a bug in view State handling which is reported
    JSF spec issue 790 and fixed in JSF 2.2. For JSF 2.0 and 2.1 you need to explicitly specify the ID of
    InrenderOf<f:ajax>.

  8. Be sure thatActionEventArgument
    actionListenerIsjavax.faces.event.ActionEventAnd thus not
    java.awt.event.ActionEvent, Which is what most ides suggest as 1st AutoComplete option.

  9. Be sure that noPhaseListenerOr any
    EventListenerIn the request-response chain has changed the JSF lifecycle to skip the invoke action phase by for example calling
    FacesContext#renderResponse()OrFacesContext#responseComplete().

  10. Be sure that noFilterOrServletIn the same request-response chain has blocked the request fo
    FacesServletSomehow.

My bet thatYour ParticleProblem is caused by Point 2:
Nested forms. You probably already haveIn the parent page which wraps the include file. The include file itself shocould
NotHave. You can also fix it the other way round, ensure that the parent page does
NotHaveAround the place of the include file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.