jsfactionactionlistenercommandbutton

h:commandbutton with ajax calls wrong action methods


I have problem with jsf <h:commandButton> with <f:ajax> tag. If it has <f:ajax> tag, it calls other action and actionListener methods in the backing bean. If it doesn't have the <f:ajax> tag it calls its own right action method. here is my snippet:

 <h:form>
    <h:panelGroup id="loanContent" layout="block">
        <ui:include src="#{mainView.typePage}.xhtml"/>
    </h:panelGroup>
    <h:commandButton id ="rLoanBtn" value="Create" action="#{mainView.createNewType}">
        <f:ajax execute="loanContent" render="@form"/>
    </h:commandButton>  
 </h:form>

if I omit <f:ajax execute="loanContent"/> part, it works fine. If I leave as it is, it calls other methods which are responsible for other buttons of the same form. Btw mainView backing bean is a ViewScoped managed bean.


Solution

  • I have found out cause. If I have <type = "button"> attribute with other buttons, it goes through methods that is bind to other buttons before its actual method. So I omitted it then it works fine.