1

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Odgiiv
  • 683
  • 1
  • 11
  • 32
  • Did you try to change execute attribute to something including commandButton in question? Like execute="@this" or "@form" to begin with? – mrembisz Jul 19 '13 at 10:14
  • The dynamic include is causing that. Which JSF impl/version? – BalusC Jul 19 '13 at 12:10
  • @BalusC After several experiments. I knew that it is not dynamic include. But It calls other methods whatever these methods are before its actual method. I'm using Mojarra 2.1.23 and 2.1.24 is same. – Odgiiv Jul 20 '13 at 10:30
  • It goes through other method which is tied to another commandButton component in same view before its own action method. – Odgiiv Jul 20 '13 at 13:26

1 Answers1

5

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.

peterh
  • 11,875
  • 18
  • 85
  • 108
Odgiiv
  • 683
  • 1
  • 11
  • 32